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.

Modifying notes on mouse position

Modifying notes on mouse position - JavaScript Tutorial

From the course: Code Clinic: JavaScript

Start my 1-month free trial

Modifying notes on mouse position

- [Instructor] Now we want to modify the sound that we make when we click on different positions on the screen, so in order to do that I'm going to need a few other variables. I'll start off with original Y position as well as original X position. That would be obviously the position of the mouse and then we'll store the frequency or the note that we're playing in a variable called originalFrequency, and then we're gonna need a list of frequencies. So we'll put that in a list called scaleFrequencies and that's gonna be of course an array, and it's gonna have a bunch of notes. You notice that before we've been using this note of 110 and we need to put the frequencies for all the notes that we want to play depending on the mouse position. So, because there are a bunch of numbers, I've placed these in a Gist for you. The interesting thing to note is that if you look at the numbers you'll note that there's a 110 right here, and if you go seven places to the right, the number is 220, so…

Contents