Module: HeadMusic::Style::Guideline::HarmonicContext
- Included in:
- HeadMusic::Style::Guideline
- Defined in:
- lib/head_music/style/guideline/harmonic_context.rb
Overview
What sounds together: the intervals between this voice and the cantus firmus, and the motion from one to the next.
Instance Method Summary collapse
-
#downbeat_harmonic_intervals ⇒ Object
protected
-
#harmonic_intervals ⇒ Object
protected
-
#motions ⇒ Object
protected
-
#positions ⇒ Object
protected
Every moment any voice attacks, so an interval is measured wherever one could have been heard.
-
#sounding_together(intervals) ⇒ Object
protected
Fewer than two notes means one voice is silent, so nothing sounds together.
Instance Method Details
#downbeat_harmonic_intervals ⇒ Object (protected)
15 16 17 18 19 20 |
# File 'lib/head_music/style/guideline/harmonic_context.rb', line 15 def downbeat_harmonic_intervals @downbeat_harmonic_intervals ||= sounding_together( cantus_firmus.notes.map { |note| HeadMusic::Analysis::HarmonicInterval.new(note.voice, voice, note.position) } ) end |
#harmonic_intervals ⇒ Object (protected)
22 23 24 25 26 27 |
# File 'lib/head_music/style/guideline/harmonic_context.rb', line 22 def harmonic_intervals @harmonic_intervals ||= sounding_together( positions.map { |position| HeadMusic::Analysis::HarmonicInterval.new(cantus_firmus, voice, position) } ) end |
#motions ⇒ Object (protected)
9 10 11 12 13 |
# File 'lib/head_music/style/guideline/harmonic_context.rb', line 9 def motions downbeat_harmonic_intervals.each_cons(2).map do |harmonic_interval_pair| HeadMusic::Analysis::Motion.new(*harmonic_interval_pair) end end |
#positions ⇒ Object (protected)
Every moment any voice attacks, so an interval is measured wherever one could have been heard.
36 37 38 |
# File 'lib/head_music/style/guideline/harmonic_context.rb', line 36 def positions @positions ||= voices.flat_map(&:notes).map(&:position).sort.uniq(&:to_s) end |
#sounding_together(intervals) ⇒ Object (protected)
Fewer than two notes means one voice is silent, so nothing sounds together.
30 31 32 |
# File 'lib/head_music/style/guideline/harmonic_context.rb', line 30 def sounding_together(intervals) intervals.reject { |interval| interval.notes.length < 2 } end |