1

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:

  1. Preprocessing of the signal (maybe Hanning window, lowpass or bandpass filtering) and/or
  2. Postprocessing of the signal (some kind of frequency smoothing).

Has someone an idea how to overcome the "choppy" results?

Ulrich Vormbrock
  • 369
  • 2
  • 13

1 Answers1

1

I used autocorrelation for my free chromatic app iTransposer and incorporated a Hanning window so this may help you. I wasn't looking for accuracy initially as I wanted to display the note on a stave not a meter. However a friend of mine tested it to 0.1 Hz with a signal generator at his work and had issues over 383 Hz with simple signals such as Sine waves.I've tried it with various brass instruments, guitar and Garageband instruments seems to be OK for tuning. Basically I implemented this http://www.ucl.ac.uk/~ucjt465/tutorials/praatpitch.html using VDSP and updated a sample project supplied by Kevin P Murphy https://github.com/kevmdev/PitchDetectorExample

  • Thank you, psybersonic - I've tried out your proposals and there are slight improvements concerning frequency stability. The paper "Pitch in Praat" helped me a lot in order to get a better understanding about pitch- or speech detection. Thank you so much! – Ulrich Vormbrock Apr 16 '15 at 22:16
  • Glad to help Ulrich. Digital Audio is not easy. If you use any of Kevin Murphy's code there is a memory leak in the audio controller. Need to add free(THIS->bufferList.mBuffers[0].mData); at the end of the recording callback. (if my memory is correct). – psybersonic Apr 17 '15 at 08:30