| 1 |
// name: envelope2.ck |
| 2 |
// desc: real-time segmented envelope generation |
| 3 |
// requires: 1.5.2.5 or higher |
| 4 |
|
| 5 |
// no sound in this example; only printing |
| 6 |
Step s(1) => Envelope e => blackhole; |
| 7 |
|
| 8 |
// spork printing shred |
| 9 |
spork ~ print(); |
| 10 |
|
| 11 |
// infinite time-loop |
| 12 |
while( true ) |
| 13 |
{ |
| 14 |
// next duration to target |
| 15 |
Math.random2f(500,1000)::ms => dur duration; |
| 16 |
// next target |
| 17 |
Math.random2f(.1, 10) => float target; |
| 18 |
// print duration and target |
| 19 |
<<< "duration:", duration/second, "target:", target >>>; |
| 20 |
|
| 21 |
// over a duration, ramp to target |
| 22 |
e.ramp( duration, target ) => now; |
| 23 |
} |
| 24 |
|
| 25 |
// print function |
| 26 |
fun void print() |
| 27 |
{ |
| 28 |
// infinite time loop |
| 29 |
while( true ) |
| 30 |
{ |
| 31 |
// print value of e |
| 32 |
// NOTE: this is only a rough print-out and |
| 33 |
// will not necessary print the target values |
| 34 |
// but values approaching towards the targets |
| 35 |
<<< e.last(), "" >>>; |
| 36 |
50::ms => now; |
| 37 |
} |
| 38 |
} |