Sha256: 251fa53c10cb44747f171b05a80d4eeb8f488f88391f017108d0e3b53e4b54c9
Contents?: true
Size: 805 Bytes
Versions: 6
Compression:
Stored size: 805 Bytes
Contents
# Encapsulate the distance methods of the interval class HeadMusic::DiatonicInterval::Size attr_reader :low_pitch, :high_pitch def initialize(pitch1, pitch2) @low_pitch, @high_pitch = *[pitch1, pitch2].sort end def number @number ||= @low_pitch.steps_to(@high_pitch) + 1 end def simple_number @simple_number ||= octave_equivalent? ? 8 : (number - 1) % 7 + 1 end def octaves @octaves ||= number / 8 end def simple? number <= 8 end def compound? !simple? end def simple_semitones @simple_semitones ||= semitones % 12 end def semitones (high_pitch - low_pitch).to_i end def steps number - 1 end def simple_steps steps % 7 end private def octave_equivalent? number > 1 && ((number - 1) % 7).zero? end end
Version data entries
6 entries across 6 versions & 1 rubygems