p5.js-sound icon indicating copy to clipboard operation
p5.js-sound copied to clipboard

Error in 1.1.9 Using p5.Amplitude with p5.AudioIn

Open lisajamhoury opened this issue 5 years ago • 1 comments

I'm using p5.js and p5.sound.js @1.1.9. I am using p5.Amplitude without a problem. When I add a new p5.AudioIn to the sketch to use the microphone I get the following two errors in the console:

Uncaught TypeError: Cannot read property 'length' of undefined
    at RingBuffer.push (1d018b22-0c01-4c60-b19d-efc7640501a6:75)
    at AudioWorkletProcessor.process (1d018b22-0c01-4c60-b19d-efc7640501a6:170)

push | @ | 1d018b22-0c01-4c60-b19d-efc7640501a6:75
-- | -- | --
  | process | @ | 1d018b22-0c01-4c60-b19d-efc7640501a6:170
Uncaught TypeError: Cannot read property 'length' of undefined
    at RingBuffer.push (b75c9056-6fcf-45b9-b4b6-d3f89cfea3e2:75)
    at AudioWorkletProcessor.process (b75c9056-6fcf-45b9-b4b6-d3f89cfea3e2:193)

push | @ | b75c9056-6fcf-45b9-b4b6-d3f89cfea3e2:75
-- | -- | --
  | process | @ | b75c9056-6fcf-45b9-b4b6-d3f89cfea3e2:193

You can see the error in this p5 sketch. It works without a problem with 0.9.0. If you update the library in the index to 1.1.9 you will see the error in the console.

lisajamhoury avatar Nov 05 '20 19:11 lisajamhoury

Although I didn't get any error what I found out is p5.Amplitude doesn't work as expected if the mic(p5.AudioIn) is running. For that either stop the mic while listening to other sources/soundfiles or use max(amp.getLevel(),mic.getLevel()) . The first one is the logical way , second one is just a workaround

Ajaya1000 avatar Apr 14 '21 20:04 Ajaya1000