| 1 |
//---------------| |
| 2 |
// mand-o-matic! (simplified version) |
| 3 |
// by: Ge Wang ([email protected]) |
| 4 |
// Perry R. Cook ([email protected]) |
| 5 |
//------------------| |
| 6 |
|
| 7 |
// our patch |
| 8 |
Mandolin mand => JCRev r => dac; |
| 9 |
// set the gain |
| 10 |
.95 => r.gain; |
| 11 |
// set the reverb mix |
| 12 |
.05 => r.mix; |
| 13 |
|
| 14 |
// scale |
| 15 |
[ 0, 2, 4, 7, 9 ] @=> int scale[]; |
| 16 |
|
| 17 |
// our main loop |
| 18 |
while( true ) |
| 19 |
{ |
| 20 |
// position |
| 21 |
Math.random2f( 0.2, 0.8 ) => mand.pluckPos; |
| 22 |
// frequency... |
| 23 |
scale[Math.random2(0,scale.size()-1)] => int freq; |
| 24 |
45 + Math.random2(0,3)*12 + freq => Std.mtof => mand.freq; |
| 25 |
// pluck it! |
| 26 |
Math.random2f( 0.2, 0.9 ) => mand.pluck; |
| 27 |
|
| 28 |
// how much to wait |
| 29 |
if( Math.random2f(0,1) > .95 ) // long note |
| 30 |
{ 500::ms => now; } |
| 31 |
else if( Math.random2f(0,1) > .95 ) // short |
| 32 |
{ 250::ms => now; } |
| 33 |
else if( Math.random2f(0,1) > .05 ) // shorter |
| 34 |
{ .125::second => now; } |
| 35 |
else // trill |
| 36 |
{ |
| 37 |
1 => int i => int pick_dir; |
| 38 |
// how many times |
| 39 |
4 * Math.random2( 1, 5 ) => int pick; |
| 40 |
0.0 => float pluck; |
| 41 |
0.7 / pick => float inc; |
| 42 |
// time loop |
| 43 |
for( ; i < pick; i++ ) |
| 44 |
{ |
| 45 |
75::ms => now; |
| 46 |
Math.random2f(.2,.3) + i*inc => pluck; |
| 47 |
pluck + -.2 * pick_dir => mand.pluck; |
| 48 |
// simulate pluck direction |
| 49 |
!pick_dir => pick_dir; |
| 50 |
} |
| 51 |
// let time pass for final pluck |
| 52 |
75::ms => now; |
| 53 |
} |
| 54 |
} |