Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My approach on the Drum Kit : day 1 #691

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dumbprism
Copy link

INTRODUCTION

Well setting up the drum kit was quite easy. I had created a set of buttons that consisted the specific sound effect names so that users can guide through and work on it easily.

THE MAIN IMPLEMENTATION

When it came to implementing and getting the desired sound, i tackled the approach in a different way. Frankly, I did not refer to the video since I wanted to give it my own shot and if I get stuck of course there is the video solution to help me figure out.

Coming to the point, the first thing to tackle was to generate the music. The sound effect. To do that, I used the normal Audio constructor that is a pretty handy tool by JavaScript that lets you play music.

Well, that's how I began. The next task was on how to generate these sound effects. For that, I have used buttons that have the text based on the sound effect they produce so that it would be easy for the users to navigate and also get an idea on what is the sound effect. So for each button I inserted the text value as the name of the sound effect and I applied a "for each loop". Also I used a document.querySelectorAll('button') functionality giving it a variable notes so that I can access my for each loop. Pretty conveniently I used the for each loop that iterates over each of the buttons and if the button.taextContent == "sound-effect" Then that particular sound effect would be played. Now similarly this must happen When I press keys on my keyboard. I used a keypress event listener and if val.key == 'sound-effect-key' then it would play that particular sound effect. Well this was my approach and I got pretty much things done in an easier way, rather than beauti-fying all the stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants