# IndexOutOfBoundsException

**URL:** https://discourse.processing.org/t/indexoutofboundsexception/12499
**Category:** Libraries
**Created:** [July 4, 2019, 2:50pm UTC](https://discourse.processing.org/t/indexoutofboundsexception/12499 "2019-07-04T14:50:34Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![bu.aus](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bu.aus](https://discourse.processing.org/u/bu.aus)
#### Post date: [July 4, 2019, 2:50pm UTC](https://discourse.processing.org/t/indexoutofboundsexception/12499/1 "2019-07-04T14:50:34Z")

</div>

Hello, i copied a very simple code from the website,[https://processing.org/reference/libraries/sound/SoundFile.html](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

```auto
  
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() {
}

```

---

<div class="post-metadata">

### Author: ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)
#### Post date: [July 4, 2019, 4:28pm UTC](https://discourse.processing.org/t/indexoutofboundsexception/12499/2 "2019-07-04T16:28:26Z")

</div>

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

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [July 6, 2019, 12:13pm UTC](https://discourse.processing.org/t/indexoutofboundsexception/12499/3 "2019-07-06T12:13:24Z")

</div>

Possibly relevant:

> <https://github.com/processing/processing-sound/issues/11>

---

<div class="post-metadata">

### Author: ![JRussellHuffman](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@JRussellHuffman](https://discourse.processing.org/u/JRussellHuffman)
#### Post date: [November 9, 2021, 1:19am UTC](https://discourse.processing.org/t/indexoutofboundsexception/12499/4 "2021-11-09T01:19:43Z")

</div>

I had the same issue. According to the Processing Sound Library github [readme](https://github.com/processing/processing-sound) “Some MP3 files with meta-information (especially where large amounts of data such as the album cover image is stored in the ID3 header) fail to load (see [#32](https://github.com/processing/processing-sound/issues/32))”.

In short, nothing is wrong with the code. It’s the audio file.
