//Uses a sine "LFO" to add vibrato //Our sound-making sine: connect to dac SinOsc s => dac; //Our vibrato sine: connect to blackhole so we don't //hear it, but it still computes a sine wave we can use SawOsc s2 => blackhole; 4 => s2.freq; //vibrato freq: Change to other numbers (10, 200, etc.) for other sounds 4 => s2.gain; //vibrato gain: change to other numbers (1, 10, 100, etc.) for other sounds //Target frequency of our melody oscillator float frequency; spork ~playMelody(); spork ~controlVibrato(); //Advance time in parent shred so that children don't die: 1::hour => now; fun void playMelody() { while (true) { Std.mtof(Std.rand2(60, 72)) => frequency; //not the catchiest melody 1::second => now; } } fun void controlVibrato() { while(true) { //s2.last() gets last value output by s2. Add that to our target frequency to create vibrato: s2.last() + frequency => s.freq; 1::samp => now; //repeat calculation every sample for truly nice vibrato. can play with updating this less frequently... } }