This week we focused on video and sound. The video/imaging processing component is through DOM library and then there is a separate library for sound. I wanted to combine both of them to make a synth that you control with your webcam. I know the sounds are choppy and awful sounding. Once I closed more tabs and tested the sounds individually it sounded like a normal sine wave, so I think my computer/Chrome was struggling to handle all of the code.
Here's a video of it in action below & you can play with it on my website here.
I basically started with a very similar sketch as the one that Dan Shiffman made in the "Checkbox Mirror" video. And then I wanted to create an active area that would cause sounds to play when the pixels (instead of checkboxes) were activated. In lines 60-77 you can see where I've created code to select the active pixels (making them red) and then playing different tones based on the pixel's horizontal position within the active area. I used a pentatonic scale, hoping it would sound nice no matter what was played, and divided the canvas into 6 sections kind of like a piano.
Now that I am writing this, I think the oscillator sounds are playing so poorly because if every pixel in a section is activated they will all play at once, even if it is the same tone. I think I'll need to debug it more & talk to someone else, but now I'm thinking I'll need to use boolean values to activate a section instead of doing it pixel by pixel.
My full code is below.