class HeadMusic::Pitch::OctaveEquivalence

Octave equivalence is the functional equivalence of pitches with the same spelling separated by one or more octaves.

Attributes

pitch[R]

Public Class Methods

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

Private Class Methods

new(pitch) click to toggle source
# File lib/head_music/pitch/octave_equivalence.rb, line 12
def initialize(pitch)
  @pitch = pitch
end

Public Instance Methods

equivalent?(other)
Alias for: octave_equivalent?
octave_equivalent?(other) click to toggle source
# File lib/head_music/pitch/octave_equivalence.rb, line 16
def octave_equivalent?(other)
  other = HeadMusic::Pitch.get(other)
  pitch.spelling == other.spelling && pitch.register != other.register
end
Also aliased as: equivalent?