From the course: Code Clinic: JavaScript

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Playing sound with the mouse

Playing sound with the mouse - JavaScript Tutorial

From the course: Code Clinic: JavaScript

Start my 1-month free trial

Playing sound with the mouse

- [Instructor] Let's go ahead and modify our sound so that we can control it with the mouse. So for that I'm going to need a new variable here called myOscillator. And I probably should have created that before 'cause I'm using this variable here really pretty much everywhere and it doesn't really exist before that. JavaScript will automatically create it for you, but that's bad form so I'm creating one here officially. And what I also need is another variable to hold the node that's going to contain my sound. So I'll create a variable called appNode. And this will select from the document using querySelector, the item with the class of app. So it looks like that and what I wanna do next is move all of this sort of sound customizing stuff out of here, so we'll take it all out of there. And then create some events that are going to control when my sound plays. So first off I'm doing an appNode, or at least on the appNode I want to add an EventListener and the first event I want is…

Contents