Note length

Audio to MIDI: the decay sets the note length.

A note ends when it drops below a fixed loudness gate. On a steady decay the written length is 3.35 × the decay constant.

Select an audio file to create a MIDI draft locally.

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

The rule

A note ends at the first analysis frame that falls below 0.015.

Inside the detector every 23.2 ms frame is measured for loudness before any pitch is estimated. A frame quieter than the gate is treated as silence, and a run of frames ends the note at that point. Nothing in the loop asks how long the key was held, whether the note was still audible, or whether another frame later climbs back above the gate. The end of a note is the first frame that dips, and that is the whole rule. The same number holds at all three sensitivity settings, and at every decay length from 0.05 s to 6 s — the setting scales the number, it does not change its form.

This page measures what that rule does to note length: not whether notes survive — the missing-notes page covers the gate that decides that — but how long the notes that do survive turn out to be. It is a separate question and it has a separate answer, and the answer is a closed form rather than a lookup table.

Measured

On a decaying tone, the length is 3.35 × the decay constant.

Take a single A3 (220 Hz) built from five harmonics at 1/k amplitude, peak 0.5 (−6 dBFS), 44.1 kHz mono, decaying as e−t/τ. Change only τ. The table gives the length written into the file, the closed form τ·ln(peak·R/gate) alongside it, and the multiplier each one implies.

τClosed formWritten lengthWritten / τDifference
0.05 s0.168 s0.168 s3.37+0.8 ms
0.10 s0.335 s0.337 s3.37+1.6 ms
0.15 s0.503 s0.505 s3.37+2.5 ms
0.30 s1.005 s1.004 s3.35−0.9 ms
0.50 s1.675 s1.672 s3.34−3.4 ms
1.00 s3.350 s3.349 s3.35−1.0 ms
2.00 s6.701 s6.682 s3.34−19.3 ms
4.00 s13.402 s13.363 s3.34−38.7 ms
6.00 s20.103 s20.045 s3.34−58.0 ms

Balanced (gate 0.015, minimum note 75 ms). R = 0.85546 is the RMS-to-peak ratio of five harmonics at 1/k and is arithmetic, not measured. Reproduction: node run-decay-length.js, table A.

Two things fall out. First, the multiplier is constant: a tone that decays over a second is written as 3.35 s, one that decays over six seconds as 20 s. Second, the closed form is not approximate. Across a 120:1 range of decay times the predicted length is within 3 ms of the measured length at the short end, and the disagreement that does appear at the long end is a separate defect covered further down.

The practical consequence is that you cannot set note lengths. A quarter note on a plucked instrument and a dotted half on the same instrument, held for the times their notation implies, come back with identical lengths if the decay is the same, because the written length never depends on the held length once the note rings longer than the gate needs.

The cap

Held time only matters when the note is cut before it decays.

There are two ways a note ends: the decay falls through the gate, or the sound physically stops. The written length is whichever comes first, which is the smaller of the held duration and τ·ln(peak·R/gate). Both halves of that sentence are measurable, and the grid below crosses them.

τHeld 0.15 sHeld 0.40 sHeld 1.20 sHeld 3.00 sHeld 6.00 s
0.05 s0.16 s0.17 s0.17 s0.17 s0.17 s
0.15 s0.16 s0.41 s0.51 s0.51 s0.51 s
0.50 s0.16 s0.41 s1.21 s1.67 s1.67 s
1.50 s0.16 s0.41 s1.21 s3.01 s5.02 s

Read each cell as “measured (predicted)”: the two agree to within one hop of 5.805 ms everywhere in the grid. Balanced. Reproduction: node run-decay-length.js, table E.

Two rows in that table are worth naming. At τ = 0.05 s every column gives 0.17 s, because a fast decay is through the gate before any plausible held time is up — holding longer changes nothing. At τ = 1.5 s the row climbs from 0.16 s to 5.02 s, because the decay outlasts every held time in the row until the last column. The transition happens where the two quantities cross, and after that adding held time stops adding note length.

