Class: HeadMusic::Style::Guidelines::Diatonic
- Inherits:
-
HeadMusic::Style::Guideline
- Object
- HeadMusic::Style::Guideline
- HeadMusic::Style::Guidelines::Diatonic
- Defined in:
- lib/head_music/style/guidelines/diatonic.rb
Overview
A counterpoint guideline
Instance Method Summary collapse
-
#fitness_denominator ⇒ Object
protected
Score by the rate of out-of-key notes rather than the raw count, so fitness is invariant to melody length.
-
#marks ⇒ Object
-
#notes_not_in_key_excluding_penultimate_leading_tone ⇒ Object
private
-
#penultimate_note ⇒ Object
private
Constructor Details
This class inherits a constructor from HeadMusic::Style::Guideline
Instance Method Details
#fitness_denominator ⇒ Object (protected)
Score by the rate of out-of-key notes rather than the raw count, so fitness is invariant to melody length.
14 15 16 |
# File 'lib/head_music/style/guidelines/diatonic.rb', line 14 def fitness_denominator notes.length end |
#marks ⇒ Object
6 7 8 |
# File 'lib/head_music/style/guidelines/diatonic.rb', line 6 def marks HeadMusic::Style::Mark.for_each(notes_not_in_key_excluding_penultimate_leading_tone) end |
#notes_not_in_key_excluding_penultimate_leading_tone ⇒ Object (private)
20 21 22 23 24 25 26 |
# File 'lib/head_music/style/guidelines/diatonic.rb', line 20 def notes_not_in_key_excluding_penultimate_leading_tone notes_not_in_key.reject do |note| penultimate_note && note == penultimate_note && HeadMusic::Rudiment::ScaleDegree.new(key_signature, note.pitch.spelling).alteration == "#" end end |
#penultimate_note ⇒ Object (private)
28 29 30 |
# File 'lib/head_music/style/guidelines/diatonic.rb', line 28 def penultimate_note voice.note_preceding(positions.last) if positions.last end |