Search code examples
audioprocessingindexoutofboundsexceptionjavasound

OutOfBoundsException in Processing (Sound library)


I recently started playing with Processing. I want to create a simple FFT visualizer that will import music file using Sound library. Here's my code and the console output.

Console Output

import processing.sound.*;
SoundFile file;

void setup()
{
    size();
    background(51);

    file = new SoundFile(this, "song.mp3");
    file.play();
}

void draw ()
{

}

Can someone explain why is this happening and how it can be fixed? By the way, sound file (song.mp3) is located in the same folder as the .pde file.


Solution

  • Put the mp3 file in a folder called data which should be located where your .pde file is located.

    This might not fix your issue though. If the issue persists, then it's the fault of the SoundFile library and there is nothing you can currently do.

    I have heard people recommending the "minim" library. Try to look into that, as continuing to use the SoundFile library will only lead to problems.