| 1 |
// in this example, this demonstrates using |
| 2 |
// a custom class defined by the C++ host |
| 3 |
// (see example-5-custom-api.cpp) |
| 4 |
FooFoo foo( 220 ); |
| 5 |
|
| 6 |
// testing constructor, should print 220 |
| 7 |
<<< "FooFoo value from constructor:", foo.getValue() >>>; |
| 8 |
// testing static function call, should print 3 |
| 9 |
<<< "static function test FooFoo.add():", FooFoo.add( 1, 2 ) >>>; |
| 10 |
|
| 11 |
// base duration |
| 12 |
300::ms => dur T; |
| 13 |
|
| 14 |
//-------- some audio setup ------------ |
| 15 |
// (adapted from blit4.ck, or rather blit4 came out of this) |
| 16 |
Blit s => LPF lpf => PoleZero dcb => ADSR e => Gain g => JCRev r => dac; |
| 17 |
// feedback |
| 18 |
g => DelayL eicho => g; .65 => eicho.gain; |
| 19 |
// block zero |
| 20 |
.99 => dcb.blockZero; |
| 21 |
// lower the volume a bit |
| 22 |
.65 => s.gain; |
| 23 |
// delay settings |
| 24 |
T/2*3 => eicho.max => eicho.delay; |
| 25 |
// reverb mix |
| 26 |
.15 => r.mix; |
| 27 |
// lowpass cutoff |
| 28 |
8000 => lpf.freq; |
| 29 |
// set adsr |
| 30 |
e.set( 15::ms, 13::ms, .5, T/3 ); |
| 31 |
//--------------------------------- |
| 32 |
|
| 33 |
// time loop |
| 34 |
while( true ) |
| 35 |
{ |
| 36 |
// set value |
| 37 |
foo.setValue( 55 * Math.pow(2,Math.random2(0,3)) ); |
| 38 |
// increment |
| 39 |
foo.getValue() => float inc; |
| 40 |
// print marker |
| 41 |
<<< "--------", "" >>>; |
| 42 |
|
| 43 |
// repeat |
| 44 |
repeat( Math.random2(3,12) ) |
| 45 |
{ |
| 46 |
// 5 |
| 47 |
<<< "foo's value:", foo.getValue() >>>; |
| 48 |
// set frequency |
| 49 |
foo.getValue() => s.freq; |
| 50 |
// harmonics |
| 51 |
Math.random2( 1, 6 ) => s.harmonics; |
| 52 |
// key on |
| 53 |
e.keyOn(); |
| 54 |
// advance time |
| 55 |
T - e.releaseTime() => now; |
| 56 |
// key off |
| 57 |
e.keyOff(); |
| 58 |
// advance time |
| 59 |
e.releaseTime() => now; |
| 60 |
// increment |
| 61 |
foo.increment( inc ); |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
// let it ring |
| 66 |
500::ms => now; |