# TypeError: arraySequence\[0\] is undefined

**URL:** <https://discourse.processing.org/t/typeerror-arraysequence-0-is-undefined/22005>\
**Category:** Libraries\
**Created:** [June 19, 2020, 6:55pm UTC](https://discourse.processing.org/t/typeerror-arraysequence-0-is-undefined/22005 "2020-06-19T18:55:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![antocreo](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@antocreo](https://discourse.processing.org/u/antocreo)\
**Post date:** [June 19, 2020, 6:55pm UTC](https://discourse.processing.org/t/typeerror-arraysequence-0-is-undefined/22005/1 "2020-06-19T18:55:06Z")

</div>

Hi all,  
I am getting this error since Firefox update to 77.0.1

`TypeError: arraySequence[0] is undefined`

 ![Screen Shot 2020-06-19 at 19.51.34](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/6/6c09e4e9d5e641c55e90e80b2932a30d747d6c27.png)

I think it might related to the p5-sound library as it’s the only place where I’ve found arraySequence[0].  
I’ve looked around and tried to figure it out but can’t find anything.  
The web app is actually working ok, so I am not sure what the error is about and if it might be related to other things.

Anyone with the same issue or with any info on this?

Cheers 🙂 🌻

---

<div class="post-metadata">

**Author:** ![slow\_izzm](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/slow_izzm/32/5637_2.png) [@slow\_izzm](https://discourse.processing.org/u/slow_izzm)\
**Post date:** [June 19, 2020, 9:41pm UTC](https://discourse.processing.org/t/typeerror-arraysequence-0-is-undefined/22005/2 "2020-06-19T21:41:47Z")

</div>

Can you post your code? It’s impossible to help/debug without it.

---

<div class="post-metadata">

**Author:** ![antocreo](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@antocreo](https://discourse.processing.org/u/antocreo)\
**Post date:** [June 21, 2020, 11:44pm UTC](https://discourse.processing.org/t/typeerror-arraysequence-0-is-undefined/22005/3 "2020-06-21T23:44:37Z")

</div>

Hi @slow_izzm, thanks for replying.  
I didn’t post the code because it’s too long and I wouldn’t know which part is relevant to be honest. I’ve extracted the code relative to the audio part ([here](https://discourse.processing.org/t/p5js-sound-and-safari/20880/3)) and it works fine, no errors in the console. However, the only `arraySequence[0]` available in my scripts is in the ps5-sound library, I think it relates to the buffer ([here](https://github.com/processing/p5.js-sound/pull/376/files/d423aecf614618de21ef6c172cb95e6ba5c99eef)). So it should be that, crashing with some other thing in the code, no idea what.  
The app works just fine a part from this error in the console which exists only in Firefox.  
I was just wondering if anyone encountered a similar problem or had a hint to what I could look at to start debugging. It’s more about curiosity at this point.

cheers

---

<div class="post-metadata">

**Author:** ![siJ2ZeL1qI1wA](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sij2zel1qi1wa/32/9811_2.png) [@siJ2ZeL1qI1wA](https://discourse.processing.org/u/siJ2ZeL1qI1wA)\
**Post date:** [July 2, 2020, 3:13pm UTC](https://discourse.processing.org/t/typeerror-arraysequence-0-is-undefined/22005/4 "2020-07-02T15:13:55Z")

</div>

I am getting the same error with Firefox 77 and 78, but not 75 (on Linux if that matters). In my case I can easily reproduce it already with the sample code in [https://p5js.org/reference/#/p5.Amplitude](https://p5js.org/reference/#/p5.Amplitude), and in fact it breaks the functionality of that example: while a sound plays after clicking the canvas, the size of the ellipse does not change at all. @antocreo can you check if you also see that behaviour? I will keep you posted if I figure out where the problem lies.

---

<div class="post-metadata">

**Author:** ![antocreo](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@antocreo](https://discourse.processing.org/u/antocreo)\
**Post date:** [July 2, 2020, 3:28pm UTC](https://discourse.processing.org/t/typeerror-arraysequence-0-is-undefined/22005/5 "2020-07-02T15:28:11Z")

</div>

@siJ2ZeL1qI1wA yes, I do. In my Firefox I don’t actually see the ellipse, I guess it stays at radius 0.  
Sounds works fine but no ellipse. Same error. Thanks for spotting that out.

---

<div class="post-metadata">

**Author:** ![slow\_izzm](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/slow_izzm/32/5637_2.png) [@slow\_izzm](https://discourse.processing.org/u/slow_izzm)\
**Post date:** [July 2, 2020, 5:50pm UTC](https://discourse.processing.org/t/typeerror-arraysequence-0-is-undefined/22005/6 "2020-07-02T17:50:51Z")

</div>

> [@antocreo](#):
>
> I’ve extracted the code relative to the audio part ([here](https://discourse.processing.org/t/p5js-sound-and-safari/20880/3))

I checked this out, I didn’t have the audio so I pointed to some archived sounds and everything worked just fine … never threw an error.

I did notice a couple of things … one being your eventListener `onended()` being registered every time you invoke `playMusic()` … this only needs to be registered once (unless you deregister and need to register again), so I would move it into`setup()`

```auto
const tracks = [],
  sng_src = ['https://ia800702.us.archive.org/6/items/cd_tee-vee-toons-the-commercials_various-artists-ajax-cleanser-ajax-laundry/disc1/01.%20Kellogg%27s%20Rice%20Krispies%20-%20Snap%2C%20Crackle%2C%20Pop%20%5BKellogg%27s%20Rice%20Krispies%5D_sample.mp3',
    'https://ia800702.us.archive.org/6/items/cd_tee-vee-toons-the-commercials_various-artists-ajax-cleanser-ajax-laundry/disc1/02.%20Chiquita%20Bananas%20-%20I%27m%20A%20Chiquita%20Banana_sample.mp3'
  ];

let trackCounter = 0,
  page = 'click';

function preload() {
  for (let i = 0; i < sng_src.length; i++) {
    tracks.push(createAudio(sng_src[i]));
  }
}

function setup() {
  createCanvas(512, 512);

  noStroke();
  textSize(50);
  textAlign(CENTER, CENTER);

  shuffle(tracks, true);
  for (let t of tracks) t.onended(playNext);
}

function draw() {
  background(255);
  checkPageState();

}

const checkPageState = _ => {
  switch (page) {

    case 'click':
      text(page, width / 2, 50);
      fill(0);
      ellipse(width / 2, 200, 100, 100);
      break;

    case 'track':
      text(page + " " + trackCounter, width / 2, 50);
      fill(0, 255, 120);
      ellipse(width / 2, 200, 100, 100);

      break;
  }
}

function playMusic() {
  tracks[trackCounter].play();
}

function playNext() {
  tracks[trackCounter = (trackCounter + 1) % tracks.length].play();
}

function mouseReleased() {

  switch (page) {

    case 'click':
      playMusic();
      page = 'track';
      break;

    case 'track':
      tracks[trackCounter].stop();
      playNext();

      break;
  }
}

```

---

<div class="post-metadata">

**Author:** ![ffd8](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ffd8/32/815_2.png) [@ffd8](https://discourse.processing.org/u/ffd8)\
**Post date:** [July 2, 2020, 9:27pm UTC](https://discourse.processing.org/t/typeerror-arraysequence-0-is-undefined/22005/7 "2020-07-02T21:27:12Z")

</div>

Just ran into this issue as well while testing Firefox (no problem in Chrome or Safari) and have potentially isolated it to the `getLevel()` function, specifically in the latest p5.sound version 0.3.12 (the [editor.p5js.org](http://editor.p5js.org) links a CDN of version 0.3.11, which doesn’t have this issue).

[Here’s an example](https://editor.p5js.org/ffd8/sketches/zny-NR1Z5) to test in various browsers. The equalizer at the bottom works in all, but a `getlevel()` reactive ellipse doesn’t appear in Firefox (with size of 0). You can toggle the two p5.sound versions to compare within `index.html`

Just [opened an issue](https://github.com/processing/p5.js-sound/issues/499) to track fixing of it.

---

<div class="post-metadata">

**Author:** ![antocreo](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@antocreo](https://discourse.processing.org/u/antocreo)\
**Post date:** [July 3, 2020, 9:42am UTC](https://discourse.processing.org/t/typeerror-arraysequence-0-is-undefined/22005/8 "2020-07-03T09:42:36Z")

</div>

Hi @slow_izzm, thanks for spotting that. That code is actually extracted (quickly) from a larger one and in the final one I do need to access that function multiple times, but you are right, in that code it works better your way 🙂  
The thing is that even with the error, my app works just fine. or so it seems. I am more curious about this error rather than actually wanting to sort it out.
