Day 33: How to make music with ClojureScript
I am working on a small project to practice change ringing with ClojureScript.
As always when starting a new project I have been consulting approximately a million resources to get started. So I thought I’d collect them all together in one place instead of searching for them over and over forever.
Getting started with ClojureScript
- Empty ClojureScript project, with instructions, from Mary
- CLJSFiddle, for trying out ClojureScript snippets
- Explanation of cljs/js interop, from Zach
Web Audio
There’s a newish API for synthesizing sound in the browser called the WebAudio API.
- Some demos
- Very cool player piano app by Liam Griffiths, a Hacker Schooler in my batch. You will have to run it on your computer but it will be worth it.
- Hum, a small ClojureScript wrapper around the WebAudio API. If you want to test if it works in your browser, try this CLJSFiddle. It should make an annoying noise when you run it..
Sound samples
If you don’t want to synthesize music, there are tons of samples on freesound.org
- Freesound API documentation
- Get a Freesound API key. It says “Apply”, but it gives it to you automatically.
- freesound.js, a JS library for working with freesound
- IDs for a set of piano samples, from the Overtone project.
- JSFiddle demoing the Freesound API.
Scroll to the bottom to see the actual code; I copied all of
freesound.js
into it. It should make a piano sound when you run it.