For a staccato note shorter than its decay, the reverse is true. A 0.12 s touch on a tone with τ = 0.03 s writes 0.104 s; the same touch on τ = 0.05 s writes 0.128 s and then stops growing, because the sound is gone at 0.12 s and the gate reads the last partial frame. Short articulations are the one case where your fingers set the length, and only while the decay is shorter than the touch.

The other two dials

Timbre moves the multiplier by 0.21. Level moves it by 1.39 s per 6 dB.

The multiplier is ln(peak·R/gate), so anything that changes R or the peak changes note length along with it — and both do, in ways that are easy to get backwards.

HarmonicsR (RMS/peak)Multiplier at τ=1 sWritten length
1 (sine)0.7073.163.16 s
20.7913.273.27 s
30.8253.313.31 s
50.8553.353.35 s
80.8743.373.37 s

All five tones at the same peak, 0.5. A brighter tone has more RMS for the same peak, so it sits above the gate longer. Balanced. Reproduction: node run-decay-length.js, table C.

Timbre is the quiet dial here: a pure sine and an eight-harmonic tone differ by 0.21 in the multiplier, about 6%. Level is the loud one. Because the gate is a fixed absolute number, turning the whole file down shortens every note, one decay constant times ln 2 for every 6 dB:

PeakWritten length (τ=2 s)Shorter than −6 dBFS by
−6 dBFS6.682 s0.019 s
−9 dBFS5.991 s0.710 s
−12 dBFS5.317 s1.384 s
−18 dBFS3.936 s2.765 s
−24 dBFS2.554 s4.147 s
−30 dBFS1.167 s5.534 s

Same tone, same τ= 2 s, same shape; only the gain changes. Predicted shortening is τ·ln 2 = 1.386 s per 6 dB and the measured column tracks it within 3 ms from −12 dBFS down. Balanced. Reproduction: node run-decay-length.js, table D.

The direction here is the opposite of the usual instinct. Making a take quieter does not just make notes quieter in the MIDI — the format has no level — it makes them shorter, and at −30 dBFS a two-second decay is written as 1.17 s. On the real recordings checked further down, a 6 dB trim cost 114 ms of average note length on a plucked guitar line and left a piano take unchanged; a 12 dB trim cost 400 ms and turned five notes into one.

The defect

Past about a second of decay, the note ends early — by up to 69 ms.

The closed form is what the gate would produce if the loudness measurement were exact. It is not: the frame RMS is computed from every fourth sample of a 1,024-sample window, so it carries a ripple of about 0.9% relative to the smooth decay. Near the gate, 0.9% of headroom is all that is left, and the ripple crosses the gate in both directions from frame to frame.

The detector takes the first downward crossing and stops there. The frames after it that climb back above the gate are ignored, so the note is cut at the first dip rather than at the last frame that was still above.

Frame timeFrame RMSGate 0.015
20.0161 s0.01505above
20.0220 s0.01538above
20.0278 s0.01527above
20.0336 s0.01500below — note ends here
20.0394 s0.01508above
20.0452 s0.01514above
20.0510 s0.01508above
20.0568 s0.01493below

τ = 6 s, A3, five harmonics, peak 0.5. The reported end is 20.0336 s; after it, twelve more frames clear the gate within the next half second. Reproduction: node run-decay-length.js, table H2.

The size of the cut scales with the decay constant, because a longer decay spends more time in the ripple’s reach. At τ = 0.3 s the measured length is within 1 ms of the closed form; at 6 s it is 58 ms short, and at 4 s, 39 ms. As a rule of thumb the shortfall is bounded by about 1% of τ, which is the ripple amplitude divided by the slope of the decay at the gate.

This is a real error in the file, not a rounding artefact you can ignore, and it is one-directional: notes can only come out short, never long. It also explains why a held organ note reads shorter than the recording: 20 s of steady tone with a 6 s decay constant is written as 20.045 s against a closed form of 20.103 s.

