1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
//------------------------------------------------------------------
// name: oscillatronx (oscillator demo)
// desc: playing all of the different types of oscillator UGens
// mixing together different timbres to create a sonic texture
//
// author: philipd
//------------------------------------------------------------------
// scale degrees in semi-tones
[ 0, 2, 4, 7, 9 ] @=> int f[];
// various oscialltors
SinOsc s => dac;
SawOsc saw => dac;
TriOsc tri => dac;
PulseOsc pul => dac;
SqrOsc sqr => dac;
// FM modulator and carrier
TriOsc trictrl => SinOsc sintri => dac;
// interpret input as frequency modulation
2 => sintri.sync;
100 => trictrl.gain;
// array of Oscs
[ s, saw, tri, pul, sqr, trictrl ] @=> Osc oscillators[];
// set gains
0.2 => s.gain;
0.1 => saw.gain;
0.1 => tri.gain;
0.1 => pul.gain;
0.1 => sqr.gain;
0.1 => sintri.gain;
// infinite time-loop
while( true )
{
// randomize
Math.random2(0,7) => int select;
// clamp (giving more weight to 5)
if( select > 5 ) 5 => select;
// generate new frequenc value
Std.mtof( f[Math.random2( 0, 4 )] + 60 ) => float newnote;
// set frequency
newnote => oscillators[select].freq;
// wait a bit
0.25::second => now;
// 10 times
repeat(10)
{
Math.random2f( 0.2, 0.8 ) => trictrl.width;
// <<< "trictrl width:", trictrl.width() >>>;
0.05::second => now;
}
}
|