p5.js-sound
p5.js-sound copied to clipboard
Error in 1.1.9 Using p5.Amplitude with p5.AudioIn
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.
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