Weird out of bounds issue with the sound library

i’m working on a game and i want to add sound effects so i installed the sound library but every time i try to load a sound it returns “ArrayIndexOutOfBoundsExeption: -1” and i don’t understand why. the sound file is in the right place and the library is installed correctly (because if that wasn’t true i’m sure i would’ve gotten a different error) i’m just really confused.

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, "sound.wav");
  file.play();
}      

void draw() {
}

(this demo code wont even work)

Please try the minim library. The current sound lib is going through a revamp. Minim works as advertised.

Kf

2 Likes

@ducco it seems like your default sound card does not have any output channels, maybe try manually selecting the appropriate sound card using the new outputDevice() method: https://www.processing.org/reference/libraries/sound/Sound_outputDevice_.html

The ArrayIndexOutOfBoundsExeption sure isn’t very helpful, I’ll add a more meaningful one as soon as possible, thanks for reporting!

This issue has now been fixed and the new 2.0.1 update of the Sound library should become available from the Content Manager at some point during the day. @ducco it would be very helpful if you could let me know if the update fixes your problem!

1 Like

i just used minim sorry for not responding @kevinstadler