My take on the classic JavaScript Drum Kit. Just vanilla JS, not with a frontend framework like is suggested for the Build a Drum Machine project for the Front End Libraries certificate.
I found a tutorial and watched the demo of how it is supposed to work, then without watching any of the coding part of the tutorial I tried coding it on my own. By “my own” means in many cases, for what I thought I wanted to accomplish, looking at the documentation for different things or in some cases googling “how do I do this”.
Without looking at others’ code for similar projects, I’m sure it’s not the most elegant solution but I think I got it working the way that it’s supposed to. I also added functionality for touch/click events that I didn’t see demonstrated in the demo. I’m pretty satisfied I got it to where it is in just a few hours and hope I can do things like this in less time as I practice more.
However, for some reason sounds don’t always play when expected, either a delay or not at all.
Edit: Went back and watched the rest of the tutorial. Turns out there was a simple fix for some of the audio issues. added sound.currentTime=0
to stop a current instance of the playing sound when a new event is triggered.