Menu

Why a plain FFT tuner locks onto the wrong note, and what I used instead (McLeod Pitch Method on iOS)
📰

Why a plain FFT tuner locks onto the wrong note, and what I used instead (McLeod Pitch Method on iOS)

DEV Community: ios·Nova Lumen Labs·about 23 hours ago
#nCupH7Tg
#devtoios#devto#dev#tuner#metronome
Reading 0:00
15s threshold

I'm a solo developer at a small studio, and I recently shipped a guitar tuner and metronome called Maestro. The tuner was the part I got wrong first, so this post is about that.

The naive approach fails on real instruments

The obvious way to build a tuner: take a window of microphone samples, run an FFT, pick the tallest peak, convert to a note. It works on a sine wave. On a real guitar it doesn't, because the loudest bin is often the 2nd or 3rd harmonic, not the fundamental. A low E (about 82 Hz) will happily read as the E an octave up, or as a B, depending on the pluck.

What I used: the McLeod Pitch Method (MPM)

MPM computes a normalized square-difference autocorrelation of the window. Instead of looking for the biggest peak in frequency space, it looks for repeating structure in time, and normalizes by signal energy at each lag so quiet tails don't lose to loud attacks.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.