=========================== Random Frequency Oscillator =========================== Generate a sine wave whose frequency changes to a random value between 30 and 1000 Hz every 100 milliseconds for an infinte time. Stride ====== :: signal FrequencyValue { rate: 10. } Random ( minimum: 30. maximum: 1000. ) >> FrequencyValue; Oscillator ( type: 'Sine' frequency: FrequencyValue ) >> AudioOut; .. highlight:: rst Chuck ===== :: SinOsc s => dac; while( true ) { 100::ms => now; Std.rand2f(30.0, 1000.0) => s.freq; } Gibber ====== :: Sine().frequency.seq(Rndf(30, 1000), ms(100)) .. highlight:: py cSound ====== :: sr = 44100 ksmps = 128 nchnls = 2 0dbfs = 1.0 turnon 1 instr 1 kRand randh 970, 10, 10 aout oscili 0.5, 30+ kRand, 1 outs aout, aout endin f 1 0 16384 10 1 e 3600 SuperCollider ============= :: { var freq = LFNoise0.kr(10,970,30); SinOsc.ar([freq,freq],0,0.25,0); }.play; :: SynthDef(\sinewave, { |freq = 440| var output = SinOsc.ar(freq, 0 ,0.1); Out.ar([1,0], output); }).send; r = Routine({ var delta; x = Synth(\sinewave); loop { delta = 0.100; x.set(\freq, rrand(30,1000)); delta.yield; } }); TempoClock.default.sched(0, r); r.stop; x.free; .. highlight:: cpp Gamma ===== :: #include #include "Gamma/Gamma.h" #include "Gamma/AudioIO.h" #include "Gamma/Oscillator.h" using namespace gam; Accum<> tmr(10.0); Sine<> osc(440.0); void audioCB(AudioIOData& io){ while(io()){ if(tmr()){ osc.freq(rnd::uni(1.f) * 970 + 30); } io.out(0) = io.out(1) = osc(); } } int main(int argc, char* argv[]){ AudioIO io(4096, 44100, audioCB, NULL, 2); Sync::master().spu(io.framesPerSecond()); io.start(); printf("Press 'enter' to quit...\n"); getchar(); return 0; }