-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Piano frequency #23
Comments
Thanks! Here's my version: julia> using MusicTheory, MusicTheory.PitchNames
julia> abstract type Temperament end
julia> struct EqualTemperament
base_pitch::Pitch
base_frequency::Float64
end
julia> temperament = EqualTemperament(A[4], 440)
EqualTemperament(A₄, 440.0)
julia> function frequency(temperament::EqualTemperament, pitch::Pitch)
semitone_distance = semitone(pitch) - semitone(temperament.base_pitch)
return 2.0^(semitone_distance // 12)
end
frequency (generic function with 1 method)
julia> frequency(temperament, C[4])
0.5946035575013605
julia> function frequency(temperament::EqualTemperament, pitch::Pitch)
semitone_distance = semitone(pitch) - semitone(temperament.base_pitch)
return 2.0^(semitone_distance // 12) * temperament.base_frequency
end
frequency (generic function with 1 method)
julia> frequency(temperament, C[4])
261.6255653005986 |
I'll add a |
Done in #24. Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey! Here is a little function to get the piano frequency of a
Pitch
, using the table https://upload.wikimedia.org/wikipedia/commons/a/ad/Piano_key_frequencies.pngThe text was updated successfully, but these errors were encountered: