Class: HeadMusic::Style::Guidelines::Diatonic
- Inherits:
-
Annotation
- Object
- Annotation
- HeadMusic::Style::Guidelines::Diatonic
- Defined in:
- lib/head_music/style/guidelines/diatonic.rb
Overview
A counterpoint guideline
Constant Summary collapse
- MESSAGE =
"Use only notes in the key signature."
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::Annotation
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.
16 17 18 |
# File 'lib/head_music/style/guidelines/diatonic.rb', line 16 def fitness_denominator notes.length end |
#marks ⇒ Object
8 9 10 |
# File 'lib/head_music/style/guidelines/diatonic.rb', line 8 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)
22 23 24 25 26 27 28 |
# File 'lib/head_music/style/guidelines/diatonic.rb', line 22 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)
30 31 32 |
# File 'lib/head_music/style/guidelines/diatonic.rb', line 30 def penultimate_note voice.note_preceding(positions.last) if positions.last end |