You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ArrayIndexOutOfBoundsException: 3 when trying to load (mp3) sound file #14
Hello, after recent updates (maybe Processing, Java or the library itself), my students and I cannot load a certain sound file which we were able to load for 2 years. Can you please take a look at the issue?
The sound file is attached
Both versions of Processing and Sound library are latest. (v3.4, v2.0.2)
I also found some relevant thread here.
Error Message below:
ArrayIndexOutOfBoundsException: 3
Oct 24, 2018 4:33:03 AM com.jsyn.engine.SynthesisEngine start
INFO: Pure Java JSyn from www.softsynth.com, rate = 44100, RT, V16.8.0 (build 463, 2017-10-16)
I'm having the same issue
ArrayIndexOutOfBoundsException: 3
When:
Attempting to load a mp3 audio file in by
happyTTS = new SoundFile(this, "3 Beep.mp3");
changed the title [-]Can't load sound files, except for the .aiff files given from the example.[/-][+]ArrayIndexOutOfBoundsException: 3 when trying to load (mp3) sound file[/+]on Nov 14, 2018
I had the same issue and tried everything I could find in these forums. Newest update did nothing.
Once I changed the files to .wav format the file worked. I still see red warnings but the game doesn't give the arrayIndexOutOfBounds error anymore.
I used Audacity to convert.
Red warning code that appears still is this (with or without .mp3 files)
I had the same problem. I started with original .wav files from my music creation software and converted them into .mp3 files using an online converter. (to try and save on file size) The converted .mp3 files would not load into by program. I tried my first .wav files and they worked. So I am guessing that some converters will generate .mp3 files that the sound library cannot handle.
I also got the exception on some mp3 files:
`java.lang.ArrayIndexOutOfBoundsException: 3
at fr.delthas.javamp3.Decoder.decodeFrame(Decoder.java:474)
at fr.delthas.javamp3.Decoder.init(Decoder.java:431)
at fr.delthas.javamp3.Sound.(Sound.java:49)
at processing.sound.SoundFile.(Unknown Source)
A VBR file fails to load: (info according to winamp) MPEG-1 Layer 3, 84 Kbps (VBR), 14 Frames, 48000 Hz Joint Stereo
The exception happens when trying to determine the frequency.
The samplingFrequency = 3 is decoded in the JavaMP3 library: https://github.com/delthas/JavaMP3/blob/master/src/main/java/fr/delthas/javamp3/Decoder.java#L466
The SAMPLING_FREQUENCY array contains 3 elements: int[] SAMPLING_FREQUENCY = {44100, 48000, 32000}
Index [1] would be 48'000, but somehow it wants to access index [3] which is out of bounds.
Maybe the InputStream should be created freshly, before trying to parse as mp3.
try {
// load WAV or AIF using JSynthis.sample = SampleLoader.loadFloatSample(fin); // <-- 'fin' will be modified after this call (4 bytes are read)
} catch (IOExceptione) {
// try parsing as mp3try {
// re-create the input stream before creating the mp3fin = parent.createInput(path);
Soundmp3 = newSound(fin);
Activity
tongdaxu commentedon Nov 1, 2018
Same issue noticed, windows 10, Processing 3.4 and latest Sound lib.
Raise:
ArrayIndexOutOfBoundsException: 3
When:
Attempting to load a mp3 audio file in by
happyTTS = new SoundFile(this, "Happy_TTS.mp3");
AST-esp-rasp commentedon Nov 9, 2018
I'm having the same issue
ArrayIndexOutOfBoundsException: 3
When:
Attempting to load a mp3 audio file in by
happyTTS = new SoundFile(this, "3 Beep.mp3");
[-]Can't load sound files, except for the .aiff files given from the example.[/-][+]ArrayIndexOutOfBoundsException: 3 when trying to load (mp3) sound file[/+]sgolanka commentedon Nov 27, 2018
Same--on both Windows and Macs (ArrayIndexOutOfBoundsException).
file = new SoundFile(this, "Kalimba.mp3");
showyourmindlab commentedon Dec 3, 2018
Having the same issue on my 2018 macbook pro with Processing 3.4 and Sound 2.02.
dinarname commentedon Dec 5, 2018
Hi!
I encountered the same problem. First there was a message about the array, then about the fact that the file could not be decoded.
I fixed this through the conversion of my files(.mp3 and .wav) into an .aiff format.
jlinseman commentedon Dec 20, 2018
Fixed
I had the same issue and tried everything I could find in these forums. Newest update did nothing.
Once I changed the files to .wav format the file worked. I still see red warnings but the game doesn't give the arrayIndexOutOfBounds error anymore.
I used Audacity to convert.
Red warning code that appears still is this (with or without .mp3 files)
But I no longer get this after it.
TotallyJuice commentedon Feb 27, 2019
I had the same problem. I started with original .wav files from my music creation software and converted them into .mp3 files using an online converter. (to try and save on file size) The converted .mp3 files would not load into by program. I tried my first .wav files and they worked. So I am guessing that some converters will generate .mp3 files that the sound library cannot handle.
cluder commentedon Mar 14, 2019
I also got the exception on some mp3 files:
`java.lang.ArrayIndexOutOfBoundsException: 3
at fr.delthas.javamp3.Decoder.decodeFrame(Decoder.java:474)
at fr.delthas.javamp3.Decoder.init(Decoder.java:431)
at fr.delthas.javamp3.Sound.(Sound.java:49)
at processing.sound.SoundFile.(Unknown Source)
A VBR file fails to load: (info according to winamp)
MPEG-1 Layer 3, 84 Kbps (VBR), 14 Frames, 48000 Hz Joint StereoThe exception happens when trying to determine the frequency.
The samplingFrequency = 3 is decoded in the JavaMP3 library:
https://github.com/delthas/JavaMP3/blob/master/src/main/java/fr/delthas/javamp3/Decoder.java#L466The SAMPLING_FREQUENCY array contains 3 elements:
int[] SAMPLING_FREQUENCY = {44100, 48000, 32000}Index [1] would be 48'000, but somehow it wants to access index [3] which is out of bounds.
The frequency is read from two bits: 0 0 = 44khz, 0 1 = 48 khz, 1 0 = 32 khz, 1 1 = ?

see http://id3lib.sourceforge.net/id3/mp3frame.html
I am currently trying to reproduce the problem directly in JavaMP3.
cluder commentedon Mar 14, 2019
The problem seems to be in the processing.sound.SoundFile class.
https://github.com/processing/processing-sound/blob/master/src/processing/sound/SoundFile.java#L59
The InputStream
finis already at position 4, when it is passed to the Sound constructor, which then leads to the wrong decoding.Sound mp3 = new Sound(fin);Maybe the InputStream should be created freshly, before trying to parse as mp3.
Mp3 file to reproduce the problem: https://github.com/cluder/processing-examples/blob/master/resources/beep1.mp3
sjernigan commentedon Jun 4, 2022
I had the same problem when trying to load mono mp3s. Changed them to stereo and they worked.