T-035 — Velocity dependence of the timbre: soft notes below the first layer darker, as Salamander’s v1–v3 are; the hammer felt and strike position as an analysis

Status: done · Implementation: Claude · Area: julia, rust, piano · Depends on: T-006 (T-050 for the level law below the first layer)

Read for that: T-050 (What the samples already say, D1, Outcome), T-007 H3 (velocity between and below the layers), Piano model file (Excitation, Validation), Piano 05, Piano 12 step 1 item 4; code: training/src/ReferencePiano.jl (excitation_db), crates/dsp/src/piano/model.rs (velocity_weights), training/scripts/t050_layers.jl; data: training/results/salamander/partials.csv (T-006: per-partial onset levels of all 16 layers, both mics).

Why: the row asked for the velocity dependence of the spectrum. The model already has most of it: partial.excite_db holds every partial’s level at four layers (v4, v8, v12, v16 = MIDI 40, 60.5, 92.5, 124), linear in dB between them (T-007 H3). Below MIDI 40 it plays v4’s spectrum, only quieter (T-050’s 0.36 dB per velocity step, the same for every partial). Salamander’s own v1–v3, which the model does not use, are clearly darker. So a soft note from a keyboard (MIDI 1–39, a sizeable part of real playing, T-048) sounds too bright.

What the samples already say (probe, 2026-12-04)

From partials.csv: onset level of partial (sum of the fitted components’ amplitudes at the onset), relative to v4, regressed on over ; mean of the two mics. Spectral tilt in dB per octave of partial number, relative to v4:

keyv1 (13.5)v2 (30.5)v3 (35.5)v8 (60.5)v12 (92.5)v16 (124)
C2−2.7+0.2−3.5−0.70.0+1.7
F#2−8.8−2.2−1.6+2.9+3.6+4.7
C3−11.8−2.6−0.2+3.0+5.0+2.3
F#3−6.9−3.8−1.2+2.1+3.8+3.4
C4−6.7−4.2−2.6+3.1+5.7+7.1
F#4−4.4−3.7−5.2+3.5+4.4+5.3
C5−6.6−3.9−3.9+3.9+6.9+5.6
F#5−7.2−1.6−3.7+3.2+7.1+11.8
C6−4.2+3.8−4.1+4.8+10.7+14.7
  • Below v4 the tilt keeps falling, about 0.25 dB per octave per velocity step (v1: mean −6.6 dB/oct at 26.5 steps below v4), with the trend in every key from F#2 up; C2’s numbers scatter (its partials crowd one another in the fit’s window).
  • Between the layers the model’s interpolation is unbiased: the per-partial level of the eight layers between the model’s four (v5–v7, v9–v11, v13–v15), predicted dB-linearly from them, misses by a mean of −0.7…+1.2 dB per layer. The scatter per partial is large (RMS 6–20 dB, from T-006’s component fits: near-cancelling prompt/slow pairs), so a per-partial comparison is noise; the tilt above averages over it.
  • The tilt rises from v4 to v16 by 2–5 dB/oct in the middle and up to 15 dB/oct in the treble: the model holds this in its layers already.

So what is missing is below the first layer, and it is about as large as what T-050 fixed for the level: at velocity 13 a C4 partial 8 (3 octaves) is ~20 dB too loud relative to the fundamental.

What

  1. Measure (training/scripts/t035_tilt.jl): the tilt of all 16 layers against v4, for every sampled key from C2 to C7, both mics, from partials.csv (no audio needed), with a robust regression (the per-partial scatter above); table and plot to training/results/salamander/ (CC BY 4.0). Also the tilt in the audio, from the harmonic bands of T-050’s feature (10–110 ms), as a check that does not depend on T-006’s component fits.
  2. Law below the first layer (D1): fit it on v1–v3, jointly with T-050’s level slope (D3), and put it into the model: Julia excitation_db, Rust velocity_weights/the excitation lookup, model format, a new model directory, golden vectors, the Rust paths of Piano notes’ Plugin hint; re-render the demos (T-040). The sound changes only below MIDI 40.
  3. Refit T-048/T-050’s curve against the new model (t048_velocity.jl model | fit) only if the broadband level below 40 moved (D3 keeps it where it is, so expected: no change; checked, not assumed).
  4. The hammer as an analysis (D2): fit felt stiffness (and relative to it) per sampled key to the tilt over all 16 layers, and the strike position to the comb notches of the onset spectra; results and plots only, for the physical stage (Piano model file, physical tables) — not in the model.

