Last active
August 29, 2015 14:27
-
-
Save liammclennan/aa1b3a5e74eb3ff01898 to your computer and use it in GitHub Desktop.
Pitch frequency code puzzle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write a function that calculates the number of semitones between two musical notes. | |
The notes are [A;ASharp;B;C;CSharp;D;DSharp;E;F;FSharp;G;GSharp]. | |
The distance between each is 1 semitone. E.g. ASharp -> E = 6 semitones. | |
Twist: The notes can be in 3 different octaves. E.g. ASharp (octave 1) -> E (octave 2) = 18 semitones. | |
Extra credit: If A (octave 1) is 220Hz write a function that calculates the frequency of a note in an octave. | |
E.g. Frequency(A, 1) == 220, Frequency(A,2) == 440 etc | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment