Out of tune
Audio to MIDI on a recording that is not at A=440: the notes flip at ±50 cents, not at ±100.
A melody recorded a little sharp or flat usually comes back transposed as a whole, which one transpose fixes. But between roughly 44 and 56 cents of drift the six notes of a single melody stop flipping together, and then no single transpose can put them back.
The selected audio is decoded in your browser; it is not uploaded to a server.
The converter assigns each note a MIDI number by rounding: round(69 + 12 × log₂(f / 440)). Rounding a continuous number to the nearest integer means the decision point sits half a semitone, 50 cents, away from the correct pitch — in theory. Measured on six notes spanning A3 to F4, the actual decision points land between 43.4 and 55.5 cents below and between 44.5 and 56.3 cents above. That is a 12-cent spread, and it is wide enough to leave a band where the notes of one melody disagree with each other.
Everything below comes from one melody, one detector, and one variable — the whole file multiplied by 2^(cents/1200). Nothing else was changed: same note lengths, same gaps, same five-partial timbre, same 44.1 kHz mono, same peak level.
Measured, not assumed
Each note has its own flip point, and they are not the same point.
A six-note melody — A3, B3, C4, D4, E4, F4, each 0.30 s with 0.10 s of silence after it, five partials, peak normalised to 0.5 — reads as 57, 59, 60, 62, 64, 65 at dead centre. That is the published baseline, and it reproduced before any other number here was taken. Then the entire melody was retuned by a fixed number of cents and converted again, and each note was tracked until it moved to a different MIDI number:
| Note | Baseline | Flips flat at | Flips sharp at |
|---|---|---|---|
| A3 | 57 | −51.2 cents | +51.2 cents |
| B3 | 59 | −55.5 | +49.6 |
| C4 | 60 | −50.0 | +44.5 |
| D4 | 62 | −49.2 | +54.3 |
| E4 | 64 | −47.3 | +56.3 |
| F4 | 65 | −43.4 | +52.3 |
Conditions: 44,100 Hz mono, six notes at 0.30 s with 0.10 s silence between them, five harmonics with 1/h amplitudes, 5 ms attack, exponential decay, peak normalised to 0.5 (−6.0 dBFS), sensitivity Balanced. Detector read directly from the live converter.js (8,069 bytes, sha256 77a9dd6b9f15af65), 1,024-sample frame, 256-sample hop, lag search 31–512 samples. Boundaries found by bisection to 0.5 cents. Script run-tuning.js, log tuning-2026-11-19.txt.
Read the two boundary columns as a range rather than six numbers. The flat side runs from −43.4 to −55.5, a 12.1-cent spread. The sharp side runs from +44.5 to +56.3, a spread of 11.8 cents. Both straddle the theoretical 50-cent line, which is the part that matters: a melody cannot be treated as if it had one flip point, because it does not.
The band
Between those points there is a band where a single transpose stops working.
Three outcomes are possible at any given amount of detuning. All six notes can stay correct. All six can move together by the same interval — one transpose then puts them back exactly. Or some can move while others do not, and that third case is the one worth knowing about, because it is not repairable by transposing.
Scanning the whole range one cent at a time and testing every transpose from −3 to +3 semitones against the original six pitches gives the unrepairable stretches directly:
| Timbral recipe | Unrepairable, flat side | Unrepairable, sharp side | Total width |
|---|---|---|---|
| 1 harmonic (pure sine) | −70 to −46 cents | +33 to +54 cents | 47 cents |
| 5 harmonics | −55 to −44 cents | +45 to +56 cents | 24 cents |
| 8 harmonics | −52 to −44 cents | +49 to +56 cents | 17 cents |
The pure sine is the widest case at 47 cents, which is nearly half a semitone of detuning where the output cannot be rescued by transposing. Richer timbres narrow it to 17–24 cents but do not close it. A synthesiser patch with a single partial, a flute recorded close, or a pitch-corrected vocal can sit in a different band from a piano or a guitar playing the same note, so the width itself is a property of the recording rather than a constant of the tool.
What happens inside the band is visible note by note. At −50 cents the melody returns 57, 59, 60, 61, 63, 64 against a baseline of 57, 59, 60, 62, 64, 65: the first three notes and the fourth hold, while D4 and E4 each drop a semitone. Shift the whole file up one semitone and the five that were already correct become wrong. Nothing in the output marks which notes came from the band and which did not.
Sensitivity does not touch any of it. At −55, −50, −45, +45, +50 and +55 cents the three settings of Fewer notes, Balanced and More notes returned identical pitch sequences, because the threshold only decides whether a frame is loud enough to analyse and how long a run has to last — not which integer the rounding lands on.
Real cases
Most real detuning is safe; the two that are not are ordinary.
The four reference pitches people actually encounter sit outside the band, and both baroque tunings come back as a clean whole-file transposition:
| Reference pitch | Offset from A=440 | Notes returned | Error per note |
|---|---|---|---|
| A=442 | +7.9 cents | 57, 59, 60, 62, 64, 65 | none |
| A=432 | −31.8 cents | 57, 59, 60, 62, 64, 65 | none |
| A=415 (baroque) | −101.3 cents | 56, 58, 59, 61, 63, 64 | −1 semitone, all six |
| A=392 (French baroque) | −200.0 cents | 55, 57, 58, 60, 62, 63 | −2 semitones, all six |
That is the good news, and it is worth stating plainly because it contradicts the usual worry: an orchestra tuned to 442, a period-instrument recording at 415, a tape that runs a hair fast — none of these produce scattered errors. They produce one consistent interval, which you remove with one transpose in the editor.
The ordinary cases that do break are the ones near 3%. Playback speed is the common cause: a tape machine calibrated for a different mains frequency, a transfer done at the wrong speed, a sampler and a DAW that disagree about the sample rate, a video whose audio was resampled by a rounder. At ×0.97 the file is 52.7 cents flat and at ×1.03 it is 51.2 cents sharp — both inside the measured band:
| Playback speed | Offset | Notes returned | Repairable? |
|---|---|---|---|
| ×0.94 | −107.1 cents | 56, 58, 59, 61, 63, 64 | yes, +1 semitone |
| ×0.95 | −88.8 cents | 56, 58, 59, 61, 63, 64 | yes, +1 semitone |
| ×0.96 | −70.7 cents | 56, 58, 59, 61, 63, 64 | yes, +1 semitone |
| ×0.97 | −52.7 cents | 56, 59, 59, 61, 63, 64 | no |
| ×0.98 – ×1.02 | −35.0 to +34.3 | 57, 59, 60, 62, 64, 65 | already correct |
| ×1.03 | +51.2 cents | 57, 60, 61, 62, 64, 65 | no |
| ×1.04 | +67.9 cents | 58, 60, 61, 63, 65, 66 | yes, −1 semitone |
| ×1.05 | +84.5 cents | 58, 60, 61, 63, 65, 66 | yes, −1 semitone |
| ×1.06 | +100.9 cents | 58, 60, 61, 63, 65, 66 | yes, −1 semitone |
Note what the two bad rows look like. At ×1.03 the returned pitches are 57, 60, 61, 62, 64, 65 — that is almost the correct melody, with B3 and C4 pushed up a semitone and the rest intact. It does not look broken. It looks like a transcription with two wrong notes, which is exactly the kind of result people blame on the detector's accuracy rather than on the file's speed. The wrong-note page covers the other causes of a scattered semitone error; this one has a single cause you can check before converting.
Mechanism
The pitch cannot be more precise than one lag, and one lag is about 17 cents wide up here.
The detector never computes a frequency. For each frame it compares the waveform against itself at every whole-sample offset from 31 to 512 and keeps the offset with the highest correlation. That offset is an integer, so the pitch it represents is one of a finite ladder of values rather than a continuum.
At A4 the true period is 100.23 samples, and the ladder step from 100 to 99 is about 17 cents. Dumping the winning lag for a single sustained A4 across the range shows the ladder directly:
| Tuning offset | Winning lag | Lag as a frequency | Note returned |
|---|---|---|---|
| −65 cents | 104 samples | 424.04 Hz | 68 |
| −59 cents | 103 | 428.16 Hz | 69 |
| 0 cents | 100 | 441.00 Hz | 69 |
| +47 cents | 98 | 450.00 Hz | 69 |
| +48 cents | 97 | 454.64 Hz | 70 |
Two things follow. First, the note changes when the winning lag changes, not when the true pitch crosses 50 cents. Second, a single sustained A4 does not flip symmetrically: bisection puts its flat flip at 60.5 cents and its sharp flip at 47.7 cents, a difference of nearly 13 cents on either side of the same note. The sharp side lands where the arithmetic says it should — the true period at +47.7 cents is 97.53 samples, which is exactly the halfway point between lag 98 and lag 97, and the dump shows 98 at +47 cents and 97 at +48. The flat side does not: the lag already reads 104 by −60 cents, but the returned note is still 69 until −60.5, because the note's pitch is the median of all its frames rather than the value of any one frame. Rounding on the ladder and averaging across the note are two separate steps, and the asymmetry is what happens where they disagree.
The ladder is also coarser at high pitches than at low ones — one step is 8.7 cents at A3, 10.3 at C4 and 13.8 at F4 — so the same detuning is judged with different resolution depending on which note is playing. That is the order of magnitude of the spread in the first table, though it does not explain the whole of it: C4 flips sharp earliest at +44.5 while F4, the coarsest note, holds until +52.3.
Timbre moves the boundary as well, and further than the ladder alone would suggest. For a single A4 the flat flip point is −73.4 cents with one harmonic, −60.9 with three, −58.2 with eight and −57.4 with twelve, while the sharp side barely moves at all between +47.3 and +47.7. Adding partials makes the waveform repeat more sharply, so a slightly wrong lag correlates worse and loses sooner on the flat side; the sharp side is already pinned by the ladder. This is why the unrepairable band in the previous section narrows as harmonics are added but never disappears.
The lag values above are read from the same integer search the shipped code runs, dumped on the steady middle frame of a 0.6 s tone so that attack and decay cannot be confused with the tuning change. The note numbers in the last column are what the full converter returns for that tone after the median-of-frames step, which is why −65 cents reads 68 while its midpoint lag alone would read 69.
What to do
Check the pitch before you convert, not after.
The practical order is short. Tune or speed-correct the file first, convert second, and only then start fixing notes.
Find the actual reference pitch. Hold one sustained note from the recording against a tuner. A reading between A=438 and A=442 is inside the safe zone and needs nothing. A reading of A=415 or A=392 means the whole file will come back a semitone or a whole tone low, consistently, and one transpose in the editor fixes it with no per-note work.
Treat a reading near A=424 or A=466 as the warning sign. Those are the two sides of the measured band on this melody, 60 cents flat and 47 cents sharp of A=440. If a tuner puts your recording there, do not convert and repair — resample or retune the file to A=440 first, so that the detector sees the pitch it is going to round against. That is the only route that avoids the scattered case entirely.
Do not trust a two-note spot check. At −50 cents two of the six notes were still correct, which is exactly enough to look convincing. Comparing the first two notes of the output against the score would have passed a file that was already inside the band.
If the file is a straight playback-speed error rather than a tuning choice, correcting the speed is better than correcting the pitch, because it fixes the tempo at the same time. A ×1.03 file is 51 cents sharp and also 3% short in duration, and the exported MIDI carries a fixed 120 BPM grid that will place every note relative to a tempo the recording never had — the tempo measurement covers that side of the same problem.
For material that is genuinely between the two, such as a period-instrument recording at an unusual pitch, the honest answer is that one pass will not do it. Convert, listen for the notes that sit a semitone off their neighbours, and fix those by hand — they are the ones the band produced, and their number is bounded by how far into the band the file sits, not by how long the file is.
Limits
The limits of this test.
One melody, six notes, one register. A3 to F4 is where the ladder is 8.7 to 13.8 cents per step. Below A3 the steps get finer and the flip points should move closer to 50 cents; above F4 they get coarser and the band should widen. Nothing here measures the octave above or the bass register, and the numbers must not be extended to them.
Every input is synthetic and perfectly steady. Five partials at 1/h with a 5 ms attack and a smooth decay, retuned by multiplying every frequency by one exact factor. A real instrument drifts within a note, and a singer is rarely steady to a cent; a note that wanders across a flip point mid-way would produce two events instead of one, which is a different failure from the one measured here. The 50 ms note and the 30 ms note are not tested at all, and a short note may fall below the minimum duration before the pitch question even arises.
The detuning is uniform. Every note is multiplied by the same factor. Real out-of-tune playing is not uniform — one string of a guitar is flat while the others are not, and a piano is stretched across its range by design. In that case the per-note flip points in the first table are still the right tool, but you have to apply them per note rather than per file, and this test does not establish how far a single note can drift before it flips on its own.
44.1 kHz only. The lag ladder is defined in samples, so the ladder shifts with the sample rate: at 48 kHz the same pitch sits on a different set of integers and the flip points move with it. The direction of that shift was not measured here, and the sample-rate page covers what does move at 48 kHz, separately.
Notes do not overlap. This is a monophonic melody with silence between the notes. A chord has its own rule for which pitch survives, which is arithmetic on the interval rather than rounding on the tuning — see chords for that case.
Reproduction: node run-tuning.js regenerates every number on this page from the live converter, and node run-tuning.js --fixture also writes the −100-cent test file used for the browser check. The detector version is printed in the first line of the output, so a page quoting these numbers can always be checked against the build it was measured on.
Questions
Tuning and this converter
My recording is a little flat. Will the whole MIDI file come out a semitone low?
Usually yes, and that is the easy case. At A=415 the six notes all came back exactly one semitone low, and at A=392 exactly two semitones low, so one transpose restores them. The hard case is a smaller offset: between roughly 44 and 56 cents of drift the notes stop agreeing with each other and a single transpose cannot fix them.
Why does the note change at 50 cents and not at 100?
The converter rounds the pitch to the nearest MIDI number, and MIDI numbers are a semitone apart, so the nearest one changes at the half-way point — 50 cents. The measured flip points sit between 43.4 and 56.3 cents instead of exactly at 50 because the pitch itself is estimated from a whole-sample period, which cannot represent every frequency exactly.
Can I just transpose the MIDI afterwards?
Only if every note moved by the same amount. In the unrepairable band some notes move and others do not — at −50 cents the melody came back 57, 59, 60, 61, 63, 64 against a baseline of 57, 59, 60, 62, 64, 65, so D4 and E4 are a semitone low and the rest are correct. No single transpose fixes that.
Does changing the sensitivity setting help?
No. At −55, −50, −45, +45, +50 and +55 cents, Fewer notes, Balanced and More notes returned identical pitch sequences. The setting controls the loudness gate and the minimum note length; the pitch decision is separate and happens by rounding.
What is the fastest way to tell whether a file is safe?
Put a tuner on one sustained note before converting. Between A=438 and A=442 nothing needs doing. A=415 or A=392 will come back as a clean whole-file transposition. A reading near 424 Hz or 466 Hz is inside the measured band — retune or resample the file to A=440 first rather than repairing the MIDI afterwards.