| 1 |
// name: honkeytonk-algo1.ck |
| 2 |
// desc: ALL NEW! HonkyTonk 4op FM (TX81Z Algorithm 1) |
| 3 |
// This Algorithm can also do PumpOrgn, NylonGuit, others |
| 4 |
// See nylon-guitar-algo1.ck for how to do this |
| 5 |
// |
| 6 |
// author: Perry R. Cook |
| 7 |
// date: June 2021, for REPAIRATHON 2021 |
| 8 |
// needs chuck 1.4.1.0 or above |
| 9 |
|
| 10 |
// to learn more about HnkyTonk, uncomment this: |
| 11 |
// HnkyTonk.help(); |
| 12 |
|
| 13 |
// ugens! |
| 14 |
HnkyTonk h[8]; |
| 15 |
Pan2 p[8]; |
| 16 |
Chorus c[2] => NRev r[2] => dac; |
| 17 |
// turn volume down a bit |
| 18 |
0.33 => r[0].gain => r[1].gain; |
| 19 |
0.07 => c[0].mix; |
| 20 |
0.07 => c[1].mix; |
| 21 |
0.04 => r[0].mix; |
| 22 |
0.04 => r[1].mix; |
| 23 |
|
| 24 |
for (int i; i < 8; i++) { |
| 25 |
h[i] => p[i] => c; |
| 26 |
-0.4 + 0.2*i => p[i].pan; |
| 27 |
Math.random2f(6.95,7.05) => h[i].lfoSpeed; |
| 28 |
0.04 => h[i].lfoDepth; |
| 29 |
} |
| 30 |
|
| 31 |
Std.mtof(36) => h[0].freq; |
| 32 |
Std.mtof(41) => h[1].freq; |
| 33 |
Std.mtof(53) => h[2].freq; |
| 34 |
Std.mtof(57) => h[3].freq; |
| 35 |
Std.mtof(60) => h[4].freq; |
| 36 |
|
| 37 |
[69,72,74,76,77,81] @=> int melody[]; |
| 38 |
|
| 39 |
// triplets (bass 1, bass 2, repeats) |
| 40 |
// must contain 3-multiple of elements |
| 41 |
[41, 48, 4, |
| 42 |
41, 48, 4, |
| 43 |
38, 50, 2, |
| 44 |
34, 53, 2]@=> int bass[]; |
| 45 |
|
| 46 |
// bass counter |
| 47 |
0 => int n; |
| 48 |
// drop amount |
| 49 |
0 => int drop; |
| 50 |
// start with bass line |
| 51 |
bassLine( bass[0], bass[1], 4 ); |
| 52 |
|
| 53 |
// play melody concurrently over... |
| 54 |
spork ~ doMelody(); |
| 55 |
// ... the bass line |
| 56 |
while( true ) |
| 57 |
{ |
| 58 |
// play current chord |
| 59 |
bassLine( bass[n*3] + drop, bass[n*3+1], bass[n*3+2] ); |
| 60 |
// increment counter |
| 61 |
n++; |
| 62 |
// reset drop |
| 63 |
0 => drop; |
| 64 |
// end of cycle? (if yes, start over but with a drop) |
| 65 |
if( n >= bass.size()/3 ) { 0 => n; -12 => drop; } |
| 66 |
} |
| 67 |
|
| 68 |
fun void doMelody() |
| 69 |
{ |
| 70 |
while( true ) |
| 71 |
{ |
| 72 |
Std.mtof(melody[Math.random2(0,5)]) => h[5].freq; |
| 73 |
Math.random2f(.75,1) => h[5].noteOn; |
| 74 |
if (maybe*maybe) { |
| 75 |
Std.mtof(melody[Math.random2(0,5)]) => h[6].freq; |
| 76 |
Math.random2f(.5,.75) => h[6].noteOn; |
| 77 |
} |
| 78 |
Math.random2(1,3)*second/8 => now; |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
fun void bassLine( int note1, int note2, int thisManyTimes ) |
| 83 |
{ |
| 84 |
// set thumb1 note |
| 85 |
Std.mtof(note1) => h[1].freq; |
| 86 |
// repeat |
| 87 |
repeat( thisManyTimes ) |
| 88 |
{ |
| 89 |
1 => h[1].noteOn; |
| 90 |
second/2 => now; |
| 91 |
.75 => h[2].noteOn; |
| 92 |
.75 => h[3].noteOn; |
| 93 |
.75 => h[4].noteOn; |
| 94 |
second/2 => now; |
| 95 |
if (maybe*maybe) |
| 96 |
Std.mtof(note2) => h[0].freq; |
| 97 |
else |
| 98 |
Std.mtof(note2-12) => h[0].freq; |
| 99 |
1 => h[0].noteOn; |
| 100 |
second/2 => now; |
| 101 |
.75 => h[2].noteOn; |
| 102 |
.75 => h[3].noteOn; |
| 103 |
.75 => h[4].noteOn; |
| 104 |
second/2 => now; |
| 105 |
} |
| 106 |
} |