4 ms·
I've been playing around with single tone detection using the Minsky circle algorithm. Without roundoff, they are equivalent, but Minsky tolerates roundoff bett
by kragen 7y ago
I've been playing around with single tone detection using the Minsky circle algorithm. Without roundoff, they are equivalent, but Minsky tolerates roundoff better, especially at low frequencies — you can think of Goertzel as representing the phase or quadrature information as the difference s[n] - s[n-1], which obviously gets less bits allocated to it than the s[i] themselves, particularly near the peaks and at low frequencies.
Precisely, you can derive Minsky’s algorithm (modified for frequency detection by adding the input samples into the register you produce the output from) from applying Goertzel’s algorithm to the first backward differences of the input signal.
The derivation is in Dercuano in notes/goertzel-minsky-prefix-sums.html. The latest, and probably the penultimate, version of Dercuano is at http://canonical.org/~kragen/dercuano-20191215.tar.gz http://canonical.org/~kragen/dercuano-20191215.tar.gz.
There are some tricks in there for windowing the computation over different timescales, too.
- kragen 7y agoI've published the final version of Dercuano at http://canonical.org/~kragen/dercuano-20191230.tar.gz http://canonical.org/~kragen/dercuano-20191230.tar.gz. I also hacked together an inferior PDF version for reading on hand computers at http://canonical.org/~kragen/dercuano.20191230.pdf http://canonical.org/~kragen/dercuano.20191230.pdf. The Goertzel derivation is pp. 2769–2770.
- jacquesm 7y agoInteresting, thank you, I will look into that. The problem I'm working on requires something that will work well in the presence of chords and even though I've made really good progress I'm still about 4% away from SOTA, but 100's of times faster. Not quite ready to give up. edit: found a HN discussion on that: https://news.ycombinator.com/item?id=15266331 https://news.ycombinator.com/item?id=15266331
- kragen 7y agoAnything linear should work well in the presence of chords, I would think? (Although maybe PLLs would work better, depending on what you're doing, despite being nonlinear.) The HN discussion has some good information, but it also has some mathematical errors. Presumably you don't mean the School of the Arts or Summits on the Air (though both involve detecting frequencies), so what is SOTA?
- rjeli 7y agoState of the art
- jacquesm 7y agoPLL is an interesting option, never thought of that, that is worth pursuing, thank you. And like the other comment already wrote, state of the art. The project is automatic music transcription, the 'gold standard' that I've found so far is Magenta based 'Onsets and Frames' (https://magenta.tensorflow.org/onsets-frames https://magenta.tensorflow.org/onsets-frames ), which scores pretty good on a large benchmark. I'm still a ways away from being their score but there is real chance that it will happen. The tensorflow based software is super slow, many orders of magnitude slower than realtime would require and I have a bunch of applications in mind where slower than realtime is not an option. Here are the two side-by-side across the same testset (first mine): // di 24 dec 2019 16:49:29 CET overall total 17482 correct 12604 fp(fantasized) 2723 fn(missed) 4878 f_measure 76.833 precision 82.234 recall 72.097 accuracy 62.381 vs (Magenta O&F): // wo 25 dec 2019 20:09:51 CET overall total 17482 correct 13865 fp(fantasized) 2908 fn(missed) 3617 f_measure 80.952 precision 82.663 recall 79.31 accuracy 67.999 Clearly the O&F software has the edge in detection but it is close enough that I have some hope of beating that score, I'm already way ahead of what they list as the 'previous state of the art'.
- kragen 7y agoCongratulations! So you're equal in precision but still suffer on recall? Anything in common among the notes your system misses? My friend Alastair Porter recently did his dissertation on tune identification, so he told me a bit about the transcription problem. It's hairy! I think PLLs make sense when you have chirps, like vibrato or portamento. Not sure they'll help in other cases. For piano they can only hurt, I imagine.
- jacquesm 7y ago> Congratulations! Thank you. There ought to be something to show for working this hard between jobs since August... It's been a very long slog. > So you're equal in precision but still suffer on recall? That's about the gist of it. But I suspect that if I fix the recall I'll end up being down on precision again, that's roughly how this has been going so far. Two steps forward, one step back. > Anything in common among the notes your system misses? Restrikes are really hard, as are octaves. They are conceptually super simple but when you get all the combinations thrown at you it stops being simple in a hurry. I'm reasonably optimistic about the restrikes, less so about the octaves, especially when the lower note is the louder one (power chords, for instance). > My friend Alastair Porter recently did his dissertation on tune identification, so he told me a bit about the transcription problem. It's hairy! No kidding. Tune identification is usually done on the binary encoding of the melody (up or equal = 1, down = 0) so I can see why transcription would come in handy there. > I think PLLs make sense when you have chirps, like vibrato or portamento. Not sure they'll help in other cases. For piano they can only hurt, I imagine. They might be useful in verification of notes already generated.
- jcims 7y agoIs FFT a problem because of the compute requirements or the latency? (or something else)
- jacquesm 7y agoWell, it is not so much a problem as it is a solution, FFTs are a very important part of what I've built. But the low end is very hard to do precise using FFTs (because the bin size is large compared to the difference between individual notes), for that I use autocorrelation, and for the verification step I would like to use something else than FFTs to get a 'second opinion' on the notes detected.
- jcims 7y agoSounds like a very cool project, hope we hear about it when its ready.