Skip to content

Instantly share code, notes, and snippets.

@1j01
Forked from stuartmemo/Note to Frequency
Last active March 3, 2018 03:51
Show Gist options
  • Save 1j01/168a622ee16fa1d4722e to your computer and use it in GitHub Desktop.
Save 1j01/168a622ee16fa1d4722e to your computer and use it in GitHub Desktop.
notes = ['A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#']
getFrequency = (noten)->
440 * 2 ** ((noten - 49) / notes.length)
getNoteN = (notestr)->
i = notes.indexOf notestr[0...-1]
octave = parseInt notestr[-1..]
octave -= 1 if i >= notes.indexOf 'C'
octave * notes.length + i + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment