I'm developing an IOS app for frequency detection, and I'm using the YIN algorithm, which is very precise: witch Audacity, I've generated rectangular waves of different frequencies - and my algorithm has a precision of about 0.1 % - for example generating a tone of 82,4 Hz (E string), I really get 82,4 Hz and nothing else.
Anyhow, when I strum a guitar string, I often get overtones which sometimes can be stronger (with a higher amplitude) than the fundamental tone (F0). Consequently, my display starts "dancing" and toggling - sometimes, it even occurs that (when the tone dies out) my algorithm stops at the overtone's frequency (for example A instead of E) - so the user has to strum the string again in oder to see if his desired tone (frequency) is present.
I know that this phenomena has nothing to do with my algorithm, because it's merely a "hardware" problem (I mean the guitar which simply produces overtones).
I've tried in vain to smooth the results (of the frequency detection) or to "snap" to a fixed frequency as soon as a crucial frequency (for example 82.4 Hz for E string +/- tolerance) has been detected. Anyhow, it often occurrs that my algorithm snaps into an erroneous frequency, as well.
I'm asking myself how cheap guitar tuners (for 10$ in guitar stores) are working, as their frequency detections are reliable and stable, as well.
I don't want to change the algorithm, but two possible solutions come into my mind:
- Preprocessing of the signal (maybe Hanning window, lowpass or bandpass filtering) and/or
- Postprocessing of the signal (some kind of frequency smoothing).
Has someone an idea how to overcome the "choppy" results?