Sha256: febae94986e4b698c85f5f953ba43f5839470d6b58c955fbe091e1befd2e2b0a

Contents?: true

Size: 580 Bytes

Versions: 9

Compression:

Stored size: 580 Bytes

Contents

# Octave equivalence is the functional equivalence of pitches with the same spelling separated by one or more octaves.
class HeadMusic::Pitch::OctaveEquivalence
  def self.get(pitch)
    @octave_equivalences ||= {}
    @octave_equivalences[pitch.to_s] ||= new(pitch)
  end

  attr_reader :pitch

  def initialize(pitch)
    @pitch = pitch
  end

  def octave_equivalent?(other)
    other = HeadMusic::Pitch.get(other)
    pitch.spelling == other.spelling && pitch.register != other.register
  end

  alias_method :equivalent?, :octave_equivalent?

  private_class_method :new
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
head_music-7.0.5 lib/head_music/pitch/octave_equivalence.rb
head_music-7.0.4 lib/head_music/pitch/octave_equivalence.rb
head_music-7.0.3 lib/head_music/pitch/octave_equivalence.rb
head_music-7.0.2 lib/head_music/pitch/octave_equivalence.rb
head_music-7.0.1 lib/head_music/pitch/octave_equivalence.rb
head_music-7.0.0 lib/head_music/pitch/octave_equivalence.rb
head_music-6.0.1 lib/head_music/pitch/octave_equivalence.rb
head_music-6.0.0 lib/head_music/pitch/octave_equivalence.rb
head_music-5.0.0 lib/head_music/pitch/octave_equivalence.rb