| 1 |
// STK StifKarp |
| 2 |
|
| 3 |
// patch |
| 4 |
StifKarp m => NRev r => dac; |
| 5 |
.75 => r.gain; |
| 6 |
.02 => r.mix; |
| 7 |
|
| 8 |
// our notes |
| 9 |
[ 61, 63, 65, 66, 68, 66, 65, 63 ] @=> int notes[]; |
| 10 |
|
| 11 |
// infinite time-loop |
| 12 |
while( true ) |
| 13 |
{ |
| 14 |
Math.random2f( 0, 1 ) => m.pickupPosition; |
| 15 |
Math.random2f( 0, 1 ) => m.sustain; |
| 16 |
Math.random2f( 0, 1 ) => m.stretch; |
| 17 |
|
| 18 |
<<< "---", "" >>>; |
| 19 |
<<< "pickup:", m.pickupPosition() >>>; |
| 20 |
<<< "sustain:", m.sustain() >>>; |
| 21 |
<<< "stretch:", m.stretch() >>>; |
| 22 |
|
| 23 |
// factor |
| 24 |
Math.random2f( 1, 4 ) => float factor; |
| 25 |
|
| 26 |
for( int i; i < notes.size(); i++ ) |
| 27 |
{ |
| 28 |
play( Math.random2(0,2)*12 + notes[i], Math.random2f( .6, .9 ) ); |
| 29 |
100::ms * factor => now; |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
// basic play function (add more arguments as needed) |
| 34 |
fun void play( float note, float velocity ) |
| 35 |
{ |
| 36 |
// start the note |
| 37 |
Std.mtof( note ) => m.freq; |
| 38 |
velocity => m.pluck; |
| 39 |
} |