This should be really simple. I want to play a sound a fixed number of times (once, twice, or thrice).
I tried this below. Here I copied the same sound and pretend that Quack1 and Quack2 are different sounds so I can play the same sound twice. It doesn’t work.
I also tried checking if the sound is playing before rewinding and then playing it again. But I can’t believe there is a very little digital cassette tape embedded in the file that I need to rewind.
Is there a simple way to play the same sound n times? It’s very useful when some time-consuming code is running and you want to know when it has finished.
import processing.sound.*;
SoundFile file1;
SoundFile file2;
void setup() {
// Load a soundfile from the /data folder of the sketch and play it back
file1 = new SoundFile(this, "Quack1.aiff");
file2 = new SoundFile(this, "Quack2.aiff");
file1.play();
file2.play();
//file.loop();
}
void draw() {
}
//https://processing.org/reference/libraries/sound/SoundFile.html