IndexOutOfBoundsException

Hello, i copied a very simple code from the website,https://processing.org/reference/libraries/sound/SoundFile.html but turns out the problem:IndexOutOfBoundsException
.I’ve checked that the file is in the data folder. I really do not know why, can somebody help? Thx

  
import processing.sound.*;
SoundFile file;

void setup() {
  size(640, 360);
  background(255);
    
  // Load a soundfile from the /data folder of the sketch and play it back
  file = new SoundFile(this, "sample.mp3");
  file.play();
}      

void draw() {
}

I tried your code and it works on my machine, P3.5.3 and Win 10 OS.

I suggest you try another mp3 file. In addition, if the file were not in the data folder, it will give you a NPE error and not an IndexOutOfBoundsException error.

Kf

1 Like

Possibly relevant:

1 Like