SPB Git

Repository Public

piano.md 3.2 KB 71 lines markdown

1<!--2ORIX Sonata3File: Documentation/acoustics/piano.md4Author: Simon-Pierre Boucher5Contact: contact@spboucher.ai6-->7# Piano89The piano engine is **modal**: each note is a sum of exponentially decaying sinusoids, the10partials of its strings. There is no hammer-string contact simulation and no soundboard11simulation; their effects are imposed on the partials' amplitudes and decays.1213## Partials of a stiff string1415    f_n = n f_s sqrt(1 + B n^2),   f_s = f0 / sqrt(1 + B)1617so that the first partial is exactly the requested pitch. The stiffness coefficient is1819    B = inharmonicity * max(8e-5, 3e-4 exp(0.085 (m - 60)))     (m = MIDI note)2021about 1e-4 in the bass, 3e-4 at middle C and above 1e-2 in the top octave, the orders of22magnitude reported for grand pianos. Up to 36 partials below 0.45 fs are generated.23Because the partials are stretched, a periodicity estimator reads a piano note sharp; the tests24measure the first partial as a spectral peak (error below 0.01 cent).2526## Hammer2728A string struck at fraction `p` of its length cannot excite partials with a node there:2930    a_n = sin(n pi p) / n * 1 / (1 + (f_n / f_c)^2)3132`p = 1/8` by default (partials 8, 16, ... vanish). The low-pass models the finite contact time33of the felt, which shortens when the key is struck harder:3435    f_c = (300 + 11000 v^2 (0.25 + 1.5 brightness)) (0.5 + hardness) + 1.5 f0    [Hz]3637That is the source of "louder is brighter" (test `louder_is_brighter_for_brass_and_piano`).38Amplitudes are normalised so that the sum of |a_n| is constant; loudness follows39`0.08 + 0.92 v^1.6`. A 12 ms burst of band-passed noise stands for the knock of the hammer and40action.4142## Double decay and beating4344Two or three strings per note, slightly mistuned and coupled at the bridge, give the piano its45fast "prompt sound" followed by a slow "aftersound", and a slow beating. Each partial is46therefore two sinusoids:4748    0.72 a_n sin(2 pi f_n d1 t) exp(-6.9 t / (0.45 T_n))  +  0.28 a_n sin(2 pi f_n d2 t) exp(-6.9 t / (1.7 T_n))4950with `d1`, `d2` detuned by a seeded random fraction of `unison_detune` (reduced to 30 % below51MIDI 34, where notes have one string), and5253    T_n = decay * 12 s * 2^(-(m - 21) / 20) / (1 + 0.05 n^1.4)5455(12 s at A0, about 3 s at middle C, 0.6 s at C8, shorter for higher partials.) This reproduces56the *shape* of the double decay; the coupling itself is not simulated, so the ratio of the two57rates does not depend on the bridge admittance as it does on an instrument.5859## Dampers, pedal, soundboard6061Note-off closes an amplitude envelope (`envelope.release`, 0.18 s by default). Notes from MIDI6290 up have no dampers and ring out. With the sustain pedal down note-offs are deferred.63`resonance` feeds the sum of the voices to 14 two-pole resonators between 55 Hz and 2.6 kHz64whose decay time is 0.35 s with the pedal up and 3.5 s with it down: a coarse stand-in for the65soundboard and for the sympathetic ringing of undamped strings. It is not a model of string to66string coupling (a held silent key does not resonate at its own partials).6768*Validity.* Timbre is plausible from A0 to C8 and responds to velocity; attack transients,69longitudinal modes ("phantom partials"), una corda and half-pedalling are not modelled.70Pitch bend is ignored by this engine.71
Files main
Menu

Theme