I’ve thought about making an analogue polyfill for the Web MIDI API using pitch detection of the Web Audio API, ideally polyphonic. But it’s a fair way down my long list of things I’d love to do but will probably never make the time to do.
That the black notes aren’t centred is something I was reminded of when making an SVG keyboard myself a few years back. It’s rather important to comfortable playing.
If I was to carry on with it, I would look into using byteFrequencyData rather than timeDomainData. My initial attempts with the frequency data weren't great, but a few people have mentioned it so I'd take another look and see if I just wasn't doing something dumb.
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.
That the black notes aren’t centred is something I was reminded of when making an SVG keyboard myself a few years back. It’s rather important to comfortable playing.