Piano Tuning - Virginia Tech Physics

PianoTuning
For Physicists & Engineers
Piano Tuning
using your
Laptop, Microphone, and Hammer
by
Bruce Vogelaar
313 Robeson Hall
Virginia Tech
[email protected]
at
Room 130 Hahn North
April 21, 2011
1
Piano Tuning
2
What our $50 piano sounded like when delivered.
So far: cleaned, fixed four keys, raised pitch a halfstep to set A4 at 440 Hz, and did a rough tuning…
Piano Tuning
3
Bravely put your ‘VT physics
education’ to work on that
ancient piano!
Tune: to what? why? how?
Regulate: what?
Fix keys: how?
Piano Tuning
L
A piano string is fixed
at its two ends, and
can vibrate in several
harmonic modes.


Ln ;
2
v
v
fn  
n  nf 0
 2L
The string vibrating at a given frequency,
produces sound with the same frequency.
Depending where you pluck the string,
the amplitude of different frequencies varies.
What you hear is the sum.
4
p (t )  a1 sin(2f1t )  a2 sin(2f 2t )  a3 sin( 2f 3t )  ...
Why some notes sound ‘harmonious’
Piano Tuning
Octave (2/1)
5th (3/2)
4th (4/3)
3rd (5/4)
5
Octaves are universally pleasing;
to the Western ear, the 5th is next
most important.
Piano Tuning
A frequency multiplied by a power of 2
is the same note in a different octave.
6
Going up by 5ths
12 times brings you very
near the same note
(but 7 octaves up)
(this suggests perhaps
12 notes per octave)
“Wolf ” fifth
Up by 5ths: (3/2)n
Piano Tuning
“Circle of 5th s”
f
27  1.512
log2(f)
We define the number of
‘cents’ between two notes as
1200 * log2(f2/f1)
Octave = 1200 cents
“Wolf “ fifth off by 23 cents.
7
log2(f) shifted into same octave
log2 of ‘ideal’ ratios
Options for equally spaced notes
Piano Tuning
1= log 2/1
log 3/2
log 4/3
log 5/4
log 6/5
log 9/8
0
Average deviation from ‘just’ notes
8
We’ve chosen 12 EQUAL tempered steps; could have been 19 just as well…
Piano Tuning
Typically set
A4 to 440 Hz
from: http://www.sengpielaudio.com/calculator-notenames.htm
9
What an ‘aural’ tuner does…
for equal temperament:
Piano Tuning
Octave (2/1)
tune so that desired
harmonics are at the
same frequency;
5th (3/2)
4th (4/3)
3rd (5/4)
10
then, set them the
required amount off
by counting ‘beats’.
Piano Tuning
From C, set G above it such that
an octave and a fifth above the C
you hear a 0.89 Hz ‘beating’
I was hopeless,
and even wrote a
synthesizer to try
and train myself…
11
These beat frequencies are for the central octave.
but I still couldn’t
‘hear’ it…
Piano Tuning
Is it hopeless?
not with a little help from math
and a laptop…
we (non-musicians) can use a
spectrum analyzer…
12
Piano Tuning
With a (free) “Fourier” spectrum
analyzer we can set the pitches
exactly!
13
True Equal Temperament Frequencies
0
1
2
C
32.70
65.41
C#
34.65
69.30
D
36.71
73.42
D#
38.89
77.78
E
41.20
82.41
F
43.65
87.31
F#
46.25
92.50
G
49.00
98.00
G#
51.91 103.83
A
27.50
55.00 110.00
A#
29.14
58.27 116.54
B
30.87
61.74 123.47
3
130.81
138.59
146.83
155.56
164.81
174.61
185.00
196.00
207.65
220.00
233.08
246.94
4
261.63
277.18
293.66
311.13
329.63
349.23
369.99
392.00
415.30
440.00
466.16
493.88
5
523.25
554.37
587.33
622.25
659.26
698.46
739.99
783.99
830.61
880.00
932.33
987.77
6
1046.50
1108.73
1174.66
1244.51
1318.51
1396.91
1479.98
1567.98
1661.22
1760.00
1864.66
1975.53
7
8
2093.00 4186.01
2217.46
2349.32
2489.02
2637.02
2793.83
2959.96
3135.96
3322.44
3520.00
3729.31
3951.07
Destructive
Constructive
2
1
time
domain
0
Piano Tuning
-1
-2
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
frequency
spectrum
Forward and Reverse Fourier Transforms
14
Piano Tuning
Any repeating waveform
can be decomposed into
a Fourier spectrum.
But that doesn’t mean they
sound good…
frequency content determines ‘timbre’
15
Piano Tuning
Given an arbitrary waveform, how does one find its
spectral content (Fourier transform)?
• Collect N samples x dT = T seconds,
f0  1/T.
• Multiply the input by harmonics of f0 [sin(2nf0t)], and
report 2x the average for each.
1 sec
eg: 200 x 1/200 = 1 sec
f0 (1 Hz in this case)
2f0
3f0
4f0
16
200 Samples, every 1/200 second, giving f0 = 1 Hz
1 sec
Piano Tuning
Input 4Hz pure sine wave
Look for 2Hz component
Multiply & Average
17
2xAVG = 0
1 sec
Piano Tuning
Input 4Hz pure sine wave
Look for 3Hz component
4+3 = 7 Hz
Multiply & Average
4 - 3 = 1 Hz
18
2xAVG = 0
1 sec
Piano Tuning
Input 4Hz pure sine wave
Look for 4Hz component
4+4 = 8 Hz
Multiply & Average
4 - 4 = 0 Hz
19
2xAVG = 1.0
1 sec
Piano Tuning
Input 4Hz pure sine wave
Look for 5Hz component
Multiply & Average
20
2xAVG = 0
Great, picked out the 4 Hz input. But what if the input phase is different?
Use COS as well. For example: 4Hz 0 = 30o; sample 4 Hz
Piano Tuning
1 sec
sin
0.43
21
2 x (0.432 + 0.252)1/2 = 1.0 Right On!
1 sec
cos
0.25
0.25
From a “math” perspective:
Piano Tuning
࡭ ൌ ࣓࢚ ൅ ࣐
࡮ ൌ ࣓ࡾ ࢚
‫ ࡮ ܛܗ܋ ࡭ ܛܗ܋‬ൌ
૚
‫ ࡮ ܖܑܛ ࡭ ܛܗ܋‬ൌ ‫ ࡭ ܖܑܛ‬൅ ࡮ ൅ ‫ ࡭ ܖܑܛ‬െ ࡮
૛
time average is 0, unless  = R
‫࡮ ܛܗ܋ ࡭ ܛܗ܋‬
‫࡮ ܖܑܛ ࡭ ܛܗ܋‬
22
૚
ࢉ࢕࢙ ࡭ ൅ ࡮ ൅ ࢉ࢕࢙ ࡭ െ ࡮
૛
ࢉ࢕࢙ ࣐
ൌ
૛
࢙࢏࢔ ࣐
ൌ
૛
‫ܖܑܛ‬૛ ࣐ ൅ ‫ ܛܗ܋‬૛ ࣐ ൌ ૚
Piano Tuning
Signal phase does not matter.
What about input at 10.5 Hz?
23
Sample
2xAverage
7
0.09
8
0.13
9
0.21
10
0.64
11
0.64
12
0.21
13
0.13
14
0.09
Finite Resolution
Piano Tuning
Remember, we only had 200 samples, so there is a limit
to how high a frequency we can extract. Consider 188 Hz,
sampled every 1/200 seconds:
Nyquist Limit
24
Sample > 2x frequency of interest;
Fast Fourier Transforms
Piano Tuning
• 100’s of times faster
25
• uses complex numbers…
Free FFT Spectrum Analyzer:
http://www.sillanumsoft.org/download.htm
“Visual Analyzer”
Piano Tuning
But first – a critical note about ‘real’
strings (where ‘art’ can’t be avoided)
26
• strings have ‘stiffness’
• bass strings are wound to reduce this, but not
all the way to their ends
• treble strings are very short and ‘stiff’
• thus harmonics are not true multiples of
fundamentals
– their frequencies are increased by 1+n2
• concert grands have less inharmonicity
because they have longer strings
Piano Tuning
Tuning the ‘A’ keys:
32 f0
sounds ‘sharp’
33.6 f0
Ideal strings
f 0  440(2 n ); n  4 2
With 0.0001 inharmonicity
sounds ‘flat’
Need to “Stretch” the
tuning.
27
Can not match all
harmonics, must
compromise  ‘art’
Piano Tuning
(how I’ve done it)
for octaves 0-2
tune to the harmonics in octave 3
for octaves 6-7
set ‘R’ inharmonicity to ~0.0003
and use R(L) ‘Stretched’
.
28
Piano Tuning
but some keys don’t work…
29
pianos were designed to come apart
(if you break a string tuning it,
you’ll need to remove the ‘action’ anyway)
(remember to number the keys before removing them
and mark which keys hit which strings)
“Regulation”
Fixing keys, and making mechanical adjustments
so they work optimally, and ‘feel’ uniform.
Piano Tuning
a pain on spinets
30
31
Piano Tuning
Piano Tuning
32
“Voicing”
the hammers
NOT for the novice
(you can easily ruin a set of hammers)
Piano Tuning
Let’s now do it for real…
33
pin turning
unisons (‘true’ or not?)
tune using FFT
put it back together