Docs

Tuning

Pitch, inharmonicity and stretch — why a piano is never tuned to the equal-tempered table, and how the model follows a real one.

A piano string is a steel wire, and steel is stiff. A perfectly flexible string would vibrate at exact multiples of its fundamental; a stiff one resists bending a little more for each shorter wave, so every partial comes out sharp, and more so the higher it is. That is the piano’s inharmonicity — part of its slightly metallic colour, and the reason it cannot be tuned by the textbook.

Inharmonicity

Each key gets a coefficient B, and partial k lands at

fk = k · f0 · √(1 + B · k²)

Inharmonicity · partials of a stiff string

k · f0stringA0 · f0 = 27.2 Hz · B = 2.22·10⁻⁴1+1¢2+3¢4+12¢8+27¢12+48¢16C4 · f0 = 261.5 Hz · B = 2.82·10⁻⁴1+1¢2+4¢4+16¢8+34¢12+60¢16C7 · f0 = 2108 Hz · B = 0.0067761+23¢2+89¢4+312¢8
Top: where the partials of an ideal, perfectly flexible string would be — exact multiples of the fundamental. Bottom: the default instrument's strings, whose stiffness pushes each partial sharp by √(1 + B·k²). Partials are drawn up to 20 kHz. Tuners stretch the octaves to follow this (see Stretch, below).

B is large for the short, thick strings of the treble, and rises again in the bass where the strings are foreshortened to fit the case. The model uses the two-exponential law of Rigaud, David and Daudet (2013), fitted on the recordings of a Yamaha C5 (the Salamander Grand):

Inharmonicity B

1·10⁻⁵1·10⁻⁴0.0010.010.1A0C2C3C4C5C6C7C8
B per key (log scale): the two exponentials meet in the bass, near C#2, where B is lowest. Fitted on Salamander, rms 0.07 in log B.

Stretch

Because the partials are sharp, an octave tuned exactly 2:1 between fundamentals sounds flat: the upper note’s fundamental beats against the lower note’s sharp second partial. Tuners stretch the octaves instead — treble tuned sharp, bass flat — until they sound pure. The model follows a fitted stretch law, in cents from equal temperament:

cents(n) = a_t · ek_t (n − 69) − a_b · e−k_b (n − 69) + c

Stretch

-20-100102030A0C2C3C4C5C6C7C8cents
The default stretch, fitted on Salamander (C8 excluded, rms 2 cents): −16 cents at A0, +25 at C8. Hover to read any key.

a4 moves everything: 440 Hz is the modern standard, orchestras often tune to 442, baroque ensembles to 415 — the Baroque 415 character preset does that, and also turns the stretch off and makes the felt less nonlinear. Changing it rebuilds the instrument, because each string’s mass is computed from its pitch, length and tension.

In the application

The Tuning page of the Unsampled Piano interface
The Tuning page of the interface, default instrument. Its sketch is drawn from the current settings; hover a parameter to light up the part it acts on, click its name for the help shown below.

Parameters

General

A4 pitch

rebuild
a4
400470default 440 Hz

Pitch of the A above middle C, which the whole tuning follows. 440 Hz is the modern standard; some orchestras tune to 442, baroque ensembles to 415.

in the model

Each key's fundamental is a4·2^((n − 69)/12), shifted by the stretch law. The string masses follow from it (μ = T/(2·L·f0)²), so the instrument is rebuilt.

Inharmonicity

A bass

rebuild
inharmonicity.a_bass
-0.33510.3351default -0.1117range ≈

Steel strings are stiff, so their overtones are a little sharp of exact multiples of the fundamental: this gives the piano its slightly metallic colour. This sets how fast that inharmonicity falls from the lowest key towards the middle.

in the model

B(n) = e^(a_bass·n + b_bass) + e^(a_treble·n + b_treble) (Rigaud, David & Daudet 2013), partial k at k·f0·√(1 + B·k²). Fitted on Salamander's Yamaha C5 (rms 0.07 in log B).

A treble

rebuild
inharmonicity.a_treble
0.0088550.8855default 0.08855logrange ≈

How fast inharmonicity grows towards the top. Short, thick treble strings are very stiff.

in the model

Slope of the treble exponential of B(n).

B bass

rebuild
inharmonicity.b_bass
-18.3218.32default -6.107range ≈

Inharmonicity of the bass strings: higher, more 'metallic' and more out-of-tune overtones in the bass.

in the model

Offset of the bass exponential of B(n) (natural log).

B treble

rebuild
inharmonicity.b_treble
-40.4940.49default -13.5range ≈

Inharmonicity of the treble strings.

in the model

Offset of the treble exponential of B(n) (natural log).

Stretch tuning

A b

rebuild
stretch.a_b
0.0019490.1949default 0.01949logrange ≈

Amount of stretch (flattening) in the bass.

in the model

Amplitude a_b of the bass exponential (cents).

A t

rebuild
stretch.a_t
0.422442.24default 4.224logrange ≈

Tuners stretch the octaves: the treble is tuned sharp and the bass flat of equal temperament, so the octaves sound pure despite the sharp overtones. Amount of stretch in the treble.

in the model

Stretch in cents: a_t·e^(k_t·(n − 69)) − a_b·e^(−k_b·(n − 69)) + c. Fitted on Salamander, C8 excluded (rms 2 cents): −16 cents at A0, +25 at C8.

C

rebuild
stretch.c
-11.1211.12default -3.708range ≈

Offset of the whole tuning around A4 (cents).

in the model

Constant term c of the stretch law.

K b

rebuild
stretch.k_b
0.013521.352default 0.1352logrange ≈

How quickly the bass stretch builds up towards the bottom.

in the model

Rate k_b of the bass exponential (per key).

K t

rebuild
stretch.k_t
0.0049130.4913default 0.04913logrange ≈

How quickly the treble stretch builds up towards the top.

in the model

Rate k_t of the treble exponential (per key).