class HeadMusic::Pitch::EnharmonicEquivalence

An enharmonic equivalent pitch is the same frequency spelled differently, such as D# and Eb.

Attributes

pitch[R]

Public Class Methods

get(pitch) click to toggle source
# File lib/head_music/pitch/enharmonic_equivalence.rb, line 5
def self.get(pitch)
  pitch = HeadMusic::Pitch.get(pitch)
  @enharmonic_equivalences ||= {}
  @enharmonic_equivalences[pitch.to_s] ||= new(pitch)
end

Private Class Methods

new(pitch) click to toggle source
# File lib/head_music/pitch/enharmonic_equivalence.rb, line 15
def initialize(pitch)
  @pitch = HeadMusic::Pitch.get(pitch)
end

Public Instance Methods

enharmonic?(other)
enharmonic_equivalent?(other) click to toggle source
# File lib/head_music/pitch/enharmonic_equivalence.rb, line 19
def enharmonic_equivalent?(other)
  other = HeadMusic::Pitch.get(other)
  pitch.midi_note_number == other.midi_note_number && pitch.spelling != other.spelling
end
Also aliased as: enharmonic?, equivalent?
equivalent?(other)