We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi I'm trying to make a musical keyboard with p5.sound and I'm running into trouble. I have some divs that make up the keyboard inside of a larger div called "keyboard". Each key div has an id corresponding to its note.
In the javascript file I add functionality for clicking each div and also playing keys on the keyboard.
Initially I had one octave and that was working reasonably well. When I added more divs for the second octave I started having notes playing when I didn't want them to. As soon as I load up the page, I get unwanted notes playing.
In my setup() function, I iterate over every div in "keyboard" and create a p5.Env object, set the ADSR, set the range, create a p5.Oscillator object, then set the amp to the envelop I created. Then I start the wave. And I keep track of each env in a global variable that maps div id to the env itself. So I can trigger attack and trigger release of each envelope in event listener functions like onmousedown etc.
Some potential problems are I have a function called keyPressed that might be mirroring a p5.js function. Also I have all of my event listener functions defined inside of setup().
Any idea what the problem is? Is there a better way to set this up?
I really appreciate any advice I can get, Thanks