On real recordings

The same lever works, but a plucked note is not a single decay.

Synthetic tones have one clean τ. Recordings do not, so the closed form cannot be applied per note. What can be checked is the direction and the size of the level effect on material that was not generated in code.

MaterialAverage length at 0 dBat −6 dBat −12 dB
Plucked guitar, four notes0.499 s (4 notes)0.385 s (3)0.099 s (1)
Piano attack, three notes0.131 s (3)0.131 s (3)0.075 s (1)
Solo voice, four notes0.179 s (5)0.144 s (5)no notes

Unchanged fixtures from smoke/fixtures/, scaled by a linear multiply before conversion, Balanced, same detector hash. The piano and guitar takes start at −15.1 and −12.3 dBFS peak, so −6 dB moves them into a different part of the gate’s response than the synthetic sweep does. Reproduction: node probe-real-decay.js.

Two of the three rows agree with the synthetic result and one does not, and the disagreement is informative. The guitar line loses 23% of its average note length for 6 dB, which is the same order as the prediction for a decay around 0.5 s. The piano take loses nothing at 6 dB, because its own peak is already low and the first 6 dB of trim moves it from comfortably above the gate to still above the gate — the fold only lands at 12 dB, where a whole note count disappears.

That is the honest shape of the finding: the level lever is real and it is steep, but where it bites depends on where your peaks already sit relative to 0.015. A take that peaks at −6 dBFS has about 30 dB of headroom before the gate starts eating sustain; a take that peaks at −20 dBFS has almost none.

The setting

Changing sensitivity rescales every note by a constant.

The three settings carry three gates — 0.009, 0.015 and 0.023 — so they rescale the multiplier rather than changing its form. On a five-harmonic tone at the same peak, the multipliers are 3.86, 3.35 and 2.92.

What that means in practice is that “Fewer notes” shortens all the notes it does keep by about 13% relative to Balanced, and “More notes” lengthens them by about 15%. It does not choose between long and short notes; it scales the whole set. If your MIDI comes back with the right pitches and the wrong articulation, moving the slider will not fix it — the whole file stretches or shrinks together.

Measured multipliers at τ = 0.2, 0.5 and 2.0 s agree with the closed form to two decimals at all three settings. Reproduction: node run-decay-length.js, table B.

Repair

What you can actually do about it.

Raise the level before converting, not after. Normalising the take to about −6 dBFS peak buys the most sustain per unit of effort, because the gate is absolute and the ceiling is not. This is the opposite of the usual advice to leave headroom for the converter to work with; headroom is exactly what costs you note length.

Shorten the decay in the source if you want shorter notes. Because the written length is 3.35 τ, a note you want at 0.4 s needs a decay constant near 0.12 s. Damping a string, palm-muting, or using a shorter articulation is the only way to get there — there is no setting in the converter that changes the ratio.

Fix lengths in the piano roll, not by re-converting. Once the pitch content is right, quantising note ends to the grid is a single operation and it is exactly reversible. Re-converting at a different level moves the lengths by however much the level moved, which is a larger change than most edits you would make by hand.

Treat the 1% shortfall as a floor, not a bug to chase. A six-second sustain will come back up to 69 ms short and there is nothing in the interface that will fix it. Knowing the direction means you extend the last few notes rather than wonder whether the conversion failed.

Limits

What these numbers do not cover.

The limit of this test. The closed form and the whole τ sweep come from synthesised tones: exact harmonics at 1/k, no noise, no body resonance, no vibrato, one channel, 44.1 kHz, one fixed peak. A real instrument has a decay that is neither exponential nor single-valued, and a plucked string’s decay differs between its partials. Do not carry the 3.35 figure over to a specific recording and expect the note lengths to match it; use it to predict the direction and the rough size.

