lib/head_music/pitch.rb in head_music-0.22.0 vs lib/head_music/pitch.rb in head_music-0.23.0

- old
+ new

@@ -62,11 +62,12 @@ fetch_or_create(spelling, natural_letter_pitch.octave) end def self.natural_letter_pitch(number, letter_name) natural_letter_pitch = get(HeadMusic::LetterName.get(letter_name).pitch_class) - natural_letter_pitch += 12 while (number - natural_letter_pitch.to_i).to_i >= 11 + natural_letter_pitch += 12 while (number.to_i - natural_letter_pitch.to_i) >= 6 + natural_letter_pitch -= 12 while (number.to_i - natural_letter_pitch.to_i) <= -6 get(natural_letter_pitch) end def self.fetch_or_create(spelling, octave = nil) octave ||= HeadMusic::Octave::DEFAULT @@ -104,25 +105,25 @@ def natural HeadMusic::Pitch.get(to_s.gsub(HeadMusic::Sign.matcher, '')) end def +(other) - if other.is_a?(HeadMusic::FunctionalInterval) + if other.is_a?(HeadMusic::DiatonicInterval) # return a pitch other.above(self) else # assume value represents an interval in semitones and return another pitch HeadMusic::Pitch.get(to_i + other.to_i) end end def -(other) - if other.is_a?(HeadMusic::FunctionalInterval) + if other.is_a?(HeadMusic::DiatonicInterval) # return a pitch other.below(self) elsif other.is_a?(HeadMusic::Pitch) # return an interval - HeadMusic::Interval.get(to_i - other.to_i) + HeadMusic::ChromaticInterval.get(to_i - other.to_i) else # assume value represents an interval in semitones and return another pitch HeadMusic::Pitch.get(to_i - other.to_i) end end