From the course: Code Clinic: Clojure

Unlock the full course today

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

Integrating sound

Integrating sound - Clojure Tutorial

From the course: Code Clinic: Clojure

Start my 1-month free trial

Integrating sound

- [Instructor] In this video, we'll complete the solution by wiring in the sound. First, in the core dot clj file, I'll add a require for the sound module that we just wrote. Hold this in as theremin dot sound and alias it as sound. Next, I'll scroll down to the draw state function. Inside of the let bindings, we'll set the pitch and volume for our sound. First, I'll set our pitch. I'm gonna multiply our normalized y value by 12, because there are 12 notes chromatically in an octave, and then I'll multiply by six because I want to have six octaves of range. Our midi pitch needs to be an integer and this expression will return a decimal number. So I'll wrap this in a cast to int. Lastly, this will start our pitch at zero which is a bit too low to hear. So I'm gonna add 24 to our value to increase it by two octaves. Next, I'll set our volume. This will also need to be an integer. And I'll multiply our normalized x value by the maximum amplitude, which is 16,383. With these values…

Contents