lib/head_music/pitch.rb in head_music-0.5.2 vs lib/head_music/pitch.rb in head_music-0.5.3
- old
+ new
@@ -12,10 +12,11 @@
delegate :smallest_interval_to, to: :pitch_class
def self.get(value)
from_name(value) || from_number(value)
end
+ singleton_class.send(:alias_method, :[], :get)
def self.from_name(name)
return nil unless name == name.to_s
fetch_or_create(HeadMusic::Spelling.get(name), HeadMusic::Octave.get(name).to_i)
end
@@ -26,11 +27,11 @@
octave = (number.to_i / 12) - 1
fetch_or_create(spelling, octave)
end
def self.from_number_and_letter(number, letter)
- letter = HeadMusic::Letter.get(letter)
- natural_letter_pitch = get(HeadMusic::Letter.get(letter).pitch_class)
+ letter = HeadMusic::LetterName.get(letter)
+ natural_letter_pitch = get(HeadMusic::LetterName.get(letter).pitch_class)
natural_letter_pitch += 12 while (number - natural_letter_pitch.to_i).to_i >= 11
natural_letter_pitch = get(natural_letter_pitch)
accidental_interval = natural_letter_pitch.smallest_interval_to(HeadMusic::PitchClass.get(number))
accidental = HeadMusic::Accidental.for_interval(accidental_interval)
spelling = HeadMusic::Spelling.fetch_or_create(letter, accidental)