File: foo2.ck

package info (click to toggle)
chuck 1.5.5.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 41,056 kB
  • sloc: cpp: 123,473; ansic: 35,893; javascript: 2,111; yacc: 609; makefile: 457; python: 174; perl: 86
file content (38 lines) | stat: -rw-r--r-- 643 bytes parent folder | download | duplicates (3)
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
// bandlimited ugens (Blit, BlitSaw, BlitSquare)
Blit s => Pan2 p;
p.left => JCRev r1 => dac.left;
p.right => JCRev r2 => dac.right;

// initial settings
.5 => s.gain;
.1 => r1.mix;
.1 => r2.mix;

// an array
[ 0, 2, 4, 7, 9, 11 ] @=> int hi[];

// set the harmonic
4 => s.harmonics;

// spork the pan control
spork ~ dopan();

// infinite time loop
while( true )
{
    Std.mtof( 33 + Math.random2(0,3) * 12 +
        hi[Math.random2(0,hi.size()-1)] ) => s.freq;
    120::ms => now;
}

// pan control
fun void dopan()
{
    float t;
    while( true )
    {
        .7 * Math.sin(t) => p.pan;
        .005 +=> t;
        10::ms => now;
    }
}