# Processing Sound library, multiple plays, some annoying playing, noises, bad quality

**URL:** https://discourse.processing.org/t/processing-sound-library-multiple-plays-some-annoying-playing-noises-bad-quality/15589
**Category:** Libraries
**Created:** [November 17, 2019, 5:31pm UTC](https://discourse.processing.org/t/processing-sound-library-multiple-plays-some-annoying-playing-noises-bad-quality/15589 "2019-11-17T17:31:53Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![GeorgeJava](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/georgejava/32/7646_2.png) [@GeorgeJava](https://discourse.processing.org/u/GeorgeJava)
#### Post date: [November 17, 2019, 5:31pm UTC](https://discourse.processing.org/t/processing-sound-library-multiple-plays-some-annoying-playing-noises-bad-quality/15589/1 "2019-11-17T17:31:53Z")

</div>

Hello, i try to make some shooter game, and when i was clicking the mouse, the sound gets lags and some noisy, can you help me ? Try it yourself, why it is doing that ? I try to stop afrer if(!audio.isPlaying()) … end its the same… its doesnt matter… why ?

```auto

import processing.sound.*;
SoundFile someSoundEffect;

void setup() {
  size(800, 800);

  someSoundEffect = new SoundFile(this, "http://soundbible.com/mp3/40_smith_wesson_single-mike-koenig.mp3");

  // Lets play this sound effect multiple times, doesnt matter if its on the one time or with delays etc.
  for (int i = 0; i < 350; i++) {
    someSoundEffect.play();
    delay(50);
  }
}

void draw() {
  // Wait some time
  delay(1000);
  // play again, and you can hear, the audio going very bad...
  someSoundEffect.play();
}

```

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [November 17, 2019, 10:09pm UTC](https://discourse.processing.org/t/processing-sound-library-multiple-plays-some-annoying-playing-noises-bad-quality/15589/2 "2019-11-17T22:09:15Z")

</div>

with some reasonable settings and a very short sound file  
it works here ( win 10 64b // processing 3.5.3 ) fine  
( also using updated sound lib )

```auto
import processing.sound.*;
SoundFile snd;

void setup() {
  size(800, 800);
  snd = new SoundFile(this, "data/blip.mp3");
  for (int i = 0; i < 20; i++) {
    snd.play();
    delay(500);
  }
  println("setup end");
}

void draw() {
  delay(1000);
  snd.play();
}

```

anything shorter ( your 50msec are 20 songs per second )  
would need OS to run multiple player instances ( like same time ) as with

- start program
- file load
- play file ( even if short one )
- and close file
- shutdown player

computer (OS) needs longer as 50 msec ( for one blip )

and ( for windows ) it can’t do it without a hicks.

this timing problem MUST happen if you try to run “faster”  
( more often ) as a

```auto
snd.loop();

```

( in setup with an empty draw ) works. did you test that ?

* * *

summary: don’t do it!
