Error when playing SoundFile

I have a p5js application which loads and plays a sound file. It was worked fine for a very long time, but suddenly it’s started throwing errors when I try to play the file.

I’ve stripped the code down to its basics, as well as trying it with different sound files, formats, browsers etc, but it breaks in all of them.

As soon as I call audioStream.play() I get the following error:

Uncaught TypeError: Cannot read property 'length' of undefined
    at RingBuffer.push (a95166f8-a660-483a-99b5-aafd118d4566:75)
    at AudioWorkletProcessor.process (a95166f8-a660-483a-99b5-aafd118d4566:170)

I’m speculating, due to the undefined error, that something may be trying to access the audio stream before it is fully instantiated, but after it’s loaded.

The error happens outside the flow of my program, I’m guessing in a timeout or something, so I can’t debug it from a point in my code. However, If I use:

console.log('play');
audioStream.play();
console.log('playing');

Then the error occurs between the two log statements, so it’s something that’s triggered by calling play() on the p5 SoundFile object.

Here is my code, stripped down as much as possible, which replicates the problem:


const audioFile = '../audio/Track.wav';
let audioStream;
let playing = false;

window.setup = () => {
  createCanvas(640, 480);
  background(0,128,0)
  audioStream = loadSound(audioFile, function () {
    console.log('loaded', audioFile);
  });
  console.log('loading', audioFile);
};

window.draw = () => {
  if (!playing && audioStream.isLoaded()) {
    playing = true;
    console.log('play');
    audioStream.play();
    console.log('playing');
  }
};

I too am at a loss for what’s going on. This code was working great for the last week and all of a sudden started receiving this error as well.

I’ve changed versions of p5/p5Sound and still no luck.

It’s happening cross browser as well and can’t even trace the stack properly.

I’ll post more if I find anything else.

audioTrack.currentTime(); always seems to be returning 0 for me now(Add that to the list of strange things that just started happening).

Thanks @Brewhog! Sorry to hear that you have this problem too, but very glad to learn that I am not alone. I thought this must be something I’d screwed up in my environment, but if it suddenly stopped working for you as well then it sounds like something broke elsewhere.

There is a problem with the library. Upon further investigation, this error is occurring on the p5js.org site examples as well. Go here to see what I’m talking about:
https://p5js.org/reference/#/p5.EQ

Click the ‘lows’ button and open the developer console. The same RingBuffer.push() error is thrown.

Not sure how to report a bug, or confirm if this bug already exists.

Thanks for confirming. God, I spent hours pulling my code apart trying to figure out what I’d broken :rofl:

I’m very very interested to know what it could be that has broken everyhing like this, without requiring an update of the p5js or p5 sound library themselves or, as far as I’m aware, any dependencies.

Know if there is any way of escalating this? Do the folks who contribute to p5 sound hang out on here? I’ve got a video to make for a DJ and the deadline is creeping closer. I would be glad to try and figure it out myself and submit a fix, but I think this one is beyond my abilities.

Thanks. I’ll submit something shortly.

I’m going to try this on an older version of a browser and of the library. If it works fine, you might want to use that for your DJ.

If they’re willing to work with a slightly older browser, it might just work.

BTW, the portable firefox developer edition (v80) appears to work for me. However, there are still errors thrown.

Most important part is that all features seem to be functional (Although noisy with the errors).

https://portableapps.com/downloading/?a=FirefoxPortableDeveloper&n=Mozilla%20Firefox%20Developer%20Edition,%20Portable&s=s&p=&d=pa&f=FirefoxPortableDeveloper_80.0_Beta_1_English.paf.exe

1 Like

Another link to grab Firefox Developer Beta: :fox_face:

Yeah, swapping browsers is no problem. Let me know if you find a workaround.

Added two bugs to the P5 Sound project GitHub project:

Is there a hotfix around for the RingBuffer.push() bug, or at least a way to stop the error from going into the console?