A pitch for pitchy

I have been using a paid phone app that shall remain nameless for practicing outlining jazz chords on guitar. The app gives you the chords from a standard one at a time, and you play the intervals; the app marks each note completed as they are detected through the microphone. It works pretty well, but one thing I don’t like about it is that there are not that many built-in charts, and I really want to use it on the tunes I’m learning. The add-your-own-chords feature has been a todo list item since forever and I don’t see any new versions coming out, so I spent a weekend writing a clone in javascript.

I set out some silly requirements for this: 1) no build step and no libraries, because I don’t want to build my javascript, just vi on the server and go like the old days — or maybe cutting-edge “buildless” like the kids are doing these days; 2) host the entire thing in a single file (a bad idea honestly but I’m already committed to it); 3) let me just plop any old chord changes into a string variable, cutting-and-pasting them directly from lilypond source for the standard; 4) learn a little about signal processing and web audio.

It turns out that (single note) pitch detection is not so hard — I took more than a bit of inspiration from this medium post and accompanying demo code. For this application and with a good audio interface, you do not need to be spot on the frequency, just within the range of the target note (any octave will do).

Here it is, you can try it out yourself (the changes are for Scrapple from the Apple):