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