Sha256: 9d2d49771adfdb718405d67d543daebef54f62b911a9b0ec44b7eedeaa8e34e5
Contents?: true
Size: 970 Bytes
Versions: 1
Compression:
Stored size: 970 Bytes
Contents
class HeadMusic::HarmonicInterval attr_reader :voice1, :voice2, :position def initialize(voice1, voice2, position) @voice1 = voice1 @voice2 = voice2 @position = position.is_a?(String) ? Position.new(voice1.composition, position) : position end def functional_interval @functional_interval ||= HeadMusic::FunctionalInterval.new(lower_pitch, upper_pitch) end def voices [voice1, voice2].reject(&:nil?) end def notes @notes ||= voices.map { |voice| voice.note_at(position) }.reject(&:nil?).sort_by(&:pitch) end def lower_note notes.first end def upper_note notes.last end def pitches @pitches ||= notes.map(&:pitch).sort_by(&:to_i) end def lower_pitch pitches.first end def upper_pitch pitches.last end def to_s "#{functional_interval} at #{position}" end def method_missing(method_name, *args, &block) functional_interval.send(method_name, *args, &block) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
head_music-0.13.2 | lib/head_music/harmonic_interval.rb |