# Play sound a number of times

**URL:** <https://discourse.processing.org/t/play-sound-a-number-of-times/20433>\
**Category:** Libraries\
**Created:** [May 3, 2020, 1:51pm UTC](https://discourse.processing.org/t/play-sound-a-number-of-times/20433 "2020-05-03T13:51:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulstgeorge](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@paulstgeorge](https://discourse.processing.org/u/paulstgeorge)\
**Post date:** [May 3, 2020, 1:51pm UTC](https://discourse.processing.org/t/play-sound-a-number-of-times/20433/1 "2020-05-03T13:51:45Z")

</div>

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.

```auto
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

```
