class HeadMusic::Motion
Motion
defines the relative pitch direction of the upper and lower voices of subsequence intervals.
Attributes
first_harmonic_interval[R]
second_harmonic_interval[R]
Public Class Methods
new(first_harmonic_interval, second_harmonic_interval)
click to toggle source
# File lib/head_music/motion.rb, line 7 def initialize(first_harmonic_interval, second_harmonic_interval) @first_harmonic_interval = first_harmonic_interval @second_harmonic_interval = second_harmonic_interval end
Public Instance Methods
contrapuntal_motion()
click to toggle source
# File lib/head_music/motion.rb, line 46 def contrapuntal_motion %i[parallel similar oblique contrary repetition].detect do |motion_type| send("#{motion_type}?") end end
contrary?()
click to toggle source
# File lib/head_music/motion.rb, line 36 def contrary? upper_melodic_interval.moving? && lower_melodic_interval.moving? && upper_melodic_interval.direction != lower_melodic_interval.direction end
direct?()
click to toggle source
# File lib/head_music/motion.rb, line 21 def direct? parallel? || similar? end
notes()
click to toggle source
# File lib/head_music/motion.rb, line 42 def notes upper_notes + lower_notes end
oblique?()
click to toggle source
# File lib/head_music/motion.rb, line 16 def oblique? upper_melodic_interval.repetition? && lower_melodic_interval.moving? || lower_melodic_interval.repetition? && upper_melodic_interval.moving? end
parallel?()
click to toggle source
# File lib/head_music/motion.rb, line 25 def parallel? upper_melodic_interval.moving? && upper_melodic_interval.direction == lower_melodic_interval.direction && upper_melodic_interval.steps == lower_melodic_interval.steps end
repetition?()
click to toggle source
# File lib/head_music/motion.rb, line 12 def repetition? upper_melodic_interval.repetition? && lower_melodic_interval.repetition? end
similar?()
click to toggle source
# File lib/head_music/motion.rb, line 31 def similar? upper_melodic_interval.direction == lower_melodic_interval.direction && upper_melodic_interval.steps != lower_melodic_interval.steps end
to_s()
click to toggle source
# File lib/head_music/motion.rb, line 52 def to_s "#{contrapuntal_motion} motion from #{first_harmonic_interval} to #{second_harmonic_interval}" end
Private Instance Methods
lower_melodic_interval()
click to toggle source
# File lib/head_music/motion.rb, line 62 def lower_melodic_interval HeadMusic::MelodicInterval.new(lower_notes.first, lower_notes.last) end
lower_notes()
click to toggle source
# File lib/head_music/motion.rb, line 70 def lower_notes [first_harmonic_interval, second_harmonic_interval].map(&:lower_note) end
upper_melodic_interval()
click to toggle source
# File lib/head_music/motion.rb, line 58 def upper_melodic_interval HeadMusic::MelodicInterval.new(upper_notes.first, upper_notes.last) end
upper_notes()
click to toggle source
# File lib/head_music/motion.rb, line 66 def upper_notes [first_harmonic_interval, second_harmonic_interval].map(&:upper_note) end