Sha256: 62dcbcf46ec44049f32ffebfea3c24319f4a8f8fd9aaa7967001934ba29af191

Contents?: true

Size: 597 Bytes

Versions: 16

Compression:

Stored size: 597 Bytes

Contents

# frozen_string_literal: true

# 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.octave != other.octave
  end

  alias equivalent? octave_equivalent?

  private_class_method :new
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
head_music-0.26.2 lib/head_music/pitch/octave_equivalence.rb
head_music-0.26.1 lib/head_music/pitch/octave_equivalence.rb
head_music-0.26.0 lib/head_music/pitch/octave_equivalence.rb
head_music-0.25.0 lib/head_music/pitch/octave_equivalence.rb
head_music-0.24.5 lib/head_music/pitch/octave_equivalence.rb
head_music-0.24.4 lib/head_music/pitch/octave_equivalence.rb
head_music-0.24.3 lib/head_music/pitch/octave_equivalence.rb
head_music-0.24.2 lib/head_music/pitch/octave_equivalence.rb
head_music-0.24.1 lib/head_music/pitch/octave_equivalence.rb
head_music-0.24.0 lib/head_music/pitch/octave_equivalence.rb
head_music-0.23.4 lib/head_music/pitch/octave_equivalence.rb
head_music-0.23.3 lib/head_music/pitch/octave_equivalence.rb
head_music-0.23.2 lib/head_music/pitch/octave_equivalence.rb
head_music-0.23.1 lib/head_music/pitch/octave_equivalence.rb
head_music-0.23.0 lib/head_music/pitch/octave_equivalence.rb
head_music-0.22.0 lib/head_music/pitch/octave_equivalence.rb