Decisions (accepted by the maintainer, 2026-12-04; D1 (c) to be run later as an experiment, T-051)

QuestionOptionsProposal
D1Timbre below the first layer(a) a tilt law: below , one new number (dB per octave per velocity step, ≈ 0.25 from the probe) beside T-050’s , excitation.below_first_layer_tilt_db_per_octave_per_velocity, format v3 → v4; keyboard-wide; (b) (a) with as a curve over the keys (sparse knots, the format’s curve.*) if step 1 shows a trend over the keyboard; (c) add v1 and v2 as excitation layers (T-050 D1 c: T-037/T-038 refits for those layers, hours; model +25–50 %)(a), with (b) if step 1’s per-key tilts show a trend larger than their scatter (the probe hints at a weaker tilt in the low bass and treble, but within noise). (c) gives the most faithful soft spectrum but at hours of fitting and a larger model for the least-played range; the tilt needs no refit and the tables stay byte-identical
D2The physical hammer (, , strike position)(a) analysis only, results to training/results/, no model change (the measured model has no hammer to put them into; the physical stage, Piano 13, would use them); (b) drive D1’s tilt from a fitted felt law instead of a free ; (c) leave it out of T-035 and move it to the physical stage(a): it is cheap once step 1 is measured, it answers whether the felt law explains the tilt (Piano 12’s open question), and it leaves the model on the measured excitation it reproduces to ~2 dB. (b) only if (a) shows the felt law fits v1–v16 at least as well as D1’s line; (c) if you want T-035 to be about the sound only
D3What the tilt does to the level(a) pivot chosen so T-050’s broadband level (harmonics 1–6, 10–110 ms) is unchanged: stays 0.36 dB per step, the velocity curve and the MAESTRO preset stay valid; (b) fit and jointly on the per-partial levels with (pivot at the fundamental), then refit T-048/T-050(a): T-050 calibrated the level against the recordings and MAESTRO; the tilt should change the colour, not undo that calibration. Step 3 checks that it did not

Done when

  • Step 1’s table covers every sampled key C2–C7, from both sources (component fits and audio bands), and the two agree within their scatter.
  • A test written from this page checks the D1 law against a synthetic table (recovers a known and ; level of harmonics 1–6 unchanged per D3), and Julia’s excitation_db and Rust’s excitation agree on the law at generated velocities and partial numbers below, at and above the first layer (both sides).
  • Format v4 on both sides (writer, validator, reader; v3 refused with its version named; a negative or non-finite refused), the new model passes the golden tests; demos re-rendered with a line in demos/CHANGES.md.
  • Listening check: C4 and C6 at velocities 10, 25 and 40 rendered next to Salamander’s v1, v2 and v4 (data/t035/), and the tilt of the renders measured like the recordings (within ~1 dB/oct of the recordings’ mean).
  • D2’s results (per-key and with their fit errors) in training/results/salamander/ with a plot, and a sentence in Piano 12 on whether the felt law explains the tilt.
  • Gates of AGENTS.md; bundle + clap-validator (the engine changes); no GUI change.

Outcome

Step 1, measured (t035_tilt.csv, 21 keys C2–C7 × 16 layers, two sources; plot training/results/salamander/t035_tilt.png). Mean tilt against v4, dB per octave of partial number ():

sourcev1 (13.5)v2 (30.5)v3 (35.5)v8 (60.5)v12 (92.5)v16 (124)keyboard-wide slope below v4
component fits (T-006)−5.6−1.5−1.6+3.3+5.1+6.30.208 dB/oct per step, RMS 3.8
audio bands (10–110 ms)−4.3−2.5−0.9+2.6+4.9+6.90.174, RMS 2.3
  • The two sources agree within their scatter once the audio leaves out bands within 10 dB of the floor between the harmonics. Without that, the quietest layers’ upper harmonics sit on the floor and the audio’s slope came out at 0.13. Over the fits give 0.221, so the law holds for more partials than it was fitted on.
  • The slope has a trend over the keyboard larger than its scatter (in both sources): about 0.12 in the low bass, 0.2–0.35 from C3 to F#5, and 0 from C6 up. So D1 (b) applies, as the page provided: the slope is a curve over the keys.

