| 1 |
// power up! |
| 2 |
// - philipd |
| 3 |
|
| 4 |
// global noise source |
| 5 |
Noise n; |
| 6 |
|
| 7 |
// sweep shred |
| 8 |
fun void sweep( float st, float inc, time end) |
| 9 |
{ |
| 10 |
//set up the audio chain |
| 11 |
n => TwoPole z => dac; |
| 12 |
1 => z.norm; |
| 13 |
0.1 => z.gain; |
| 14 |
st => z.freq; |
| 15 |
|
| 16 |
//store the time we entered the thread |
| 17 |
now => time my_start; |
| 18 |
0.0 => float my_seconds; |
| 19 |
|
| 20 |
Math.random2f( 0.94, 0.99 ) => z.radius; |
| 21 |
|
| 22 |
// keep going until we've passed the end time sent in by the control thread. |
| 23 |
while( now < end ) |
| 24 |
{ |
| 25 |
( now - my_start ) / 1.0::second => my_seconds; |
| 26 |
Math.max( my_seconds * 4.0, 1.0 ) * 0.1 => z.gain; |
| 27 |
z.freq() + inc * -0.02 => z.freq; |
| 28 |
10::ms => now; |
| 29 |
} |
| 30 |
|
| 31 |
n =< z; |
| 32 |
z =< dac; |
| 33 |
} |
| 34 |
|
| 35 |
// time loop |
| 36 |
while( true ) |
| 37 |
{ |
| 38 |
500::ms => dur d; |
| 39 |
if( Math.random2( 0, 10 ) > 3 ) d * 2.0 => d; |
| 40 |
if( Math.random2( 0, 10 ) > 6 ) d * 3.0 => d; |
| 41 |
spork ~ sweep( 220.0 * Math.random2(1,8), |
| 42 |
880.0 + Math.random2f(100.0, 880.0), |
| 43 |
now + Math.random2f(1.0, 3.0)::second ); |
| 44 |
d => now; |
| 45 |
} |