History

Merge pull request #281 from terryzfeng/patch-1

Update oscillatronx example

Ge Wang committed 3 years ago

Commit abf4d982 parents cd9bf56 8bf95cd1 file · +14 −9Browse files

Unified · Split

examples/basic/oscillatronx.ck+14−9
@@ -1,5 +1,10 @@
1// oscillator demo1//------------------------------------------------------------------
2// - philipd2// 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-tones9// 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
10TriOsc tri => dac;15TriOsc tri => dac;
11PulseOsc pul => dac;16PulseOsc pul => dac;
12SqrOsc sqr => dac;17SqrOsc sqr => dac;
13// modulator and carrier18// FM modulator and carrier
14TriOsc trictrl => SinOsc sintri => dac;19TriOsc trictrl => SinOsc sintri => dac;
15// interpret input as frequency modulation20// interpret input as frequency modulation
162 => sintri.sync;212 => sintri.sync;
@@ -31,17 +36,17 @@ TriOsc trictrl => SinOsc sintri => dac; · 14 unmodified lines
31while( true )36while( true )
32{ 37{
33 // randomize38 // 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 value42 // 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 frequency44 // set frequency
40 newnote => oscillators[select].freq;45 newnote => oscillators[select].freq;
41 // wait a bit46 // wait a bit
42 0.25::second => now;47 0.25::second => now;
43 // 10 times48 // 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() >>>;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t