The three real-material rows are three short fixtures chosen for a different purpose (smoke testing), not a corpus. They are enough to show that the lever exists on recorded material and to show one case where it does not bite at 6 dB, and they are not enough to estimate an average. The piano row in particular moved from three notes to one between 6 and 12 dB, which is a count change, not a length change, and the count is governed by the minimum-duration gate rather than the length rule described here.

Everything here is measured at 44.1 kHz. The frame size and the hop are both derived from the sample rate, so on a 48 kHz machine the ripple period changes, and the size of the early-end defect may not transfer even though the multiplier does. That has not been measured and this page makes no claim about it.

Finally, the 0.9% ripple quoted above is one number from one tone. It varies with frequency and harmonic content: A2 measured 4.8% on the same test, and a pure sine at A3 measured 0.70%. The ripple amplitude is what sets the defect, so the “1% of τ” rule of thumb is a rough bound across the cases measured, not a constant.

Questions

Note length and this converter

Why are all my notes the same length?

Because they are all ending the same way — by decaying through the gate, not by stopping. If every note in your take has a similar decay, and each one rings longer than the gate needs, the written length converges on 3.35 times that decay constant regardless of how long each note was held or what value it is in the score. A take with genuinely different articulations — some notes cut short, some left to ring — comes back with different lengths.

My note is written shorter than the recording. Did the conversion fail?

No, and it did not even make a mistake by its own rules. The note ends at the first analysis frame whose loudness falls below 0.015, which happens while the sound is still faintly audible — roughly 30 dB below peak. Two additional effects make it shorter still: the frame loudness ripples around the smooth decay, so the first downward crossing lands early, and the effect grows with the decay constant, reaching about 69 ms on a six-second sustain. Extend the tail in the piano roll.

Does raising the volume make the notes longer?

Yes, and by a predictable amount: one decay constant times ln 2, about 1.39 s per 6 dB on a two-second decay. The gate is a fixed absolute level rather than a fraction of the peak, so a quieter file crosses it sooner in every note’s decay. This is why a take normalised to −6 dBFS keeps more sustain than the same take left at −20 dBFS.

Is this the same as notes being dropped?

No, and the two are governed by different gates. A dropped note never reaches the output at all — it failed the minimum-duration test, which is a separate constant per sensitivity setting. A short note reaches the output but with a length set by its decay. The same phrase can lose notes and shorten the survivors at the same time, which is why a quiet take looks like a different performance rather than a quieter one.

Why does a staccato passage come back with longer notes than I played?

It does not, but it can come back with the notes it did keep being set by a decay that outlasts the touch. A 0.12 s touch on a tone with a 0.05 s decay constant writes 0.128 s, which is slightly longer than the touch and much shorter than the 0.168 s the same decay would write if the note were held. Below about 0.022 s of decay constant the same touch fails the minimum-duration gate outright and disappears instead, because the whole note is then shorter than 75 ms.

Can I make the converter preserve the lengths I played?

Not through the interface. The rule has no term for held duration: it reads the loudness of successive analysis frames and ends the note at the first one below the gate. The only lever that puts held duration back into the result is shortening the decay so that the physical end of the note arrives before the gate does — which is a change to the performance, not to the tool.

Related readings

The missing-notes page covers the other side of the same decision — the minimum-duration gate that removes notes entirely, with the length, level and repeat-gap thresholds. The slow-attack page measures where a note starts, which is the same frame loop read at the front instead of the back. The accuracy page collects the register and pitch failures that this page deliberately leaves out.

Reproduction: node run-decay-length.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 straight out of the production converter.js by detector-from-live.js rather than re-implemented, so these numbers move when the shipped detector moves. The per-frame evidence for the early cut is node probe-first-dip.js; the RMS ripple measurement is node probe-ripple-test.js; the real-material sweep is node probe-real-decay.js. Fixtures: smoke/fixtures/piano-real-attack.wav, guitar-ks.wav, voice-real-4notes.wav.