Click here to view the sketch.
I’m writing this post retroactively, because finals got the better of me and I’m just now getting to it post facto. So, I hope my account of my process and struggles is still accurate. For my physical computing final, I was making a sensor that visualizes baby kicks (my wife, Marina, is pregnant). I wanted the visualization to also include some nice audio, so it was fortuitous that we were doing sound in .p5 at the exact time that I needed to learn it.
The grey box sketch you see above is just the event-based music that would eventually become the audio track to my baby kick sensor. Some of the struggles I had with it: initially made the very basic and dumb mistake of calling oscillators in the draw loop. That was easy enough to fix once I realized it.
The other problem I ran into was a browser / computer performance issue. Even though each sound seems like it’s stopping, it’s just decreasing in volume to zero. The oscillator actually remains. If you make too many of them, the result is weird, glitchy and awful. Give it a try!