Class: HeadMusic::Style::Guidelines::StepOutOfUnison

Inherits:
Annotation
  • Object
show all
Defined in:
lib/head_music/style/guidelines/step_out_of_unison.rb

Overview

A counterpoint guideline

Constant Summary collapse

MESSAGE =
"Exit a unison by step."

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from HeadMusic::Style::Annotation

Instance Method Details

#leaps_following_unisonsObject (private)



16
17
18
# File 'lib/head_music/style/guidelines/step_out_of_unison.rb', line 16

def leaps_following_unisons
  melodic_note_pairs_following_unisons.select(&:leap?)
end

#marksObject



8
9
10
11
12
# File 'lib/head_music/style/guidelines/step_out_of_unison.rb', line 8

def marks
  leaps_following_unisons.map do |note_pair|
    HeadMusic::Style::Mark.for_all(note_pair.notes)
  end.flatten
end

#melodic_note_pairs_following_unisonsObject (private)



20
21
22
23
24
25
26
27
# File 'lib/head_music/style/guidelines/step_out_of_unison.rb', line 20

def melodic_note_pairs_following_unisons
  @melodic_note_pairs_following_unisons ||=
    perfect_unisons.map do |unison|
      note1 = voice.note_at(unison.position)
      note2 = voice.note_following(unison.position)
      HeadMusic::Content::Voice::MelodicNotePair.new(note1, note2) if note1 && note2
    end.compact
end

#perfect_unisonsObject (private)



29
30
31
# File 'lib/head_music/style/guidelines/step_out_of_unison.rb', line 29

def perfect_unisons
  @perfect_unisons ||= harmonic_intervals.select(&:perfect_consonance?).select(&:unison?)
end