Piano Frequencies
Stephen Lukacs (2) iquanta.org/instruct/python
| key | note | f (Hz) | f Tesla (Hz) |
|---|
| 88 | C8 | 4186.00904 | 4109.89979 |
| 87 | B7 | 3951.06641 | 3879.22884 |
| 86 | A#7/B♭7 | 3729.31009 | 3661.50445 |
| 85 | A7 | 3520.0 | 3456.0 |
| 84 | G#7/A♭7 | 3322.43758 | 3262.02962 |
| 83 | G7 | 3135.96349 | 3078.94597 |
| 82 | F#7/G♭7 | 2959.95538 | 2906.13801 |
| 81 | F7 | 2793.82585 | 2743.02902 |
| 80 | E7 | 2637.02046 | 2589.07463 |
| 79 | D#7/E♭7 | 2489.01587 | 2443.76104 |
| 78 | D7 | 2349.31814 | 2306.60327 |
| 77 | C#7/D♭7 | 2217.46105 | 2177.14357 |
| 76 | C7 | 2093.00452 | 2054.94989 |
| 75 | B6 | 1975.53321 | 1939.61442 |
| 74 | A#6/B♭6 | 1864.65505 | 1830.75223 |
| 73 | A6 | 1760.0 | 1728.0 |
| 72 | G#6/A♭6 | 1661.21879 | 1631.01481 |
| 71 | G6 | 1567.98174 | 1539.47298 |
| 70 | F#6/G♭6 | 1479.97769 | 1453.06901 |
| 69 | F6 | 1396.91293 | 1371.51451 |
| 68 | E6 | 1318.51023 | 1294.53731 |
| 67 | D#6/E♭6 | 1244.50793 | 1221.88052 |
| 66 | D6 | 1174.65907 | 1153.30163 |
| 65 | C#6/D♭6 | 1108.73052 | 1088.57179 |
| 64 | C6 | 1046.50226 | 1027.47495 |
| 63 | B5 | 987.7666 | 969.80721 |
| 62 | A#5/B♭5 | 932.32752 | 915.37611 |
| 61 | A5 | 880.0 | 864.0 |
| 60 | G#5/A♭5 | 830.6094 | 815.50741 |
| 59 | G5 | 783.99087 | 769.73649 |
| 58 | F#5/G♭5 | 739.98885 | 726.5345 |
| 57 | F5 | 698.45646 | 685.75725 |
| 56 | E5 | 659.25511 | 647.26866 |
| 55 | D#5/E♭5 | 622.25397 | 610.94026 |
| 54 | D5 | 587.32954 | 576.65082 |
| 53 | C#5/D♭5 | 554.36526 | 544.28589 |
| 52 | C5 | 523.25113 | 513.73747 |
| 51 | B4 | 493.8833 | 484.9036 |
| 50 | A#4/B♭4 | 466.16376 | 457.68806 |
| 49 | A4 | 440.0 | 432.0 |
| 48 | G#4/A♭4 | 415.3047 | 407.7537 |
| 47 | G4 | 391.99544 | 384.86825 |
| 46 | F#4/G♭4 | 369.99442 | 363.26725 |
| 45 | F4 | 349.22823 | 342.87863 |
| 44 | E4 | 329.62756 | 323.63433 |
| 43 | D#4/E♭4 | 311.12698 | 305.47013 |
| 42 | D4 | 293.66477 | 288.32541 |
| 41 | C#4/D♭4 | 277.18263 | 272.14295 |
| 40 | C4 | 261.62557 | 256.86874 |
| 39 | B3 | 246.94165 | 242.4518 |
| 38 | A#3/B♭3 | 233.08188 | 228.84403 |
| 37 | A3 | 220.0 | 216.0 |
| 36 | G#3/A♭3 | 207.65235 | 203.87685 |
| 35 | G3 | 195.99772 | 192.43412 |
| 34 | F#3/G♭3 | 184.99721 | 181.63363 |
| 33 | F3 | 174.61412 | 171.43931 |
| 32 | E3 | 164.81378 | 161.81716 |
| 31 | D#3/E♭3 | 155.56349 | 152.73506 |
| 30 | D3 | 146.83238 | 144.1627 |
| 29 | C#3/D♭3 | 138.59132 | 136.07147 |
| 28 | C3 | 130.81278 | 128.43437 |
| 27 | B2 | 123.47083 | 121.2259 |
| 26 | A#2/B♭2 | 116.54094 | 114.42201 |
| 25 | A2 | 110.0 | 108.0 |
| 24 | G#2/A♭2 | 103.82617 | 101.93843 |
| 23 | G2 | 97.99886 | 96.21706 |
| 22 | F#2/G♭2 | 92.49861 | 90.81681 |
| 21 | F2 | 87.30706 | 85.71966 |
| 20 | E2 | 82.40689 | 80.90858 |
| 19 | D#2/E♭2 | 77.78175 | 76.36753 |
| 18 | D2 | 73.41619 | 72.08135 |
| 17 | C#2/D♭2 | 69.29566 | 68.03574 |
| 16 | C2 | 65.40639 | 64.21718 |
| 15 | B1 | 61.73541 | 60.61295 |
| 14 | A#1/B♭1 | 58.27047 | 57.21101 |
| 13 | A1 | 55.0 | 54.0 |
| 12 | G#1/A♭1 | 51.91309 | 50.96921 |
| 11 | G1 | 48.99943 | 48.10853 |
| 10 | F#1/G♭1 | 46.2493 | 45.40841 |
| 9 | F1 | 43.65353 | 42.85983 |
| 8 | E1 | 41.20344 | 40.45429 |
| 7 | D#1/E♭1 | 38.89087 | 38.18377 |
| 6 | D1 | 36.7081 | 36.04068 |
| 5 | C#1/D♭1 | 34.64783 | 34.01787 |
| 4 | C1 | 32.7032 | 32.10859 |
| 3 | B0 | 30.86771 | 30.30648 |
| 2 | A#0/B♭0 | 29.13524 | 28.6055 |
| 1 | A0 | 27.5 | 27.0 |
f(Hz) = 440 * 2(key-49)/12
"""
reference: https://iquanta.org/instruct/python ::: Piano: Frequencies of Notes ::: Stephen Lukacs, Ph.D. ©2023-03-22
"""
<page_scripts>
<style>
table.notes { width: 200px; }
table.notes td { padding: 2px 8px; }
table.notes tr:nth-child(12n+2) td { border: 2px solid gray; border-radius: 5px; }
table.notes tr:nth-child(12n+5) td { border: 2px solid pink; border-radius: 5px; }
</style>
</page_scripts>
from yatl.helpers import *
import plotly.graph_objects as go
BR = TAG['br/']
rtn = DIV()
if 1:
html = { '':"♮", '-':"♮", '_':"♭", '^':"♯", '#':"♯" }
octave = ['A', 'A#/B_', 'B', 'C', 'C#/D_', 'D', 'D#/E_', 'E', 'F', 'F#/G_', 'G', 'G#/A_']
for i, o in enumerate(octave):
xx = o.find('/')
if (xx > -1):
octave[i] = o[:xx]+"~"+'/<span class="flat">'+o[xx+1]+html["_"]+"</span>~"
else:
octave[i] = o+"~"
Hz440 = lambda n: round(440.*(2**((n-49)/12.)), 5)
Hz432 = lambda n: round(432.*(2**((n-49)/12.)), 5)
nth_octave, ith_octave = 8, 3
snth_octave = str(nth_octave)
t = TABLE(TR(TH("key"), TH("note"), TH("f (Hz)"), TH("f Tesla (Hz)"),), _class="notes")
for n in range(88, 0, -1):
try:
key = XML(octave[ith_octave].replace('~', snth_octave))
except Exception as E:
rtn.append(E)
t.append(TR(TD(n), TD(key), TD(Hz440(n)), TD(Hz432(n))))
ith_octave -= 1
if (ith_octave < 0):
ith_octave = 11
if (ith_octave == 2):
nth_octave -= 1
snth_octave = str(nth_octave)
rtn.append(DIV(t, _style="float:left;"))
fig = go.Figure()
fig.add_trace(go.Scatter(x=[ i for i in range(1, 89) ], y=[ Hz432(i) for i in range(1, 89) ], mode='markers', name="tesla", marker=go.scatter.Marker(color="DarkGray")))
fig.add_trace(go.Scatter(x=[ i for i in range(1, 89) ], y=[ Hz440(i) for i in range(1, 89) ], mode='markers', name="notes", marker=go.scatter.Marker(color="Black")))
fig.update_layout(xaxis=go.XAxis(title="key"), yaxis=go.YAxis(title="Frequency (Hz)", anchor='x', side='left'))
fig.update_layout(title_text="Piano Frequency Response per Key", height=1050, margin=go.layout.Margin(l=25, r=25, b=60, t=60, pad=0), plot_bgcolor="#f5f5f5", paper_bgcolor="White")
html = fig.to_html()
rtn.append(CAT(DIV(H1(XML("f(Hz) = 440 * 2<sup>(key-49)/12</sup>")), BR(), XML(html[html.find('<div>'):html.rfind('</div>')+6].replace('<div>', '<div id="plotly">')), _style="float:left; margin: 0px 10px; width: 75%; border: 0px solid black; border-radius: 4px;"), DIV(_style="float:none; clear:both;")))