Pitch accuracy
Audio to MIDI and string stiffness: the reading flips a semitone, then flips back.
A stiff string stretches its overtones while the fundamental stays where you played it. The reading flips a semitone high at 12 to 22 cents of stretch — then keeps flipping back.
The selected audio is decoded in your browser; it is not uploaded to a server.
On the converter’s own numbers, the stretch starts flipping the reading one semitone high once the second partial is out by 12 to 22 cents, and then keeps flipping it back, so no single threshold predicts what you get. That is the whole finding, and the rest of this page is the measurement behind it.
String stiffness is the reason a piano’s overtones are not exact integer multiples of the note you played. A real string resists bending, and that resistance sharpens every partial a little, with the sharpening growing with the square of the partial number. The fundamental barely moves. This is called inharmonicity, and the coefficient that describes it is conventionally written B.
It matters here because the converter does not measure pitch from the fundamental. It slides a window across the signal and asks, for every candidate period, how well the signal matches a copy of itself shifted by that period. Overtones that sit at exact multiples reinforce one candidate period; overtones that are stretched reinforce a slightly different one. So the question is not whether stiffness changes the sound — it obviously does — but whether the change is large enough to move the winning period across a semitone boundary.
It is, and the boundary is closer than you would guess. But the interesting part is what happens after you cross it.
The crossover
The first flip lands in a narrow band: 12 to 22 cents of overtone stretch.
I ran the production detector over seven pitches, each at 151 values of B from 0 to 0.03, and recorded for every value how many analysis frames read a semitone high. The flip point below is the first B at which more than half the frames are wrong, which is the point where the note actually comes back wrong rather than flickering.
| Pitch | Flip at B | 2nd partial, cents | Comes back as |
|---|---|---|---|
| E3 — 164.81 Hz | 3.40 × 10−3 | +11.7 | 53 |
| A3 — 220 Hz | 4.80 × 10−3 | +16.5 | 58 |
| C4 — 261.63 Hz | 4.40 × 10−3 | +15.1 | 61 |
| E4 — 329.63 Hz | 6.20 × 10−3 | +21.2 | 65 |
| A4 — 440 Hz | 4.60 × 10−3 | +15.8 | 70 |
| C5 — 523.25 Hz | 6.20 × 10−3 | +21.2 | 73 |
| E5 — 659.26 Hz | 6.40 × 10−3 | +21.9 | 77 |
Every note flips upward, never downward, and the stretch needed is 11.7 to 21.9 cents on the second partial. That is a narrow band for seven pitches spread over two octaves, which suggests the mechanism is not about the pitch itself but about how far one candidate period has to move to cross into the next semitone.
The cents column is the number you can actually check on a recording. Cents is a ratio, so it does not depend on which note you are looking at: if the second partial of a note sits about a fifth of a semitone above twice the fundamental, you are at the boundary. A tuner will not show you this, because a tuner reads the fundamental, and the fundamental did not move at all.
The part nobody predicts
Past the first flip, the reading goes back and forth seven times.
Here is where the simple story breaks. If stiffness sharpened the overtones and the reading followed the sharpening, then once a note flips it should stay flipped and keep climbing. It does not. Taking A3 and stepping B from 0 to 0.012 in 60 equal steps, the reading crosses the semitone line seven times: at 4.80, 5.20, 6.00, 7.00, 8.00, 9.40 and 10.4 × 10−3.
B | 2nd partial, cents | Frames reading high | Note comes back as |
|---|---|---|---|
| 0 | 0.0 | 1% | 57 — correct |
| 4.8 × 10−3 | +16.5 | 69% | 58 — a semitone high |
| 6.5 × 10−3 | +22.2 | 100% | 58 |
| 7.0 × 10−3 | +23.9 | 33% | 57 — correct again |
| 9.0 × 10−3 | +30.6 | 100% | 58 |
| 1.0 × 10−2 | +34.0 | 2% | 57 — correct again |
| 1.1 × 10−2 | +37.3 | 100% | 58 |
Read the last three rows together. At a stretch of 30.6 cents every single frame reads high. At 34.0 cents, a larger stretch, all but one frame reads correctly. At 37.3 cents it is back to every frame reading high. There is no threshold function here at all. A bigger deformation produced a better answer.
The reason is that the pitch decision is a comparison between neighbour periods one step apart, and one step at this pitch is 8.7 cents. A semitone is eleven steps. Each stretched partial nudges the correlation sum at every candidate period by a cosine, and as the stretch grows those cosines rotate through the whole circle more than once. So the sum at the true period and the sum at the period one semitone away trade places repeatedly — they do not separate monotonically.
I checked that against a closed-form approximation: take the partial amplitudes squared and sum the cosines at each candidate period, ignoring the window and the fact that longer periods use fewer samples. That model predicts nine crossings between B = 0 and 0.03, and its first crossing sits at 6.2 × 10−3 where the measurement puts it at 4.8 × 10−3. The model is an approximation and it shows — it gets the oscillation right and the exact position wrong. That is the honest way to use it: as the explanation for why the reading reverses, not as a predictor of where.
The practical consequence is blunt. You cannot look at a recording, measure its inharmonicity, and decide whether the converter will read it a semitone high. Two files with the same stiffness coefficient can land on opposite sides of the line, because the line is not where the spectrum is — it is where the two competing correlation sums happen to sit at that moment.
A check on my own method
It is not an artefact of how I built the test tones.
Every number above comes from tones I generated in code, adding sine partials with the stretch applied. Synthesised partials all start at phase zero unless you randomise them, and a correlation sum is phase-sensitive. So the obvious objection is that the oscillation is an accident of zero-phase synthesis rather than a property of the detector. I tested that directly.
I regenerated the same tone forty times, each with a different fixed random phase for every partial — reproducible seeds, same amplitude spectrum, same stretch, only the starting phases differ — and counted what the note came back as.
B | Read correct (of 40) | Read high (of 40) | Verdict |
|---|---|---|---|
| 0 | 40 | 0 | unanimous |
| 4.0 × 10−3 | 40 | 0 | unanimous |
| 4.8 × 10−3 | 0 | 40 | unanimous |
| 5.0 × 10−3 | 0 | 40 | unanimous |
| 7.0 × 10−3 | 40 | 0 | unanimous |
| 1.0 × 10−2 | 40 | 0 | unanimous |
| 2.0 × 10−2 | 0 | 40 | unanimous |
Forty seed values, forty identical answers at every stretch tested. Not one split. If phase were driving the outcome, this table would be a mix of correct and high at the boundary; instead the boundary is exactly where the zero-phase run put it and the forty seeds agree with it to the note. The oscillation is the detector’s behaviour, not my test signal’s.
I record the check here rather than leave it out because the first version of this script got it wrong. It compared the detector’s return value, a number, against a string, so every comparison was false and the table showed forty seeds “flipping” at B = 0. That table looked like a finding. It was a bug. The corrected run is the one above, and the corrected run also changed the story: it made the oscillation more certain, not less, because now the reversal reproduces across phases instead of only in the zero-phase case.
Real instruments
What actual strings reach, and how far that is from the line.
A stiffness coefficient is not an abstraction you can look up for a recording, so the useful question is different: for material that behaves like a real instrument, how close does the converter come to crossing? I measured this on the same instrument models used elsewhere on this site — an additive piano with B ≈ 0.0004 and three-string detune, a Karplus-Strong plucked guitar, a formant voice — by taking the loudest frame of each and computing the correlation sum at the period that won and at the period one semitone higher. The ratio between them is how much ground the wrong answer still has to make up. At 1.0000 it wins.
| Material | Reads as | Ratio, +1 semitone | Short by |
|---|---|---|---|
| Piano model, C4–C5 | 64 | 0.930 | 7.1% |
| Guitar, plucked line | 67 | 0.914 | 8.6% |
| Voice, four notes | 58 | 0.309 | 69.1% |
Seven to nine percent is not a comfortable margin. It is roughly the same distance the detector sits from a wrong answer on material that converts perfectly, which is why a small change in timbre, in how hard a note is struck, or in which partials survive the microphone can be enough to cross it. The voice row is the reassuring one, and it is reassuring for a reason that has nothing to do with stiffness: a voice has no stiff string, and its upper partials are shaped by resonances that do not stretch with the square of the partial number.
Turned around, the flip table says something concrete about which strings are at risk. A mid-register piano string sits near B = 0.0004 to 0.001, and the flip needs 0.0044 to 0.0064 there — a factor of four to fifteen. A short, stiff treble string is a different animal: B in the low thousandths is normal up there and 0.01 is reachable on the top octaves of a small instrument. At B = 0.01 the tables above say the note may read high or may read correctly depending on which crossing you land between, and that is precisely the case where a converter appears to fail at random on one note and not its neighbour.
This is also why a wrong semitone here cannot be diagnosed by ear and a tuner at the same time. The fundamental is at the frequency you played — a tuner agrees with you, the waveform looks right, the note sounds right — and the file still comes back a semitone high. The only visible evidence is in the upper partials, and only if you look at them.
What to do about it
Fix it after the conversion, not before it.
Because the flip is a comparison between neighbouring periods rather than a drift in the fundamental, the fix that works is a global one. If a whole passage comes back a semitone high, transpose the MIDI down a semitone and the result is correct and in the original key. Transposing the audio before conversion also works — bringing the stretch back under the line is what moved the reading back to correct in the tables above — but it costs you a resample and it is harder to undo.
What does not work is retuning by ear, because there is nothing wrong to hear. Nor is there a filter that removes the problem: the energy that decides the outcome is the stretched partials, and suppressing them changes the timbre of the instrument you are trying to transcribe. The octave-error measurements show the same lesson one octave up — filtering cannot put back a decision the period search has already made.
If you are checking a file before you convert it, look at the second partial, not the fundamental. A spectrum analyser will show it at twice the note frequency plus the cents in the table above. A note whose second partial is within about twenty cents of the ideal is a candidate; a note where it is exact is not.
Limits
What these numbers do not cover.
The limit of this test. Every tone here is additive synthesis with a stiffness model applied to the partial frequencies: partial h at h times the fundamental times the square root of one plus B times h squared. That is the standard string model, but it is still a model. A real struck string has two or three strings per note slightly detuned from each other, a soundboard resonance that colours some partials and not others, a hammer strike that excites the upper partials briefly and then lets them die, and a decay that changes the spectrum over the length of the note. None of that is in these tones. The flip points should be read as the behaviour of the algorithm under a clean stretch, not as a claim about a specific piano.
Three conditions are fixed throughout and would move the numbers. The partial amplitudes fall at 6 dB per octave; a brighter spectrum puts more weight on the stretched upper partials and a darker one puts less, and the earlier work on this converter showed that the amplitude balance between partials can decide a pitch question on its own. The note is 1.2 seconds at peak 0.5 with no decay, so every frame sees the same spectrum; a real note decays and its spectrum narrows as it does, which means the stretch that matters is the stretch in the first few hundred milliseconds, not the average. And the level is the Balanced setting: the three sensitivity settings change the loudness gate and the minimum note length, not the period search, so the pitch decision measured here should carry across, but I did not run the whole table at the other two settings.
One more boundary worth stating plainly: I tested stiffness as the only variable. In a real recording, stiffness arrives together with detuned unison strings and with a decaying envelope, and I have not measured the three together. The oscillation result in particular could look different when a note is decaying, because the frames would then be sampling a changing spectrum rather than a fixed one. That is the next measurement, not this one.
Finally, the count of seven crossings is for A3 at a 6 dB per octave slope. A different pitch or a different slope will cross a different number of times. The general claim — that the reading reverses as the stretch grows, so it is not threshold-shaped — is what the data supports; the specific count is not a constant.
Questions
Stiffness and this converter
Why would string stiffness make the pitch wrong instead of just changing the tone?
Because the converter does not read the fundamental. It compares the signal against shifted copies of itself at every candidate period, and stretched overtones reinforce a slightly shorter period than the true one. Once the winning period has moved more than half a semitone away, the note is written to the neighbouring key. The tone change and the pitch error are the same physical fact seen twice.
My tuner says the note is in tune. Can it still convert a semitone high?
Yes, and that is the distinguishing symptom. A tuner reads the fundamental, and stiffness leaves the fundamental where you played it. The reading moves because of the overtones. If a tuner and a spectrum analyser disagree about a note — tuner happy, second partial about twenty cents sharp — that note is at the boundary measured on this page.
Is more stiffness always worse?
No, and this is the finding that surprised me. On A3 the reading crossed the semitone line seven times as stiffness rose from 0 to 0.012, including a stretch of 30.6 cents where every frame read high followed by 34.0 cents where all but one frame read correctly. More deformation produced a better answer. There is no monotonic threshold to design around.
Which instruments are most at risk?
Short, stiff strings and notes high in the instrument’s range, where the coefficient is largest and where one period step covers more cents. On the models measured here a mid-register piano sat four to fifteen times below the flip point and converted cleanly, while a top-octave string at the values reported for small instruments sits inside the oscillating region. Guitars with plain steel trebles are in the same category as the piano treble.
Can I fix it by converting a different take?
Only by accident, and you will not know which take worked. The outcome depends on where two correlation sums sit relative to each other, and that shifts with small changes in which partials survive the recording. Transposing the finished MIDI is deterministic: if the whole passage is a semitone high, one transpose fixes it and keeps the key. That is the reliable fix.
Related readings
Other failures with a measured cause.
The out-of-tune page covers the neighbouring case, where the whole recording is transposed and the fundamental moves with it; there a single transpose rescues the file, and here it cannot, because the fundamental never moved. Wrong notes maps symptoms to inputs when the cause is not stiffness at all. The accuracy page measures how far the reading drifts on clean material, which is the baseline these numbers are a deviation from.
Reproduction: node run-stiffness-page.js regenerates every table on this page and prints the detector’s sha256 on its first line (77a9dd6b, 8,069 B). The detector is read directly out of the production converter.js by detector-from-live.js rather than re-implemented, so these numbers move if the shipped detector moves. The phase check is node probe-phase-robust.js, the crossing detail is node probe-osc-detail.js, and the real-material margins are node probe-real-margin.js. The smoke fixture is smoke/fixtures/stiff-oscillation.wav (392,534 B, sha256 95225a203e2b8524), five A3 notes at rising stiffness with readings 57, 58, 57, 57, 58.