| 1 |
//--------------------------------------| |
| 2 |
// Dyno demo 1: "Limiter? I hardly know 'er!" |
| 3 |
// Takes otf_07.ck, cranks the gain up obscenely high, then limits |
| 4 |
// it so it won't clip. |
| 5 |
// |
| 6 |
// authors: Matt Hoffman (mdhoffma at cs.princeton.edu) |
| 7 |
// Ge Wang (gewang at cs.princeton.edu) |
| 8 |
// Perry Cook (prc at cs.princeton.edu) |
| 9 |
//--------------------------------------| |
| 10 |
|
| 11 |
// this synchronizes to period |
| 12 |
.5::second => dur T; |
| 13 |
T - (now % T) => now; |
| 14 |
|
| 15 |
// construct the patch |
| 16 |
SndBuf buf => Gain g => Dyno dy => JCRev r => dac; |
| 17 |
me.sourceDir() + "/../data/kick.wav" => buf.read; |
| 18 |
.01 => r.mix; |
| 19 |
|
| 20 |
// make gain way too high, i.e. force clipping |
| 21 |
100 => g.gain; |
| 22 |
// turn on limiter functionality |
| 23 |
dy.limit(); |
| 24 |
// compensate for the limiter's gain reduction |
| 25 |
5 => dy.gain; |
| 26 |
// uncomment this to turn off the limiter. note that just because clipping |
| 27 |
// sounds cool here doesn't mean it will in your patch. |
| 28 |
// -1 => dy.op; |
| 29 |
|
| 30 |
// where we actually want to start |
| 31 |
25 => int where; |
| 32 |
|
| 33 |
// time loop |
| 34 |
while( true ) |
| 35 |
{ |
| 36 |
Math.random2f(.8,.9) => buf.gain; |
| 37 |
|
| 38 |
// note: Math.randomf() returns value between 0 and 1 |
| 39 |
if( Math.randomf() > .75 ) |
| 40 |
{ |
| 41 |
0 => int i; |
| 42 |
while( i < 8 ) |
| 43 |
{ |
| 44 |
i / 8.0 => buf.gain; |
| 45 |
where => buf.pos; |
| 46 |
(1.0/8.0)::T => now; |
| 47 |
i++; |
| 48 |
} |
| 49 |
|
| 50 |
while( i > 0 ) |
| 51 |
{ |
| 52 |
i / 8.0 => buf.gain; |
| 53 |
where => buf.pos; |
| 54 |
(1.0/8.0)::T => now; |
| 55 |
i--; |
| 56 |
} |
| 57 |
} |
| 58 |
else |
| 59 |
{ |
| 60 |
.9 => buf.gain; |
| 61 |
where => buf.pos; |
| 62 |
.25::T => now; |
| 63 |
.3 => buf.gain; |
| 64 |
where => buf.pos; |
| 65 |
.25::T => now; |
| 66 |
.3 => buf.gain; |
| 67 |
where => buf.pos; |
| 68 |
.25::T => now; |
| 69 |
|
| 70 |
.9 => buf.gain; |
| 71 |
where => buf.pos; |
| 72 |
.25::T => now; |
| 73 |
.3 => buf.gain; |
| 74 |
where => buf.pos; |
| 75 |
.25::T => now; |
| 76 |
.3 => buf.gain; |
| 77 |
where => buf.pos; |
| 78 |
.25::T => now; |
| 79 |
|
| 80 |
.9 => buf.gain; |
| 81 |
where => buf.pos; |
| 82 |
.25::T => now; |
| 83 |
.3 => buf.gain; |
| 84 |
where => buf.pos; |
| 85 |
.25::T => now; |
| 86 |
} |
| 87 |
} |