// FM synthesis SinOsc m => SinOsc c => dac; 2 => c.sync; // ratio .5 => float ratio; float ratio_target; // index of modulation 50 => m.gain; // targets float c_freq_target; // spork spork ~ interp(); spork ~ ratio_ctrl(); // go! while( true ) { // update carrier Std.rand2( 48, 72 ) => Std.mtof => c_freq_target; // print <<< "freq target:", c_freq_target >>>; // advance time Std.rand2( 2, 3 ) * 400::ms => now; } fun void ratio_ctrl() { while( true ) { // update ratio Std.rand2f( .2, .8 ) => ratio_target; // print <<< "ratio target:", ratio_target >>>; // advance time Std.rand2f( 1500, 2500 )::ms => now; } } fun void interp() { // define slew 0.01 => float slew; // go while( true ) { // moving towards... ( c_freq_target - c.freq() ) * slew + c.freq() => c.freq; ( ratio_target - ratio ) * slew + ratio => ratio; // modulator freq ratio * c.freq() => m.freq; // advance time 5::ms => now; } }