File: envelope2.ck

package info (click to toggle)
chuck 1.5.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 40,904 kB
  • sloc: cpp: 120,943; ansic: 35,893; javascript: 2,111; yacc: 609; makefile: 456; python: 174; perl: 86
file content (38 lines) | stat: -rw-r--r-- 919 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
// name: envelope2.ck
// desc: real-time segmented envelope generation
// requires: 1.5.2.5 or higher

// no sound in this example; only printing
Step s(1) => Envelope e => blackhole;

// spork printing shred
spork ~ print();

// infinite time-loop
while( true )
{
    // next duration to target
    Math.random2f(500,1000)::ms => dur duration;
    // next target
    Math.random2f(.1, 10) => float target;
    // print duration and target
    <<< "duration:", duration/second, "target:", target >>>;

    // over a duration, ramp to target
    e.ramp( duration, target ) => now;
}

// print function
fun void print()
{
    // infinite time loop
    while( true )
    {
        // print value of e
        // NOTE: this is only a rough print-out and
        // will not necessary print the target values
        // but values approaching towards the targets
        <<< e.last(), "" >>>;
        50::ms => now;
    }
}