History

more comments for example code

Ge Wang committed 5 years ago

Commit ca9d35a1 parent 6a08fca2 files · +47 −22Browse files

Showing the changes to examples/basic (1 of 2 files). Show all

Unified · Split

examples/basic/oscillatronx.ck+24−10
@@ -1,36 +1,50 @@
11 // oscillator demo
22 // - philipd
33
4+// scale degrees in semi-tones
45 [ 0, 2, 4, 7, 9 ] @=> int f[];
56
7+// various oscialltors
68 SinOsc s => dac;
79 SawOsc saw => dac;
810 TriOsc tri => dac;
911 PulseOsc pul => dac;
1012 SqrOsc sqr => dac;
11−
13+// modulator and carrier
1214 TriOsc trictrl => SinOsc sintri => dac;
15+// interpret input as frequency modulation
16+2 => sintri.sync;
17+100 => trictrl.gain;
1318
19+// array of Oscs
1420 [ s, saw, tri, pul, sqr, trictrl ] @=> Osc oscillators[];
1521
22+// set gains
1623 0.2 => s.gain;
1724 0.1 => saw.gain;
1825 0.1 => tri.gain;
1926 0.1 => pul.gain;
2027 0.1 => sqr.gain;
2128 0.1 => sintri.gain;
22−2 => sintri.sync;
23−
24−while ( true ) {
2529
30+// infinite time-loop
31+while( true )
32+{
33+ // randomize
2634 Math.random2(0,7) => int select;
27− if ( select > 5 ) 5 => select;
35+ // clamp (giving more weight to 5)
36+ if( select > 5 ) 5 => select;
37+ // generate new frequenc value
2838 Std.mtof( f[Math.random2( 0, 4 )] + 60 ) => float newnote;
39+ // set frequency
2940 newnote => oscillators[select].freq;
41+ // wait a bit
3042 0.25::second => now;
31− for ( 0 => int i; i < 10; i+1 => i ) {
32− Math.random2f (0.2, .8 ) => trictrl.width;
33− 0.05 ::second => now;
34− }
35−
43+ // 10 times
44+ repeat(10)
45+ {
46+ Math.random2f( 0.2, 0.8 ) => trictrl.width;
47+ // <<< "trictrl width:", trictrl.width() >>>;
48+ 0.05::second => now;
49+ }
3650 }

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