Sha256: 7b28c0f2092bf05027d74324200e3b3b306a5d52c308c38035f75164766b9617
Contents?: true
Size: 1.89 KB
Versions: 10
Compression:
Stored size: 1.89 KB
Contents
class HeadMusic::Motion attr_reader :first_harmonic_interval, :second_harmonic_interval def initialize(first_harmonic_interval, second_harmonic_interval) @first_harmonic_interval = first_harmonic_interval @second_harmonic_interval = second_harmonic_interval end def repetition? upper_melodic_interval.repetition? && lower_melodic_interval.repetition? end def oblique? upper_melodic_interval.repetition? && lower_melodic_interval.moving? || lower_melodic_interval.repetition? && upper_melodic_interval.moving? end def direct? parallel? || similar? end def parallel? upper_melodic_interval.moving? && upper_melodic_interval.direction == lower_melodic_interval.direction && upper_melodic_interval.steps == lower_melodic_interval.steps end def similar? upper_melodic_interval.direction == lower_melodic_interval.direction && upper_melodic_interval.steps != lower_melodic_interval.steps end def contrary? upper_melodic_interval.moving? && lower_melodic_interval.moving? && upper_melodic_interval.direction != lower_melodic_interval.direction end def notes upper_notes + lower_notes end def contrapuntal_motion [:parallel, :similar, :oblique, :contrary, :repetition].detect do |motion_type| send("#{motion_type}?") end end def to_s "#{contrapuntal_motion} motion from #{first_harmonic_interval} to #{second_harmonic_interval}" end private def upper_melodic_interval HeadMusic::MelodicInterval.new(upper_notes.first.voice, upper_notes.first, upper_notes.last) end def lower_melodic_interval HeadMusic::MelodicInterval.new(lower_notes.first.voice, lower_notes.first, lower_notes.last) end def upper_notes [first_harmonic_interval, second_harmonic_interval].map(&:upper_note) end def lower_notes [first_harmonic_interval, second_harmonic_interval].map(&:lower_note) end end
Version data entries
10 entries across 10 versions & 1 rubygems