Audio to MIDI

Audio to MIDI octave errors: the overtones decide, not the pitch.

An octave-wrong export is usually explained as a weak or missing fundamental — the note was too low, the speaker was too small, the take needed a high-pass. That explanation does not survive measurement. Cutting the fundamental to one four-hundredth of the second harmonic still returned the correct pitch at A2, A3 and A4. What actually flips the octave is the shape of the harmonic series: one 220.00 Hz tone read MIDI 57 or MIDI 69, an exact octave apart, with the fundamental present and unmoved in both.

Select a recording to create a MIDI draft locally.

The selected audio is decoded in your browser; it is not uploaded to a server.

What actually flips the octave

A waveform whose repetition period is half the note's period is the note an octave up.

What decided the answer was how loud the second harmonic was relative to the first. The crossover is a number you can calculate for any pitch: 3.65× for A2, 4.53× for A3, 6.59× for A4. Below it you get the note you played; above it you get that note an octave up; in a narrow band at the edge you get nothing at all.

Pitch detection of a single line works by finding the period at which the waveform repeats. That is the whole mechanism. It has no idea what note you intended; it finds the shortest strong period and converts that to a MIDI number.

Now consider a tone built only from even harmonics: 2f, 4f, 6f, with no fundamental and no odd harmonics. Every component completes a whole number of cycles in half the time the fundamental would take, so the waveform repeats at twice the rate. The signal genuinely is periodic at 2f. A period search that finds 2f is not making a mistake in the sense of a bug — it is reporting the period that is there. The note you played is gone from the waveform.

That case is contrived. What matters is the middle ground, where the fundamental is present but the second harmonic is loud, and where the answer flips at a level you can predict. That level turned out to be high, which is why ordinary instruments do not trip it — and why the handful that do trip it do so reliably.

Measured on this converter

The crossover sits between 3.65× and 9.26×, and it rises with pitch.

One tone at a time, 1.2 seconds, peak −6.0 dBFS, 5 ms attack and release, 0.40 s of lead silence, 44.1 kHz mono, balanced sensitivity. Only the second harmonic's level changed. A result counts as a flip when the converter returns one note lasting more than a second at exactly one octave above the played pitch.

Pitch playedFrequencyPeriod the search must find2nd harmonic at which it flipsIn dB
A2 (MIDI 45)110.00 Hz401 samples3.64× – 3.66×+11.2 dB
D3 (MIDI 50)146.83 Hz300 samples4.08× – 4.09×+12.2 dB
G3 (MIDI 55)196.00 Hz225 samples4.83× – 4.84×+13.7 dB
A3 (MIDI 57)220.00 Hz200 samples4.52× – 4.53×+13.1 dB
C4 (MIDI 60)261.63 Hz169 samples4.86× – 4.88×+13.7 dB
E4 (MIDI 64)329.63 Hz134 samples5.81× – 5.83×+15.3 dB
G4 (MIDI 67)392.00 Hz113 samples6.08× – 6.09×+15.7 dB
A4 (MIDI 69)440.00 Hz100 samples6.58× – 6.59×+16.4 dB
C5 (MIDI 72)523.25 Hz84 samples7.11× – 7.13×+17.0 dB
E5 (MIDI 76)659.26 Hz67 samples9.25× – 9.27×+19.3 dB

Read the second and fourth columns together. When the period being tested is short, the two competing candidates — the true period and its half — are closer in the number of samples they can be scored over, so it takes a much louder second harmonic to overcome the correct one. That is the whole trend: the threshold climbs from 3.65× at A2 to 9.26× at E5, and it never comes back down. Low notes are not more fragile here; they are the ones that flip earliest because their period is long.

Nothing about the fundamental's level changes this. Starting from an ordinary 1/k spectrum at A2, A3 and A4, the fundamental was cut by 0, 6, 12, 18, 24, 30, 36, 42 and 48 dB with the other harmonics untouched. Every single level returned the correct pitch. At −48 dB the fundamental is one four-hundredth of the second harmonic and the answer was still A3, because the odd harmonics (3f, 5f) are still present and they only repeat at the full period. Attenuating the low end — a small speaker, a phone, a high-pass filter — cannot cause this failure on its own.

Where real sources sit

Eight instrument spectra, three octaves each: not one flipped.

Each recipe below was played at A2, A3 and A4 and the reported pitch compared with the played pitch. The last column is the one to read: the level of the second harmonic, which is the quantity the crossover table above is expressed in.

Spectrum2nd harmonic vs fundamentalA2A3A4Flipped?
Flute-like−12.0 dBwrong, MIDI 89correctcorrectno
Clarinet-like (odd only)absentwrong, MIDI 89correctcorrectno
Piano-like−4.4 dBno notescorrectcorrectno
Brass-like−0.9 dBcorrectcorrectcorrectno
Bright brass+2.9 dBcorrectcorrectcorrectno
Square wave (odd 1/k)absentwrong, MIDI 89correctcorrectno
Distorted guitar+9.5 dBcorrectcorrectcorrectno
Hard-clipped fuzz+14.0 dBno notescorrectcorrectno

