NotesLearn

I recently bought an alto saxophone. It was quite a while I haven’t seriously been playing an instrument, so I came across a little challenge when it was time to read a music sheet. You know, that thing with a pentagram and some notes of various shapes drawn over it.

Since playing a note on the saxophone is not straightforward as it would be on a piano, I actually had two separate challenges: the first was to recognize a note on the pentagram, the second was to play it well (it means play the correct note steadly for some seconds – and in tune).

So I decided to code a little app to aid me doing so. The app is pretty simple: it shows a (random) note on the pentagram, and then listens to the microphone waiting for a note, identifying the pitch and, after some seconds of playing, says if the played note was correct or not. This app has proven quite useful in the process of improving my reading accuracy and speed, and I guess it might be useful to someone else too.

It’s published here: https://dmnk.cloud/noteslearn.

Technical infos

On the technical side, it is entirely coded using Javascript, and has been a cool challenge to code since it was the first time for me interacting with the microphone data on a web app. It uses some advanced Audio features of HTML5, based on the AudioContext component. Recognizing the pitch was a minor issue, obtained by playing a bit with the FFT of the signal, some other challenges included volume thresholding and octave recognition (less trivial).

In the end, the result is pretty usable for my alto sax, even though it may be less accurate if used with other instruments I didn’t test. The piano version is not perfect, for some notes it needs to repeatedly play the key to make the app recognize it. I guess it should work best with constant-volume-notes kind of instruments, like violin or flute, but as I said it was only fully tested with my alto sax.

Google Jam of Code

This is the second year I try to have some fun with python and the Google Code Jam.

This year I almost forgot about it, and started the challenge when almost half of the time was gone. Anyway I managed to complete almost half of the problems, which seemed pretty good to me, given that I spent just a few hours trying.

Unfortunately, my last attempt timed out by 3 minutes (out of 8 available) when trying to compute the result, which later proved correct. This reminded me about the importance of performance in my code: a little optimization of the code after my try gave it a speedup of 3x, which would have been enough to submit the result in time.

Anyway, both this and the last year I qualified for the second round. Last year I didn’t pass it, this year I hope to do better.

 

googlecodejam2015