| 1 |
// Listing 4.3 Playing a sound file backward |
| 2 |
|
| 3 |
// Playing sounds in reverse |
| 4 |
// by ChucK Programmer 4102, yluJ (reverse date!) |
| 5 |
SndBuf mySound => dac; |
| 6 |
|
| 7 |
// (1) Assembles file path/name and read file into SndBuf. |
| 8 |
me.dir()+"/audio/hihat_04.wav" => mySound.read; |
| 9 |
|
| 10 |
// (2) Asks the sound how long it is (in samples). |
| 11 |
mySound.samples() => int numSamples; |
| 12 |
|
| 13 |
// play sound once forward |
| 14 |
0 => mySound.pos; |
| 15 |
numSamples :: samp => now; // (3) Lets it play for that long. |
| 16 |
|
| 17 |
// and once backward |
| 18 |
numSamples => mySound.pos; // (4) Sets position to end of buffer. |
| 19 |
-1.0 => mySound.rate; // (5) Sets it to play backward |
| 20 |
numSamples :: samp => now; // Play for whole duration, but backward. |
| 21 |
|