| 1 |
// Listing 8.6 Jazz band: |
| 2 |
// save as "bass.ck" |
| 3 |
|
| 4 |
// sound chain (mandolin for bass) |
| 5 |
Mandolin bass => NRev r => dac; // (1) Mandolin bass player through reverb. |
| 6 |
|
| 7 |
// parameter setup |
| 8 |
0.1 => r.mix; |
| 9 |
0.0 => bass.stringDamping; // (2) Makes strings ring a long time. |
| 10 |
0.02 => bass.stringDetune; // (3) Gives it a really big bass-sized body. |
| 11 |
0.05 => bass.bodySize; |
| 12 |
.5 => bass.gain; |
| 13 |
|
| 14 |
// jazz scale data // (4) Scale array for walking bass line. |
| 15 |
[41,43,45,48,50,51,53,60,63] @=> int scale[]; |
| 16 |
4 => int walkPos; // (5) Pointer for position within scale. |
| 17 |
|
| 18 |
// loop |
| 19 |
while( true ) // (6) Walks forever. |
| 20 |
{ |
| 21 |
Math.random2(-1,1) +=> walkPos; // (7) Adds 1 or -1 or 0 to scale position. |
| 22 |
if (walkPos < 0) 1 => walkPos; // (8) Makes sure position doesn't go outside the array... |
| 23 |
if (walkPos >= scale.cap()) scale.cap()-2 => walkPos; // (9) ...on the top end too. |
| 24 |
Std.mtof(scale[walkPos]-12) => bass.freq; // (10) Sets pitch from scale note. |
| 25 |
Math.random2f(0.05,0.5) => bass.pluckPos; // (11) Random plucking position. |
| 26 |
1 => bass.noteOn; |
| 27 |
0.55 :: second => now; |
| 28 |
1 => bass.noteOff; |
| 29 |
0.05 :: second => now; |
| 30 |
} |