| 1 |
// CurveTable: flexible Curve/Line Segment table generator |
| 2 |
|
| 3 |
// make one |
| 4 |
CurveTable c; |
| 5 |
|
| 6 |
// coeffs are all FLOATS, specifying proportional times, values, and curvature: |
| 7 |
// [time0, value0, curvature to next, time1, value1, curvature,.. |
| 8 |
// timeN-1, valueN-1, curvaturen-1, timeN, valueN] |
| 9 |
|
| 10 |
// times => ascending unitless values (NOT Chuck Time values) |
| 11 |
// values => whatever |
| 12 |
// curvature(0) => linear |
| 13 |
// curvature(<0) => convex |
| 14 |
// curvature(>0) => concave |
| 15 |
|
| 16 |
// see: |
| 17 |
// http://www.music.columbia.edu/cmc/Rtcmix/docs/scorefile/maketable.html#curve |
| 18 |
// for more documentation |
| 19 |
|
| 20 |
// set |
| 21 |
[0., 0., -0.5, 1., 1., 0.5, 2., -1.] => c.coefs; |
| 22 |
|
| 23 |
// create an envelope to scan through the table values |
| 24 |
Envelope e => blackhole; |
| 25 |
e.duration(10000::ms); |
| 26 |
0. => e.value; |
| 27 |
e.keyOn(); //ramp to 1 in 10 seconds |
| 28 |
|
| 29 |
// patch |
| 30 |
Phasor p => c => dac; |
| 31 |
// set |
| 32 |
440. => p.freq; |
| 33 |
|
| 34 |
// ready |
| 35 |
while (true) |
| 36 |
{ |
| 37 |
// print |
| 38 |
<<< e.value(), c.lookup(e.value()) >>>; |
| 39 |
|
| 40 |
// end |
| 41 |
if(e.value() == 1.) break; |
| 42 |
|
| 43 |
// advance time |
| 44 |
10::ms => now; |
| 45 |
} |