Skip to content

Instantly share code, notes, and snippets.

@mattly
Forked from mmower/gist:4932
Created August 11, 2008 20:19
Show Gist options
  • Save mattly/4933 to your computer and use it in GitHub Desktop.
Save mattly/4933 to your computer and use it in GitHub Desktop.
def note_to_freq( note_num )
base_note_num = note_num - 69
440.0 * Math.exp( 0.057762265 * ( note_num - 69 ) )
end
60.upto(72) {|n| puts note_to_freq(n) / note_to_freq(60) }
1.0
1.05946309430986 # 61, C#
1.12246204820462 # 62, D
1.18920711483625 # 63, D#
1.25992104965971 # 64, E
1.3348398538586 # 65, F
1.41421356197715 # 66, F#
1.49830707638728 # 67, G
1.58740105137563 # 68, G#
1.68179282980115 # 69, A
1.78179743544925 # 70, A#
1.88774862439444 # 71, B
1.99999999888011 # 72, C4. really is 2, this is the only legit rounding error here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment