T-006 — Per-note analysis of Salamander: f0, B and two-slope decays per partial, smoothed over the keyboard

Status: done · Area: julia, piano · Depends on: T-004, T-014 (data), T-013 (peak tracking)

Read for that: Piano 12 (step 1 items 1–3, step 2), Piano 04, Piano 07, ADR-0007 (licence of the results), the T-013 page (measure_partials, fit_f0_B).

Scope (maintainer, Nov 2026): the old T-006 row was split in three. This task is Piano 12 step 1 items 1–3 and step 2 for those quantities. Velocity spectra → hammer felt and strike position (item 4) are T-035; the T-013 fit on real notes is T-036; the residual (item 5) stays in T-012; release decays (item 6) come later. MAPS is not used yet (not downloaded).

What:

  1. WAV reader in Julia, hand-written (no new dependency): RIFF/WAVE, PCM 16/24/32 bit and IEEE float, WAVE_FORMAT_EXTENSIBLE; a writer for the tests.
  2. Per note, velocity and channel (all 30 sampled keys × 16 velocities × 2 mics of Salamander V3; channels are analysed separately and combined afterwards, because summing a spaced pair comb-filters partials):
    • onset;
    • partial tracking from the equal-tempered guess (T-013’s measure_partials) and the fit of → , , and the residuals in cents;
    • per-partial amplitude envelope (STFT, window a few periods of ) and a two-slope fit with the noise floor: in dB → prompt and slow rates, their amplitudes, the knee, and the beat rate where the beating is visible (a one-slope or no-beat model when the extra terms do not pay off).
  3. Combine: median over channels and velocities per key; the spread between channels and between velocities is reported as a quality check (these quantities should not depend on either).
  4. Smooth over the keyboard (step 2): tuning in cents, , and per-key decay laws (as in T-013’s model) for the prompt and the slow component, as piecewise polynomials over key number with a break where the data shows one (wound → plain); evaluated at all 88 keys.
  5. Results committed to training/results/salamander/ as small CSV/TOML tables, under CC BY 4.0 with attribution to Salamander (ADR-0007: Salamander-only → CC BY 4.0), with a README of the columns. A driver script regenerates them from data/.

Done when: tests on synthetic notes recover known , , decay rates and beat rates; the tables for all 480 notes are committed with LICENSE and attribution; a results section here (per-key deviation, , decay laws, channel/velocity spread, where the two-slope or the formula fails); Piano 12 step 1–2 updated with what the data showed.

Results

Code: training/src/Wav.jl, training/src/NoteAnalysis.jl (tested on synthetic notes in training/test/noteanalysis.jl) and the driver training/scripts/t006_analyse_salamander.jl, which writes the committed tables of training/results/salamander/ (CC BY 4.0; columns in its README) and prints the tables below. A full run takes 42 minutes on the 4-vCPU cloud VM; with sample names it only prints the per-partial fits:

julia --project=training -t 4 training/scripts/t006_analyse_salamander.jl
julia --project=training training/scripts/t006_analyse_salamander.jl C4v8 A0v8

Method, as it ended up

  • Onset: first 1 ms frame within 30 dB of the loudest, moved back to the foot of the attack. The samples start 1–12 ms before it and are faded out over their last ~1.5 s, so the last 2 s (at most 30 %) are never used.
  • Partials: one zero-padded Hann spectrum of 1.5 s, each partial searched around the running prediction as in T-013, but a peak must stand 10 dB above the median of its search window, and enters the prediction only after five partials. Without both, a missing fundamental at one mic (A1, channel 2: the mic sits near a node) let noise peaks derail the track to = 0.02. Then a robust fit of , (peaks > 3 cents or 4 robust SDs off are dropped).
  • Envelopes: Blackman–Harris STFT, 12 periods of long (2048–24000 samples), a frame every 20 ms; the floor per partial halfway between partials.
  • Decay model (DecayFit): the plan’s two slopes were not enough. In dB, real envelopes show a prompt decay and then slow beating that persists long after the prompt sound has gone (C4: beat periods of 2–4 s, 2–14 s after the strike). That is beating within the aftersound, between the out-of-phase modes of the unison (Piano 07), which a prompt-vs-slow beat cannot produce. The fitted model is a prompt component plus a slow pair with one rate, the second detuned by : , with one slope, two slopes (coherent: prompt and slow at one frequency interfere, and a power sum biased by 25 % on synthetic notes) and the full model tried in turn, each kept only if it cuts the RMS error to 0.8× the simpler one’s. Starts for the full model come from a cost-only grid over beat phase, pair balance and prompt rate; Levenberg–Marquardt alone landed in local minima.
  • Per key: medians over 16 velocities × 2 channels; decay law fitted in the log domain with robust rejection to the per-partial median rates (a relative-error fit was wrecked by components that do not decay at all).
  • Over the keyboard: robust piecewise polynomials in octaves from C4: tuning cubic without break; and the decay-law coefficients quadratic with the break the data chose.

On synthetic notes (tests) the analysis recovers to < 0.5 cent (peak picking: two components of one partial with different decays and phases make the line asymmetric, worth tenths of a cent), to < 2 %, decay rates to 3–5 %, beat rates to 3 %. One known weak spot: with a beating slow pair the prompt rate can come out up to 20 % off, because the mirrored pair fits almost as well.

Per key (medians over 16 velocities × 2 channels)

