| 1 |
// Eric Heep |
| 2 |
// April 3rd, 2017 |
| 3 |
// poweradsr-feedback-beatings.ck |
| 4 |
|
| 5 |
// set number of sines and power envs |
| 6 |
5 => int num; |
| 7 |
MagicSine sin[num]; |
| 8 |
PowerADSR env[num]; |
| 9 |
|
| 10 |
// sound chain |
| 11 |
for (int i; i < num; i++) { |
| 12 |
sin[i] => env[i] => dac; |
| 13 |
sin[i].gain(0.25/num); |
| 14 |
} |
| 15 |
|
| 16 |
fun void loopSin(int idx) { |
| 17 |
dur env_time; |
| 18 |
float curve; |
| 19 |
while (true) { |
| 20 |
Math.random2(1, 2)::second => env_time; |
| 21 |
|
| 22 |
// curves below 1.0 will be "hill" shaped, |
| 23 |
// curves above 1.0 will resemble an exponential curve |
| 24 |
Math.random2f(0.5, 4.0) => curve; |
| 25 |
sin[idx].freq(Math.random2f(1000, 1100)); |
| 26 |
|
| 27 |
// set all envelope durations |
| 28 |
env[idx].set(env_time, 1::second, 0.5, env_time); |
| 29 |
|
| 30 |
// set all envelope power curves |
| 31 |
env[idx].setCurves(curve, 1.0, 1.0/curve); |
| 32 |
|
| 33 |
// begins attack phase |
| 34 |
env[idx].keyOn(); |
| 35 |
env_time => now; |
| 36 |
|
| 37 |
// begins decay phase |
| 38 |
1::second => now; |
| 39 |
|
| 40 |
// begins release phase |
| 41 |
env[idx].keyOff(); |
| 42 |
env_time => now; |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
for (int i; i < num; i++) { |
| 47 |
spork ~ loopSin(i); |
| 48 |
} |
| 49 |
|
| 50 |
while (true) { |
| 51 |
1::second => now; |
| 52 |
} |