// mic or instrument input through pitch shifter with random variation // patch mic through effect to left and direct to right adc.chan(0) => Gain inGainL => PitShift p => ResonZ f1 => dac.chan(0); adc.chan(0) => Gain inGainR => p => ResonZ f2 => dac.chan(1); // patch Clarinet to output Clarinet clar => NRev rev => dac; clar.noteOn(0.05); clar.vibratoGain(0.5); // set effect mix to full on rev.mix(0.5); // set filter Q 10 => f1.Q; 10 => f2.Q; // set effect mix to full on p.mix(0.5); // smoothing envelope to use for variation Step unity => Envelope pEnv => blackhole; 500::ms => dur updateDur; pEnv.duration(updateDur); // for clarinet unity => Envelope pitchEnv => blackhole; unity => Envelope pressEnv => blackhole; pitchEnv.duration(updateDur); pressEnv.duration(updateDur); Logistic pitch; pitch.set(0.7, 3.7); Logistic press; press.set(0.6, 3.6); // instantiate our class and initialize Random ran; ran.set(0.7, 1.4); // spork an update function to vary shift amount smoothly fun void smoothUpdates() { while( true ) { p.shift(pEnv.last()); clar.freq(Std.mtof(60.0 + 12.0 * pitchEnv.last())); clar.pressure( (.9 * pressEnv.last()) ); 1::samp => now; } } spork ~smoothUpdates(); // control loop float t; 0 => int k; while( true ) { // sweep the cutoff 10 + Std.fabs(Math.sin(1.3*t)) * 1000 => f1.freq; 10 + Std.fabs(Math.sin(t)) * 1000 => f2.freq; // increment t .005 +=> t; ran.tick() => float tmp; pEnv.target(tmp); if (k % 100 == 0){ pitchEnv.target(pitch.tick()); pressEnv.target(press.tick()); } k + 1 => k; 3.84::ms => now; } class Random { float _l, _h; false => int isSet; fun void set( float l, float h ) { l => _l; h => _h; true => isSet; } fun float tick( ) { if (!isSet) { <<<"Periodic not set, quitting","\ntry adding something like... .set(0.0, 1.0); // for initial freq and amp">>>; me.exit(); } return Std.rand2f(_l, _h); } } class Logistic { float _x, _r; false => int isSet; fun void set( float x, float r ) { x => _x; r => _r; true => isSet; } fun float tick( ) { if (!isSet) { <<<"Logistic not set, quitting","\ntry adding something like... .set(0.7, 3.1); // for initial x value and r coefficient">>>; me.exit(); } (_r * _x) * (1.0 - _x) => _x; return _x; } }