keyf0 / Hzvs ET / centcurve / centBcurve Bpartialsresid / centT60 slow @ f0 / sT60 prompt @ f0 / stwo-slope fitsbeat fitsmedian beat / Hz
A027.24-16.6-16.32.24e-042.21e-04454.594616.591 %66 %0.68
C132.40-15.9-13.41.62e-041.65e-04454.5736.118.885 %65 %0.74
D#138.71-7.9-11.01.31e-041.29e-04444.6736.416.791 %79 %0.12
F#146.01-8.9-8.98.85e-051.05e-04512.2959.815.481 %67 %0.94
A154.81-6.1-7.28.92e-059.00e-05471.1747.211.280 %73 %0.35
C265.12-7.7-5.88.97e-058.05e-05441.5447.96.8879 %75 %0.43
D#277.63-3.3-4.77.64e-057.53e-05371.3526.58.2483 %70 %0.24
F#292.30-3.7-3.87.32e-057.38e-05270.864410.792 %88 %0.31
A2109.95-0.7-3.17.84e-057.74e-05250.8335.17.4491 %86 %0.89
C3130.44-4.9-2.61.10e-041.01e-04270.45257.4473 %72 %0.4
D#3155.30-2.9-2.21.27e-041.32e-04250.63315.3386 %77 %0.38
F#3184.45-5.1-1.91.72e-041.73e-04200.7134.66.1989 %71 %0.34
A3219.97-0.3-1.62.16e-042.26e-04160.5632.86.7190 %73 %0.39
C4261.46-1.1-1.32.92e-042.95e-04160.7026.94.7984 %70 %0.49
D#4311.01-0.6-1.03.70e-043.85e-04160.8235.16.5390 %61 %0.66
F#4369.41-2.8-0.75.13e-045.02e-04100.4930.75.6686 %56 %0.59
A4440.16+0.6-0.26.44e-046.55e-04120.6039.15.375 %54 %0.96
C5524.02+2.5+0.48.23e-048.54e-0490.68244.2685 %67 %1.1
D#5622.76+1.4+1.11.14e-031.11e-0382.1015.83.1978 %69 %0.76
F#5740.84+2.0+2.11.43e-031.45e-0361.2718.22.586 %78 %1
A5882.18+4.3+3.31.84e-031.89e-0361.7315.12.1292 %61 %1.9
C61049.19+4.4+4.92.58e-032.46e-0351.7212.92.1395 %65 %2
D#61248.34+5.3+6.73.48e-033.20e-0341.567.631.8976 %57 %3.2
F#61488.63+10.1+8.94.17e-034.16e-0340.955.42.7189 %81 %2
A61773.03+12.8+11.51.15e-035.41e-0333.186.752.4791 %62 %2.5
C72107.37+11.8+14.69.72e-037.03e-0333.874.991.2890 %58 %5.8
D#72502.95+9.7+18.19.05e-039.13e-0333.537.970.72685 %55 %0.93
F#72980.33+11.9+22.11.21e-021.19e-0233.8141.2777 %54 %5.9
A73576.14+27.4+26.71.46e-021.54e-0220.812.190.58185 %41 %4
C84426.14+96.6+31.91.13e-022.00e-0246.197.830.41845 %16 %10

T60s are from each key’s decay law at its ; “two-slope fits” counts kinds 2 and 3 among all fitted partials, “beat fits” kind 3. The per-key decay-law coefficients are in keys.csv and smoothed in curves.toml.

Consistency

  • Channels: the two mics agree on to 0.35 cent and on to 1.2 % (medians over keys); worst C7 (9 cent, 87 %), where only 2–3 partials are above the floor.
  • Velocities: spread (IQR) of 0.6 cent and of 2 % (medians); worst A6 ( 39 %) and C7.
  • = 0 (fewer than 3 partials or a negative fit) in 138 of 960 channels, all in the top two octaves: there is barely measurable from isolated notes and the curve is the better value.
  • Decay fits over 17 810 partials: 0.5 % not fitted, 15 % one slope, 14 % two slopes, 71 % prompt + beating slow pair; RMS error median 2.3 dB, 90th percentile 3.5 dB, most of it in the deep beat notches, where a dB residual is very sensitive.
  • 430 slow components that do not decay within the recording (). Left out of the decay laws; candidates are sympathetic resonances of other strings and the floor of the room. T-036 should look at them.

What the data showed

  • Tuning: a stretch from −16 cent at A0 to about +30 cent at C8 (curve), as tuners do it (Piano 04). The C8 sample is a semitone sharp (+97 cent in every layer and both channels: the string sounds at 4434 Hz, checked in the raw spectrum). The robust curve ignores it; whoever renders Salamander’s C8 should know.
  • : smallest around A2 () and rising to both sides: at A0 (short wound bass strings of a 2 m grand), at C4 (Piano 04’s estimate: ), in the top octave. The break chosen by the data is at A2 (key 45), the change of slope where the wound strings end; residuals of the formula are below 1 cent in the middle and 2–5 cent in the bass.
  • Two-stage decay everywhere: slow T60 at the fundamental 35–60 s in the bass, ~30 s in the middle, 4–8 s in the top octave; prompt T60 4–5× shorter. Beating rates 0.3–1 Hz up to C5 and 2–10 Hz in the top two octaves.
  • Partial counts for the engine (Piano 14): with the fitted , A0 has 150 partials below 10 kHz (the table there is updated).

Known issues of the tables (found by T-037)

Harmless for the medians and curves above, but not for using rows as starting values: 15 of 960 channels are mis-tracked (all in the bass, e.g. A0 v4 both mics, C1 v8 and v12 mic 1: 4–6 semitones low, partial numbers shifted; recognisable as more than 20 cent off the key’s median), and some partial fits are degenerate decompositions (two components above full scale of one rate in antiphase whose difference is the partial; prompt components of +500 dB that decay in a nanosecond: 376 rows in the 119 samples T-037 used). T-037’s driver guards against both.

Not done here

  • Velocity → hammer and strike position: T-035. The real-note fit: T-036, which should start from partials.csv and model the slow pair. Residual: T-012. Release: later. MAPS (all keys) is not downloaded yet.