That result corrects the crossover table, and it is the more useful finding. A hard-clipped fuzz puts its second harmonic at +14.0 dB — comfortably past the +13.1 dB that flipped a two-component A3 tone — and it still read A3 correctly. The reason is that the fuzz recipe also carries a strong third harmonic at +6.0 dB, and 3f only repeats at the full period, so it holds the answer down. The two-component crossover is therefore not a threshold for real sounds; it is the threshold for the case where nothing else is competing. Any meaningful odd-harmonic content moves the flip out of reach.

So an octave-up export is evidence about your source, not about the note. At A3 and A4 every one of the eight recipes was correct, bright ones included. The failures that did appear at A2 — MIDI 89, or silence — are not octave errors and belong to the low-frequency floor already documented on this site, a different mechanism with a different fix. If you are seeing a clean, uniform +12 semitone shift, the source is most likely synthetic: an octave-up oscillator, a divider patch, or something hard-clipped and heavily high-passed afterwards. Look there before you touch the MIDI.

What does and does not move it

A high-pass can break a low note. No filter can put the octave back.

Because the flip depends on the second harmonic being loud relative to the fundamental, anything that changes that ratio can move the answer. A fourth-order Butterworth high-pass applied to an ordinary 1/k spectrum does exactly that, and at A2 it goes wrong:

High-pass cornerA2 played, should be MIDI 45E3 played, should be MIDI 52A3 played, should be MIDI 57
200 Hzcorrectcorrectcorrect
400 Hzcorrectcorrectcorrect
600 Hzno notescorrectcorrect
800 Hzwrong, MIDI 75correctcorrect
1000 Hzwrong, MIDI 75correctcorrect

Only the lowest note breaks, and it does not break into an octave — it lands on MIDI 75, two and a half octaves up, which is not a transposition anyone would mistake for a tuning problem. So the common advice to high-pass before converting is not protection against octave errors. At A2, above roughly 600 Hz, the filter is the cause.

The opposite operation does not work either, and neither does any other filter. Starting from a genuine octave-up input at A3 — even harmonics only, so the converter reads MIDI 69 — a second-order low-pass was applied at 250, 300, 350, 400, 450, 500, 600 and 800 Hz. Every setting still returned MIDI 69. That is not a tuning failure of the filter; it is the shape of the problem. The waveform has no energy at 220 Hz to recover. Filtering can remove partials, it cannot create the one that was never there, so no EQ move will bring the true octave back.

The one thing that does work is adding the missing partial. Starting from the same even-only A3, the correct octave returns once a fundamental is mixed in at within 10 dB of the second harmonic. At A2 the requirement tightens to 5 dB; at A4 it loosens to 13 dB. That is a resynthesis, not a repair — and by the time the fundamental is that loud, it is no longer the take you recorded.

What you cannot use to fix it

Sensitivity does not touch the pitch decision, and neither does note length.

All three sensitivity settings were run on the same two A3 inputs: an ordinary 1/k spectrum, which should read MIDI 57, and an even-harmonics-only spectrum, which reads an octave up. The normal input returned 57 at all three settings. The even-only input returned 69 at all three settings. The setting moves the amplitude gate and the minimum note length; it does not move the period the search picks inside a frame.

The same applies to length. An even-only A3 held for 80 ms, 120 ms, 200 ms, 300 ms, 500 ms and 1200 ms returned MIDI 69 every time. A shorter note is not safer, and a longer note is not safer. Once the waveform repeats at twice the rate, the answer is settled before duration is considered.

That leaves exactly two things that work. Either the source keeps enough odd-harmonic content that the true period stays dominant — which for most instruments it already does, and the table above tells you whether yours is one of them — or you fix the octave after export by moving the affected notes down twelve semitones. The second is reliable but only correct if the error is uniform, which it is not in a mixed take: in the pairs measured here, the low note can be wrong while the note an octave above it is right.

The case that surprises people

Play a note and its octave together and you get the low one — until the top note is 12 dB louder.

An octave is the one interval where the upper note's harmonic series is already a subset of the lower note's. Five pairs were played at equal level, 1.2 s each, and the reported note was the lower pitch every time: 110 + 220 Hz gave MIDI 45, 220 + 440 Hz gave 57, 329.63 + 659.26 Hz gave 64. Never two notes, never the upper one.

Interval playedEqual levelTop note +6 dBTop note +12 dB
A2 + A3 (45 + 57)MIDI 45no notesMIDI 57
E3 + E4 (52 + 64)MIDI 52MIDI 52MIDI 64
A3 + A4 (57 + 69)MIDI 57MIDI 57MIDI 69
C4 + C5 (60 + 72)MIDI 60MIDI 60MIDI 72
E4 + E5 (64 + 76)MIDI 64MIDI 64no notes

