| 1 |
// STK Flute |
| 2 |
|
| 3 |
// patch |
| 4 |
Flute flute => PoleZero f => JCRev r => dac; |
| 5 |
.75 => r.gain; |
| 6 |
.05 => r.mix; |
| 7 |
.99 => f.blockZero; |
| 8 |
|
| 9 |
// our notes |
| 10 |
[ 61, 63, 65, 66, 68 ] @=> int notes[]; |
| 11 |
|
| 12 |
// infinite time-loop |
| 13 |
while( true ) |
| 14 |
{ |
| 15 |
// clear |
| 16 |
flute.clear( 1.0 ); |
| 17 |
|
| 18 |
// set |
| 19 |
Math.random2f( 0, 1 ) => flute.jetDelay; |
| 20 |
Math.random2f( 0, 1 ) => flute.jetReflection; |
| 21 |
Math.random2f( 0, 1 ) => flute.endReflection; |
| 22 |
Math.random2f( 0, 1 ) => flute.noiseGain; |
| 23 |
Math.random2f( 0, 12 ) => flute.vibratoFreq; |
| 24 |
Math.random2f( 0, 1 ) => flute.vibratoGain; |
| 25 |
Math.random2f( 0, 1 ) => flute.pressure; |
| 26 |
|
| 27 |
// print |
| 28 |
<<< "---", "" >>>; |
| 29 |
<<< "jetDelay:", flute.jetDelay() >>>; |
| 30 |
<<< "jetReflection:", flute.jetReflection() >>>; |
| 31 |
<<< "endReflection:", flute.endReflection() >>>; |
| 32 |
<<< "noiseGain:", flute.noiseGain() >>>; |
| 33 |
<<< "vibratoFreq:", flute.vibratoFreq() >>>; |
| 34 |
<<< "vibratoGain:", flute.vibratoGain() >>>; |
| 35 |
<<< "breath pressure:", flute.pressure() >>>; |
| 36 |
|
| 37 |
// factor |
| 38 |
Math.random2f( .75, 2 ) => float factor; |
| 39 |
|
| 40 |
for( int i; i < notes.size(); i++ ) |
| 41 |
{ |
| 42 |
play( 12 + notes[i], Math.random2f( .6, .9 ) ); |
| 43 |
300::ms * factor => now; |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
// basic play function (add more arguments as needed) |
| 48 |
fun void play( float note, float velocity ) |
| 49 |
{ |
| 50 |
// start the note |
| 51 |
Std.mtof( note ) => flute.freq; |
| 52 |
velocity => flute.noteOn; |
| 53 |
} |