Stutter and lag when playing multiple samples repeatedly · Issue #74 · processing/processing-sound (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@trackme518

Description

@trackme518

When using SoundFile class and triggering samples repeatedly it will start to stutter eventually. This is not happening in another audio library - Beads. Also reported here: https://discourse.processing.org/t/sound-library-bugs-lagging-noise-choppy/4718 Example code below:

import processing.sound.*;

int timer;
SoundFile[] file = new SoundFile[5];

void setup() {
  size(640, 480);
  background(0);
  for (int i=0; i<file.length; i++) {
    file[i] = new SoundFile(this, "http://soundbible.com/grab.php?id=1705&type=wav" );
  }
  timer = millis();

  frameRate(30);
}


int numplays = 0;

void draw() {
  //around 800-1100 plays it will start to stutter
  if (numplays<1000) {
    if (millis() > timer + 20 ) {
      int i = (int)random(0, file.length);
      file[i].play();
      numplays++;
      println(numplays);
      timer = millis();
    }
  }
}