The balance does matter, just not smoothly. At equal level and at +6 dB the lower note wins; by +12 dB the upper note has won outright. There is no row anywhere in the table that returns two notes, because a single-pitch estimator cannot hold two periods at once. And two of the cells return nothing at all rather than the wrong thing — the competing periods fragment the note below the minimum length, so the whole thing is dropped.

The practical consequence is the reverse of the usual warning. An octave double in a melody line will not add a spurious high note to your MIDI file. It either collapses into the lower note and the doubling silently disappears, or — if the top note is much louder than the bottom — the bottom note disappears instead. Either way, a part written in octaves comes back as one line, and you will be re-adding the missing one by hand.

In practice

Check the spectrum before you trust the octave.

  1. Ask whether the shift is uniform. A pure octave-up shift that affects every note the same way is this mechanism. A shift that affects only the low notes is the frequency floor, which is a different page and a different fix.
  2. If it is uniform, look at the source before the MIDI. Octave-up oscillators, divider patches, sub-octave pedals, and anything hard-clipped and then high-passed can put more energy on the even harmonics than on the fundamental. Nothing acoustic in the table above flipped.
  3. Repair by moving the notes, not by re-filtering. Twelve semitones down on the affected range is reliable exactly when the error is uniform. Re-running the conversion through a low-pass does not bring the octave back: every corner tested still returned the wrong note.
  4. Do not add a high-pass to protect the octave. It does nothing for the ratio that matters at middle pitches, and at A2 above roughly 600 Hz it produces a wrong note of its own.

Test conditions. Everything above was measured offline against the detection code in converter.js on this site (8,069 bytes, sha256 77a9dd6b9f15af65), not by ear and not against a recording. Source tones were synthesised in Node: 44,100 Hz mono, 1.2 s, peak 0.5 (−6.0 dBFS), 5 ms attack and release, 0.40 s of lead silence so the first frame is not the note's first sample. Frame size 1,024, hop 256 (5.805 ms), lag search 31–512 (86.13–1,422.6 Hz), RMS gate 0.015, minimum note length 75 ms, balanced sensitivity unless stated. The reported pitch is the median of all frame pitches inside the note. These are synthetic tones, not recordings. A real distorted guitar adds noise, string inharmonicity and a moving spectrum as the note decays, none of which is in this model, so treat the results as a map of which sources are at risk rather than a prediction for a specific file. Scripts: run-octave-floor.js (tables 1–3 and the filter sweep), probe-octave-claims.js (octave pairs, the low-pass test, the 12 dB column); logs: localmidi-private/logs/octave-floor-2026-11-25.txt.

The limit of this test. Every row except the octave pairs holds the spectrum constant for the whole note. Real playing does not — a plucked string starts bright and darkens, and a source whose second harmonic dominates only during the attack may behave differently from one where it dominates throughout. That case was not tested, and it is the most likely way for this mechanism to reach a recording that the table above clears. The A2 rows also overlap the low-frequency floor documented in the low-note guide, so a MIDI 89 result at that pitch should be read as the floor first and this mechanism second. For the pitch classes this converter can and cannot resolve at all, see the measured converter boundaries.

FAQ

Octave-error questions

Why is my MIDI exactly one octave too high?

Because the waveform repeated at twice the rate the note implies, and the period search reported what it found. In the measured case on this page, one 220 Hz tone read MIDI 57 or MIDI 69 depending only on whether its second harmonic was below or above 4.52× the fundamental. It is not random and it is not a tuning problem. Note, though, that every realistic instrument spectrum tested stayed correct, so if you see a clean uniform shift, look at the source for octave-up content rather than at the note.

Does a missing fundamental cause the octave error?

No. Cutting the fundamental by up to 48 dB — to one four-hundredth of the second harmonic — left the reported pitch correct at A2, A3 and A4, because the odd harmonics still only repeat at the full period. What flips the octave is the absence of odd harmonics, not the absence of the fundamental.

Will transposing the source up an octave fix it?

It changes the margin, and the margin does grow with pitch: the two-component crossover runs from 3.65× at A2 to 9.26× at E5. But that is the threshold for a tone with nothing else competing. Once real odd-harmonic content is present the flip moves out of reach on its own, which is why all eight realistic recipes here came back correct at every pitch tested.

Can a filter fix an octave-up export?

No. Starting from an even-harmonics-only A3 that reads MIDI 69, a second-order low-pass at every corner from 250 to 800 Hz still returned MIDI 69 — the energy at the true fundamental is not there to recover. The only operation that restores the correct octave is mixing a fundamental back in within 10 dB of the second harmonic, which is resynthesis rather than repair.

Why does a chord in octaves export as one note?

Because a single-pitch estimator cannot hold two periods at once, and the upper note's harmonics are already present in the lower note's series. Five octave pairs returned one note or none, never two. At equal level the lower pitch won; only when the top note was 12 dB louder did the upper one win instead.

Does the sensitivity setting change any of this?

No. The three settings returned MIDI 57 on a normal A3 spectrum and MIDI 69 on an even-only one, identically. Sensitivity moves the amplitude gate and the minimum note length; the period chosen inside a frame is unaffected.