Piano 14 — Computational cost: where the effort lies, where it can be saved, and quality levels
What this page is for
A living cost model of the physical piano: which parts cost CPU, which savings cost little quality, and the quality levels (Ultra, High, Medium, Low) built from them. The resonator counts come from
tools/piano_cost_model.py(assumptions stated there); the time per resonator was measured by the CPU spike T-011 on a desktop-class x86 core and on a Raspberry Pi 3 (strings only; the whole engine on the Pi is T-055). Whoever measures again replaces the numbers here and keeps the script in step.
Builds on Piano 13 (modal strings, complex one-poles, 88 key states). Relevant for the Raspberry Pi target (Standalone and remote).
Where the effort lies
The unit of cost is the resonator-sample: one complex one-pole (one partial of one string in one polarisation) advanced by one sample, ≈ 10 flops including the output sum. At 48 kHz, 1,000 resonators ≈ 0.5 GFLOP/s. Measured in the per-key engine of T-011 (pulp kernel, f32 delta form): ~0.1 ns per resonator-sample on an AVX-512 core, ~0.14 ns with AVX2 at large loads, up to ~2× that at small loads (padding of short banks, per-key overhead) — so 1,000 resonators take ~0.5 % of one core.
| Part | Cost driver | Share (typical, pedalled music) | Note |
|---|---|---|---|
| String partials | sounding keys × strings × polarisations × partials below | dominant: 70–95 % | low keys have many partials (A0 ≈ 150 below 10 kHz), high keys few (C7 ≈ 4); see the table below |
| Sympathetic resonance | undamped keys × strings × partials they keep, while the pedal is down | 5–25 % with pedal, 0 without | can run at reduced rate: low partials only |
| Soundboard convolution | IR length × output channels | small: ~0.05–0.2 GFLOP/s | non-uniform partitioned FFT; mono + decorrelation halves it |
| Coupled hammer | only during contact (1–4 ms per strike): sum over the key’s partials at + 1–3 Newton steps | negligible on average; short spikes in fast repeated chords | precomputed pulses cost ~0 |
| Phantom partials | bass keys only: slope sum over partials, squaring, ~10 longitudinal resonators | +20–30 % on the bass keys that use it | off above a key and below a velocity |
| Dampers, pedals, gain | per key per block | negligible | block-rate, not sample-rate |
| Noises | short excitations through the soundboard | negligible | |
| Coefficient recompute | tuning, quality or model changes | off the audio thread | Piano 13, “Changing parameters while playing” |
Partials below 10 kHz per string (inharmonicity included, and tuning from the curves fitted to Salamander in T-006):
| Key | A0 | A1 | A2 | C4 | C5 | C6 | C7 | C8 |
|---|---|---|---|---|---|---|---|---|
| (Hz) | 27.2 | 54.8 | 110 | 261 | 523 | 1049 | 2111 | 4264 |
| strings | 1 | 2 | 2 | 3 | 3 | 3 | 3 | 3 |
| partials < 10 kHz | 150 | 120 | 75 | 33 | 17 | 8 | 4 | 2 |
So the bass is where the effort is: one A1 key at full detail (2 strings × 2 polarisations × 120 partials ≈ 480 resonators) costs as much as a dozen treble keys. A pedalled bass line is the worst realistic case.
The savings, ranked by quality lost per CPU saved
- Cull inaudible partials (almost free in quality). A partial whose envelope falls a set level below the key’s peak (e.g. −90 dB) stops being computed. High partials decay in fractions of a second, so a note that rings for 10 s spends most of its life with a handful of low partials. Over a note’s life this removes 50–70 % of the work; the threshold is a quality knob (−100 … −60 dB).
- Keep strings and polarisations separate only for the low partials. Beating and the two-stage decay (Piano 07) are audible mainly in the lowest ~10–20 partials. Above that, one resonator per partial with the fitted average decay is nearly indistinguishable. Saves up to 4–6× on triple-strung keys.
- Cap the partial frequency (). 16 → 10 → 6 → 4 kHz. Bass partials above 5–6 kHz are weak but form the “zing” of a hard attack; the cap can depend on velocity (soft notes have little high content anyway — Piano 05).
- Reduce sympathetic resonance. Only the lowest few partials of each undamped string matter, and those are low in frequency, so the bank can run at ¼ or ⅛ of the sample rate (multirate) with a cheap interpolator into the output. Off entirely on Low.
- Multirate for the bass partials in general (an engineering step, stage 3). Partials below 3 kHz don’t need 48 kHz: computing them at 12 kHz in a band-limited branch and upsampling once per key costs roughly ¼. Large gain exactly where the cost is (the bass), at the price of resampling filters and more code.
- Cap the engine rate. At a 96 kHz host, run the engine at 48 kHz and upsample the output once: ½ at high host rates, inaudible for a piano.
- Shorter or mono soundboard response. 1.0 s stereo → 0.3 s stereo → 0.2 s mono with a decorrelating stereo stage. Small CPU, but large latency and memory implications for zero-latency convolution.
- Precomputed hammer pulses instead of the coupled hammer: saves the contact-time spikes, loses the treble re-contact effects and some velocity nuance.
- Phantom partials only in the low bass and above a velocity.
- Adaptive quality (safety net). The engine measures its time per block; under pressure (e.g. dense chords at attack) it raises the cull threshold temporarily, with hysteresis so it doesn’t pump. Prevents dropouts on weak machines; not a substitute for choosing the right level.
Not worth saving (cheap, and their loss is obvious): inharmonicity and stretched tuning (free in a modal model), detune of the low partials, the velocity-dependent hammer spectrum, dampers and release, the soundboard itself.
Quality levels
| Setting | Ultra | High | Medium | Low |
|---|---|---|---|---|
| Partial cap | 16 kHz | 10 kHz | 6 kHz | 4 kHz |
| Cull threshold | −100 dB | −90 dB | −75 dB | −60 dB |
| Strings separate for the first … partials | all | 24 | 12 | 4 |
| Second polarisation for the first … partials | all | 16 | 8 | none |
| Sympathetic resonance | 16 partials < 4 kHz per string, full rate | 8 partials < 2 kHz, full rate | 4 partials < 1 kHz, ¼ rate | off |
| Soundboard | stereo, 1.0 s | stereo, 0.5 s | stereo, 0.3 s | mono 0.2 s + decorrelation |
| Hammer | coupled | coupled | precomputed | precomputed |
| Phantom partials | keys ≤ C4 | keys ≤ C3 | keys ≤ A1 | off |
| Engine rate cap | none | 96 kHz | 48 kHz | 48 kHz |
| Adaptive quality | off | on | on | on |
Load in a dense pedalled passage (40 keys over C2–C6 struck, sustain pedal down, all other keys resonating; counts from tools/piano_cost_model.py, GFLOP/s at 10 flops per resonator-sample):
| Level | Resonators at attack | Average over the notes’ life | Sympathetic | GFLOP/s peak | GFLOP/s average |
|---|---|---|---|---|---|
| Ultra | ~11,100 | ~5,600 | ~700 | ~5.7 | ~3.0 |
| High | ~4,600 | ~1,800 | ~340 | ~2.4 | ~1.0 |
| Medium | ~2,600 | ~900 | ~40 (¼ rate) | ~1.3 | ~0.5 |
| Low | ~1,000 | ~300 | 0 | ~0.5 | ~0.15 |
Measured share of one core for the same passage (T-011; strings and sympathetic banks only, pulp kernel, f32 delta form, 48 kHz, block 64; cloud VM for the desktop columns, ±20 % between runs; Pi 3 Model B, idle, for its column):
| Level | AVX-512, peak / average | AVX2, peak / average | Raspberry Pi 3 (measured, bare banks), peak / average |
|---|---|---|---|
| Ultra | 6 % / 4 % | 8 % / 4 % | 143 % / 80 % |
| High | 2–3 % / 2 % | 4–6 % / 3 % | 65 % / 34 % |
| Medium | 2 % / 2 % | 2 % / 1 % | 37 % / 17 % |
| Low | 1 % / 1 % | 1 % / 1 % | 16 % / 9 % |
“Peak” assumes all 40 keys at their attack at once (a worst case, e.g. two-handed pedalled chords); “average” uses the fraction of partials still above the cull level over a note’s life. Not included: soundboard (+0.05–0.2), phantom partials (+20–30 % on bass keys), hammer spikes; and none of the multirate gains (savings 5–6), which would lower Ultra and High most.
The whole engine on the Pi 3 (T-055 part A, 2026-12-05; the committed salamander-c5 model through PianoEngine — per-key overhead, contact kernel, activity tracking, two channels — not the bare banks): the same dense passage (40 keys struck together, pedal down) costs ~5.35 ns per resonator-sample, RTF 0.887 on one core, i.e. ~2× the bare-bank number — the engine’s per-key overhead roughly doubles the per-resonator cost at these loads. And the slowest block at such a peak attack is a warm-measured 178–199 % of the 64-frame budget on one core (block 0 of the passage, every key in hammer contact — per run in T-055 §2b; the first run’s single maximum was 208 %), while the 10-note chord attack runs at 32 % of real time: the mean fits, the peak does not — the attack spikes are what T-024 (threads) or adaptive quality (saving 10) must absorb on the Pi. Through the cost model at 5.35 ns (the script’s last row) the levels cost, peak / average of one core: Ultra 304 / 161 %, High 126 / 56 %, Medium 69 / 25 %, Low 26 / 8 % — on one thread Medium is the Pi’s highest level (T-055 Review). The stage-1 engine has no sympathetic banks, soundboard or phantom partials yet, so these numbers grow with those stages.
Targets after T-011: a desktop core runs Ultra with room to spare — the strings are no longer what limits the instrument there, so the levels matter for the Pi and for what is still unmeasured (soundboard convolution, coupled hammer, phantom partials). On the Raspberry Pi 3 the measurement (~2.25 ns per resonator-sample, ~33× the AVX-512 core — the old 5× projection came from the Pi 5’s A76) makes the levels a CPU necessity: for the bare banks High fits one core at peak (65 %), Ultra needs 1.4 cores or four threads (peak RTF 0.40); with the whole engine’s cost (below) only Medium fits one core — T-024 decides (P-004). The earlier “~8 GFLOP/s” in Piano 13 is the upper bound without savings 1–3; the measured core does roughly 100 GFLOP/s on this kernel.
As parameters
The level is a preset over individual settings, all in crates/params (T-025) and all in the recompute class (they change which resonators exist; applied off the audio thread):
quality (Ultra/High/Medium/Low/Custom) · partial_fmax_hz · cull_db · separate_string_partials · second_polarisation_partials · sympathetic_partials, sympathetic_fmax_hz, sympathetic_rate_div · soundboard_length_s, soundboard_stereo · hammer_mode · phantom_max_key · engine_rate_cap_hz · adaptive_quality.
Offline rendering (a DAW’s bounce) can switch to Ultra automatically: CLAP tells the plugin when it renders offline (render extension).
How to keep this page true
- Pi 3: done — the measured column (2026-12-05) and
NS_PER_RES_SAMPLEfor the Pi in the script replaced the projection; desktop: done. Re-measure after the fit on real notes (T-036) changes the partial counts. - and tuning: fitted (T-006). After the fit on real notes (T-036): replace the assumed decay fractions with fitted ones.
- After listening tests (Testing and evaluation): check that High is indistinguishable from Ultra and Medium only slightly worse in ABX; adjust the table if not.