D1 (b), the model (format v4, model salamander-c5/2026-12-04): below MIDI 40, each mode additionally falls by dB per velocity step. is 0.115, 0.323, 0.298, 0.117, 0 at MIDI 36, 48, 66, 78, 90, linear between and held outside: a least-squares fit on both sources’ v1–v3 together (111 points, RMS 2.3 dB/octave), with knots the data push below zero held at zero. The tables are byte-identical to 2026-12-03; only the manifest’s law and the golden output changed (two soft notes added: A3 at velocity 15 and E1 at 8).

D3, the level: pivot (partial 1.18). Over keys 36–96 and velocities 13–40, the level of harmonics 1–6 changes by mean −0.14 dB, RMS 0.7 dB, range −3.2…+1.4 dB (the extremes in the bass, where harmonics 2–6 outweigh the fundamental). So the T-050 level holds on average, not per key.

Step 3, MAESTRO refit (1,136 onsets; the preset is CC BY-NC-SA 4.0 and stays outside the plugin). The curve moved more than D3 intended:

modelγ, HRMS dBmean residual per bin (u 1–29 … 95–109), dB
2026-12-03 (T-050)2.38, 85.33.455−1.2, +0.1, +0.7, +0.4, −0.1, 0.0, −0.2, −3.0
2026-12-04, T-050’s preset kept2.38, 85.33.526—
2026-12-04, refitted1.96, 85.43.494−2.5, −0.6, +1.6, +0.7, −0.4, −0.4, −1.0, −3.9

MAESTRO’s feature uses only the bands of each onset that rise 10 dB above what was sounding before. In soft notes those are mostly the low harmonics, and the tilt makes the fundamental ~1 dB louder there (pivot at partial 1.18). The fit is flat in γ (T-050 found the same: H and the level offsets trade), so a small change of the level on the kept bands moves γ. Fitting the pivot on MAESTRO instead would put MAESTRO-derived numbers into the plugin’s model (ADR-0007), so the model keeps the Salamander pivot, and the preset is refit: Velocity curve −48.5 % (was −62.5 %), Hardest touch 85.4.

Listening check (t035_check.csv; data/t035/: C4 and C6 rendered at the velocities of v1, v2 and v4 (13.5, 30.5, 40) beside Salamander’s v1, v2 and v4; Done when named velocities 10, 25, 40, but those do not compare like with like). Every sampled key rendered at the layers’ velocities, measured like the recordings, tilt against v4 in dB/octave:

layerkeysrecordings, meanmodel, meanmean abs. difference per keybefore T-035
v1 (13.5)18−4.3−5.51.44.3 (the model’s tilt was 0)
v2 (30.5)19−2.5−1.91.32.5
v3 (35.5)19−1.0−0.90.81.0

At v2 and v3 the model is within ~1 dB/oct of the recordings’ mean. At v1 it is 1.2 dB/oct too dark on average, because a tilt linear in velocity cannot meet both v1 and v2: the recordings darken faster just below v4 than further down. That is what T-051 tests with v1 and v2 as layers of their own.

D2, the hammer (analysis only, t035_hammer.csv, plot panel d):

  • Felt: a pulse width (Gaussian low-pass, the hammer speed from the fundamental’s level, only in layers where the fundamental is above its floor), fitted over the 16 layers per key. From F#2 to A3 it explains the layers better than a free tilt per layer (RMS 0.7–2.0 against 1.0–3.5 dB), with p 1.7–5.9 (median 3.1), in the textbook range (2–4, Piano 05). At C2 and D#2 the fundamental of the soft layers is at the floor, so the speed proxy fails: not determined. From C4 up, runs to the grid’s bound 1, and from C6 up the free tilt fits better. There this felt law does not explain what the layers do (or the speed proxy fails once the fundamental itself darkens). The felt stiffness is not separable from the hammer mass in this fit (only the pulse width at v4, tau4_ms, is reported), so What 4’s “K relative to p” is not delivered.
  • Strike position: comb notches in the onset spectra (v8–v16, both mics) give β ≈ 0.12 (1/8.3) at C2, D#2, F#2 and C3, where the comb lowers the fit’s RMS (C2 10.2 → 7.4 dB, D#2 11.1 → 9.1; A2 finds the same β but no gain). From D#3 up it does not help or sits at the grid’s edge: not determined (too few partials, and the mics’ and soundboard’s colouring is as large as the notches).
  • So the measured excitation stays. A physical hammer (Piano 13, T-010) can start from p ≈ 3 and β ≈ 0.12 in the bass. Above the middle it needs a better model of the pulse than one width per layer.

