Learning question: The next steps would be to take a discrete Fourier transform to help in the frequency detection, yes?
I felt like the most fiddly work would be accurately sampling the sound. E.g. not recording when it was under (or maybe over) a particular volume, ignoring the initial thud of a key (particularly with the phone sitting on the piano), and making it so that the correct 'note' stayed blue as the sound trailed off and got less reliable.