Skip to content

How the tuner works

HeyTuner records nothing and guesses nothing: it cleans the raw microphone signal, finds the note with two independent methods, measures the cents with a third, and shows a reading only when they agree.

The short version

Every reading passes through the same chain:

  1. Capture the raw microphone signal, with the browser’s voice-call processing switched off.
  2. Move the audio off the main page thread so the display stays smooth.
  3. Filter out offsets, rumble and, on guitar, high-frequency hiss.
  4. Wait for a real note, then skip the noisy first moment of the pluck.
  5. Analyze a window long enough to hold at least seven cycles of the lowest note.
  6. Find the note with one method and cross-check it with a second.
  7. Measure the exact pitch with a third, more precise method.
  8. Show the reading only if the two measurements agree, then steady it for display.

The rest of this page explains each step and why it is there.

Capturing the real sound

Browsers apply three kinds of processing to microphone audio by default: echo cancellation, noise suppression and automatic gain control. They are built for video calls, and all three get in the way of tuning. Noise suppression is designed to remove steady sounds, and a sustained string is a steady sound, so it can fade your note out. Automatic gain control keeps changing the volume while the note rings. Echo cancellation removes parts of the signal it thinks are coming from your speakers.

HeyTuner switches all three off and works with the signal exactly as the microphone delivers it. You can pick a different input in the device picker, such as a USB audio interface or a line input for an electric guitar or bass, and the level meter shows what the tuner is hearing. The audio is analyzed on your device as it arrives and is never recorded or uploaded.

Keeping the page smooth

Pitch detection takes a lot of arithmetic, and doing it on the same thread that draws the page would make the needle stutter, especially on older phones. So the work is split up:

Cleaning the signal

Before any pitch analysis, the worker cleans the audio in three ways.

Waiting for a real note

A tuner that analyzed everything would spend most of its time measuring room noise. HeyTuner uses a noise gate that tracks the background level of the room as it changes, its noise floor, and only analyzes sound that rises clearly above it. Because the floor adapts, the same setting works in a quiet bedroom and a noisy rehearsal space. The sensitivity slider moves the threshold if your instrument is very quiet or the room is very loud.

When a note does arrive, the first 60 milliseconds are skipped. A pluck starts with a burst of noise from the pick or finger, and for a moment the string rings slightly sharp, because the large initial vibration stretches it. Measuring after the attack gives the pitch the string actually settles at.

Why low notes need longer windows

To measure a pitch, the tuner looks at a short stretch of audio, the analysis window, and works out how often the wave repeats. With only one or two cycles in view, a tiny error in finding where each cycle starts becomes a large error in pitch. With several cycles, those errors average out and the repetition is unmistakable.

HeyTuner sizes every window to hold at least seven periods of the lowest note in the tuning. Low notes have long periods, so they need long windows. At 48 kHz:

Lower tunings get longer windows by the same rule. The cost of a long window is a slower first reading, so the window follows the instrument and tuning instead of being set to the worst case everywhere. New audio arrives every hop, so the window slides forward continuously and the reading keeps updating while the string rings.

Finding the note: two methods that check each other

The first question is which note you are playing. The engine answers it with the McLeod Pitch Method (MPM), which compares the signal with delayed copies of itself. When the delay equals one period of the note, the copy lines up with the original and the match peaks. MPM then picks the first strong peak rather than simply the highest one, which keeps it from jumping to a multiple of the true period.

The classic failure of any pitch detector is the octave error. A strong second harmonic can make a note read an octave high, and a waveform that almost repeats over two periods can make it read an octave low. On a tuner, an octave error sends you to the wrong note entirely. So MPM’s answer is cross-checked with YIN, a related method with a different way of judging the match. The two have different weak spots, so a slip in one shows up as a disagreement with the other.

Measuring the cents: phase and harmonics

Knowing the note is not enough. The display needs the pitch to a fraction of a cent. For that, the engine uses a third method based on phase.

It breaks each window into its frequency components and finds the strongest of the string’s first three harmonics. It then compares that harmonic’s phase, where it is in its cycle, at two moments one hop apart. The amount the phase has advanced shows the harmonic’s frequency much more precisely than the frequency analysis alone could. This technique is the core of what audio engineers call a phase vocoder.

The engine uses the strongest of the first three harmonics, not always the fundamental, because the fundamental is often not the strongest. Phone microphones and small laptop microphones pick up the lowest notes weakly, and on a bass the second or third harmonic is often louder and cleaner than the fundamental.

Inharmonicity

On an ideal, perfectly flexible string, the harmonics would sit at exact multiples of the fundamental: two times, three times and so on. Real strings are stiff, particularly thick wound strings, and stiffness makes each harmonic slightly sharper than its exact multiple. The higher the harmonic, the bigger the deviation. This is inharmonicity.

If a tuner measured the third harmonic and simply divided by three, it would read the string slightly sharp, and you would tune it slightly flat to compensate. HeyTuner corrects the measured harmonic for inharmonicity before working out the fundamental, so the reading matches the pitch of the string itself, whichever harmonic was used.

Agreement or nothing

The coarse method (MPM checked by YIN) and the fine method (phase) work in completely different ways. When the string is ringing cleanly, they agree. When something is wrong, such as two strings ringing at once, a chord, a fading note or a loud room, they disagree.

HeyTuner shows a reading only when the coarse and fine pitch agree within 5 cents. Otherwise the display says “Listening…”.

That is a deliberate choice. A tuner that always shows something will sometimes show the wrong thing with full confidence, and you will turn the peg the wrong way. A blank display for a moment costs you nothing. If you see “Listening…” for long, pluck again a little more firmly, mute the other strings, or move the microphone closer.

Steadying the display

Even good readings vary slightly from one window to the next. Before anything reaches the screen:

A string counts as in tune when the reading holds within ±2 cents for 300 milliseconds. You can change that window to ±1, ±3 or ±5 cents.

From pitch to cents

The final number is the distance from the target note, in cents:

cents = 1200 × log2(measured ÷ target)

The target comes from the note you are tuning to and the A4 setting. A cent is a hundredth of a semitone, and cents measure ratios, so a reading of 3 cents flat means the same on a bass’s low B as on a guitar’s high E. The frequency chart explains how A4 sets every target.

How it is tested

A release ships only after it passes the accuracy tests. The release tests require readings within 0.1 cent on clean test tones and within 0.5 cent (95th percentile) on recorded plucked strings. The Accuracy Lab publishes the test method and the results, so you can see exactly what was measured and how.

Frequently asked questions

Does HeyTuner record or upload my audio?

No. All analysis runs on your device, inside the browser. The audio is processed as it arrives and is never stored or sent anywhere.

Why does the tuner sometimes say "Listening…" instead of showing a note?

It shows a reading only when two separate measurements agree within 5 cents. When they don't, because of room noise, two strings ringing at once or a note fading out, it waits instead of guessing.

Why is the tuner slower to respond on a 5-string bass?

A low B vibrates slowly, so the tuner has to listen to a longer stretch of sound to measure it reliably. The analysis window for that string spans about a third of a second, four times as long as for a guitar in standard tuning.

Does a phone microphone work for tuning a bass?

Usually, yes. Phone microphones pick up the lowest fundamentals weakly, so the tuner measures the strongest of the first three harmonics and corrects for the string's stiffness. Check your input with the mic test if readings are unsteady.

How accurate is HeyTuner?

The release tests require readings within 0.1 cent on clean test tones and within 0.5 cent (95th percentile) on recorded plucked strings. The Accuracy Lab publishes the test method and results.

Related