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