| 1 |
// name: krstlchr.ck |
| 2 |
// desc: KrystlChr (Krystal Choir) 4-Op FM Demo (TX81Z Algorithm 7) |
| 3 |
// |
| 4 |
// author: Perry R. Cook |
| 5 |
// date: June 2021, for REPAIRATHON 2021 |
| 6 |
// needs chuck 1.4.1.0 or above |
| 7 |
|
| 8 |
// array of krystal choir instruments |
| 9 |
KrstlChr c[7]; |
| 10 |
// to learn more about KrstlChr, uncomment this: |
| 11 |
// KrstlChr.help(); |
| 12 |
|
| 13 |
Pan2 p[7]; |
| 14 |
NRev r[2] => dac; |
| 15 |
// connect up |
| 16 |
for (int i; i < 7; i++) { |
| 17 |
c[i] => p[i] => r; |
| 18 |
-1.0 + 0.333*i => p[i].pan; |
| 19 |
Math.random2f(2.5,4.0) => c[i].lfoSpeed; // different modulations |
| 20 |
} |
| 21 |
|
| 22 |
// turn down the volum... for safety |
| 23 |
0.12 => r[0].gain => r[1].gain; |
| 24 |
|
| 25 |
[48, 55, 60, 65, 72, 79, 81] @=> int chord1[]; |
| 26 |
[46, 56, 63, 67, 70, 82, 89] @=> int chord2[]; |
| 27 |
|
| 28 |
<<< "Play some nice open chords...", "" >>>; |
| 29 |
rollChord(chord1); second => now; |
| 30 |
allOff(); second => now; |
| 31 |
rollChord(chord2); second => now; |
| 32 |
allOff(); second => now; |
| 33 |
Std.mtof(50) => c[3].freq; |
| 34 |
1 => c[3].noteOn; second => now; |
| 35 |
|
| 36 |
<<< "Then loop on random open circle of 4ths notes...", "" >>>; |
| 37 |
while( true ) |
| 38 |
{ |
| 39 |
Math.random2(0,6) => int which; |
| 40 |
c[which].noteOff; |
| 41 |
Math.random2(0,6) => which; |
| 42 |
Math.random2(0,10)*5 => int space; |
| 43 |
Std.mtof(38+space) => c[which].freq; |
| 44 |
if (maybe) |
| 45 |
1 => c[which].noteOff; |
| 46 |
else |
| 47 |
1 => c[which].noteOn; |
| 48 |
second => now; |
| 49 |
} |
| 50 |
|
| 51 |
fun void rollChord( int chord[] ) |
| 52 |
{ |
| 53 |
for( int i; i < 7; i++ ) |
| 54 |
{ |
| 55 |
Std.mtof(chord[i]) => c[i].freq; |
| 56 |
1 => c[i].noteOn; |
| 57 |
Math.random2f(0.1,0.3)::second => now; |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
fun void allOff() |
| 62 |
{ |
| 63 |
for (int i; i < 7; i++) 1 => c[i].noteOff; |
| 64 |
} |