Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Had nearly the same idea for the exact same reasons, but wanted it to work on an iPad. Safari has no WebMIDI, so I ended up using WebAudio paired with pitch detection by consensus instead. Here's the result -

https://github.com/apankrat/note-detector

It's not without issues still, but tends to do a reasonably good job at what it aims to do.



Oh, neat! That's very nice, we were actually discussing doing this the other day using FFTs to make it work with real pianos that do not have a silent option installed.


Thanks, yours is very nice too :)

For what it's worth, the auto-correlation route is simpler and more reliable. FFT alone is not enough, because the spectrum tends to be rather ambiguous. There's still a pattern to it for every note played, so it should be possible to deduce a note with a neural net. But I just didn't have time for that, maybe later.

PS. Give my thingy a try if you have a moment. I'm curious if it actually works with any pianos other than mine.


Yes, I know about the auto correlation trick, especially on the low end of the spectrum. I wrote an MP3->midi convertor that is very fast and does not use the GPU or any kind of deep learning, it also gives results that a year ago were SOTA but in the meantime have been passed by deep learning based techniques.

I will definitely use your software. What would be great is to have a 'virtual midi device'. If it works well enough are you open to licensing it? We will sooner or later hit this problem and such a component would make our lives a lot easier, it would also allow me to practice on my real piano using the software, which if I didn't want to play the piano I'd give my left arm for.

On another note: when you know what should be played it is actually easier: you only need to output a '1' or a '0', what is played is what is expected vs what is played is not what is expected.

This may be a simpler problem to solve, and in that context it might even be able to detect chords.


Re: a virtual midi device - I don't know the specifics of WebMIDI, but I'd think it should be rather trivial to code on top of any pitch detector, including mine. In terms of licensing - the code is already BSD-2.

Re: the another note - yes, indeed. I too realized this, because mis-detected notes are usually off by a full octave.

As a side note, after going reading through various papers on the subject, it would seem that an ultimate note detector should really be based on a Const-Q spectrum analyzer feeding into an NN. Training the net, even from scratch, can be as simple as sitting in front of a piano and then repeatedly playing each note in all possible ways. Then, throw this detector in a group with waveform-based detectors, get a weighted consensus and that should, in theory, be pretty damn accurate.


I've done that, and this is roughly how magenta works, which is pretty good, on random input it has about 92.5% accuracy which I think is very impressive.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: