Sha256: c8562953e145be93a56ff7974df14fd1c78b4ad7fa03124a9db3189587b362e1
Contents?: true
Size: 744 Bytes
Versions: 9
Compression:
Stored size: 744 Bytes
Contents
# An enharmonic equivalent pitch is the same frequency spelled differently, such as D# and Eb. class HeadMusic::Pitch::EnharmonicEquivalence def self.get(pitch) pitch = HeadMusic::Pitch.get(pitch) @enharmonic_equivalences ||= {} @enharmonic_equivalences[pitch.to_s] ||= new(pitch) end attr_reader :pitch delegate :pitch_class, to: :pitch def initialize(pitch) @pitch = HeadMusic::Pitch.get(pitch) end def enharmonic_equivalent?(other) other = HeadMusic::Pitch.get(other) pitch.midi_note_number == other.midi_note_number && pitch.spelling != other.spelling end alias_method :enharmonic?, :enharmonic_equivalent? alias_method :equivalent?, :enharmonic_equivalent? private_class_method :new end
Version data entries
9 entries across 9 versions & 1 rubygems