This video provides an overview of my solution.
- [Narrator] Writing this solution in Clojure was an absolute blast. Let's take a quick look at the theremin instrument we're building. The program displays a white background and when I click, I'll see a colored circle where my cursor is. And I hear a musical tone. If I move up, the tone increases in pitch. And moving down, lowers the pitch. Moving left we'll decrease the volume, and moving to the right will increase it.
The color of the circle changes as the pitch changes and cycles through the rainbow for each octave of notes. For this project, I knew that I needed to find some tools that would allow me to capture events and display some graphics. I remembered that the first Clojure program I wrote was an animations of Conway's Game of Life that used a library called Quil. I chose to use Quil for this piece because I knew it could handle our needs in a very concise, approachable and malleable way that would allow me to iterate quickly.
It leverages the popular processing library, and can even run in a browser. We'll use Quil in a functional style called fun mode. For the sound component I wasn't yet familiar with a suitable tool and I did a bit of research. I considered using an advanced sound synthesis tool called Overtone. I decided this wasn't the best match for our simple requirements, for which I thought basic MIDI capabilities would be sufficient. I instead found a Java library called JFugue, JFugue has a very straightforward interface for our sound needs.
We'll divide our solution into two namespaces, core and sound. The core namespace is the entry point for our application. It will create the window, listen to events, and display graphics on a canvas, as well as triggering the sounds. The sound namespace is solely responsible with playing musical tones. In the following videos I'll begin with a conceptual overview of how Quil's fun mode works, from there we'll set up our program to use Quil, then implement the event handling and graphics routines. Next, we'll produce some sounds using JFugue.
Then at the end we'll wire everything together to finish the solution. Let's get started programming in Clojure.
Skill Level Intermediate
1. Problem 1: Exploring Lake Pend Oreille
2. Problem 2: Image Analysis
3. Problem 3: Eight Queens
4. Problem 4: Accessing Peripherals
5. Problem 5: Recursion and Directories
6. Problem 6: Building the Web
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.