javascriptpitch-detection

Pitch detection - count notes


I'm using an autocorrelation algorithm to perform pitch detection on monophonic sounds (humming, whistling) and I get results good enough for what I'm attempting to do. But If I whistle a melody with the notes G F# D# and log the result I get this sequence:

2x F#
3x G
14x F#
54x G
14x G#
2x D
52x F#
6x G
14x F#
3x G
2x G
28x D#
2x D
33x D#
4x D
16x D#
2x E
2x D
2x D#

We can see that the right notes are recognized and they are the ones with more repetitions, how can I know when it´s a real note or just a transition? Is there any kind of filter that I can apply to that array and get only the real notes G F# and D#?

I'm using this javascript code: https://github.com/cwilso/pitchdetect to perform the pitch detection and I'm wondering if there's some post process algorithm that I can apply to my results to filter the notes or if I have to increase the window on the autocorrelation algorithm.

In that thread on Signal Processing (https://dsp.stackexchange.com/questions/16753/how-to-get-the-melody-from-a-signal) the accepted answer mention something like a simple post processing applying a mode filter on my result sequence of pitches. What would be this mode filter?


Solution

  • A mode filter is where you see which notes occur the most and discard the rest. e.g. if you were to do a simple mode filter and discard anything with a value less than 20 then you would get 54x G, 52x F#, 28x D#, 33x D#

    However you would have to calculate the mode value to use as it would depend on the tempo of the notes.