What was built:

  • training/scripts/t035_tilt.jl measure | fit | check | hammer (~10 s, ~5 s, ~1 min, ~30 s with -t 8; measure, check and hammer need the samples), t035_plot.py.
  • VelocityFit.tilt_pivot, fit_tilt_curve (exact non-negative least squares), curve_value, with tests in training/test/velocityfit.jl (the tilt regression reuses T-039’s ReleaseFit.huber_line).
  • Format v4 on both sides: PianoModelFile.jl (PIANO_FORMAT_VERSION = 4, the three fields and their checks), ReferencePiano.excitation_db and below_first_tilt (constants BELOW_FIRST_TILT_*), crates/model-format (FORMAT_VERSION = 4, the type renamed PianoModelV4, Excitation::tilt_at, tests tests/piano_v4.rs: v3 and a manifest without the tilt refused, negative/NaN tilt, length mismatch, empty, unordered or off-keyboard knots, negative/Inf pivot).
  • Engine: KeyModel::tilt_db_per_velocity per mode and CoeffSet::below_db = level slope + tilt per bank mode, so a note-on below the first layer costs one multiply-add per mode as before, and none from the first layer up. velocity_weights now returns the velocity steps below the first layer instead of the dB offset (unit test, and a test of the committed model’s per-mode tilt written from this page).
  • Demos re-rendered (demos/CHANGES.md), MAESTRO preset refit.
  • Gates (2026-12-04, after the review fixes): cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo nextest run (166 passed, 1 skipped), Julia Pkg.test() (2,586 passed), cargo xtask bundle piano --release + clap-validator (38 passed, 0 failed, 6 skipped). No GUI change.

Review triage (Codex at high effort and Mistral Large, 2026-12-04)

Both reviewed the change against What, Decisions and Done when and the model-file page. Both checked Julia’s and Rust’s law against each other independently: Codex through Rust’s note-on (1,320 strikes, relative error ≤ 1.9e-7), Mistral on all 88 keys × 19 velocities of the committed model (≤ 2.9e-6 dB, f32 rounding). Both confirmed the tables are byte-identical to 2026-12-03 and the MAESTRO numbers match the CSVs.

PointFromRight?Done
fit_tilt_curve drops negative knots for good, so it can miss the constrained optimumbothyes (Codex’s counterexample failed as a test; Mistral: 7 of 341 random cases)exact: every subset of free knots; test kept; the shipped curve is unchanged (on the real data the old loop was already optimal)
a valid manifest with a slope of 1e40 overflows the engine’s f32 table, and 0·∞ makes notes at and above the first layer NaNCodexyes (failing tests first: engine with an infinite tilt, validators)both validators bound the slopes to [0, 10] and the pivot to [0, log2 max_partials]; the note-on applies the tilt only below the first layer
Julia refuses a v3 manifest for a missing field instead of its version, and accepts format_version = 4.0, which Rust refusesCodexyes (tests failed first)the version is checked first and must be an integer
a Julia manifest shares the law’s arrays with the renderer, so editing one changes later rendersCodexyes (test failed first)the manifest gets copies
no test of Rust’s note-on per mode against the lawCodexyesnote_on_excites_each_mode_with_the_tilted_law (below, between and above the layers)
the felt fit at C2 and D#2 takes the speed from a fundamental below its floorCodexyeslayers need the fundamental above its floor; C2 and D#2 are now not determined (the Outcome says so)
the listening files at velocities 10 and 25 miss the recordings’ tilt by 3.6 and 1.3 dB/octCodexthe comparison is between different velocities (10 against v1’s 13.5), but the files should compare like with likerendered at the layers’ velocities instead
the model-file page says the harmonics 1–6 level stays T-050’sCodexyes, only on averagereworded with the per-key range
no relative felt stiffness ; Piano 12 without the D2 resultCodex: yes (not separable from the hammer mass here, now said in Outcome); Piano 12: written after the reviewers’ snapshot—
stale v2/v3 in doc comments and docstringsbothyeschanged to v4