Module: HeadMusic::Style::Guideline::MelodicContext
- Included in:
- HeadMusic::Style::Guideline
- Defined in:
- lib/head_music/style/guideline/melodic_context.rb
Overview
The line itself: the ends of it, the notes on either side of a note, and how a note stands to the tonic.
Instance Method Summary collapse
-
#diatonic_interval_from_tonic(note) ⇒ Object
protected
From the tonic below the note, so the interval is the one a singer hears rather than a compound of it.
-
#first_note ⇒ Object
-
#following_note(note) ⇒ Object
protected
Indexing past the end returns nil, which is the answer for the last note.
-
#last_note ⇒ Object
-
#preceding_note(note) ⇒ Object
protected
-
#starts_on_tonic? ⇒ Boolean
protected
-
#tonic_pitch ⇒ Object
protected
Instance Method Details
#diatonic_interval_from_tonic(note) ⇒ Object (protected)
From the tonic below the note, so the interval is the one a singer hears rather than a compound of it.
30 31 32 33 34 |
# File 'lib/head_music/style/guideline/melodic_context.rb', line 30 def diatonic_interval_from_tonic(note) tonic_to_use = tonic_pitch tonic_to_use -= HeadMusic::Rudiment::ChromaticInterval.get(:perfect_octave) while tonic_to_use > note.pitch HeadMusic::Analysis::DiatonicInterval.new(tonic_to_use, note.pitch) end |
#first_note ⇒ Object
7 8 9 |
# File 'lib/head_music/style/guideline/melodic_context.rb', line 7 def first_note notes.first end |
#following_note(note) ⇒ Object (protected)
Indexing past the end returns nil, which is the answer for the last note.
23 24 25 26 |
# File 'lib/head_music/style/guideline/melodic_context.rb', line 23 def following_note(note) index = notes.index(note) notes[index + 1] if index end |
#last_note ⇒ Object
11 12 13 |
# File 'lib/head_music/style/guideline/melodic_context.rb', line 11 def last_note notes.last end |
#preceding_note(note) ⇒ Object (protected)
17 18 19 20 |
# File 'lib/head_music/style/guideline/melodic_context.rb', line 17 def preceding_note(note) index = notes.index(note) notes[index - 1] if index&.positive? end |
#starts_on_tonic? ⇒ Boolean (protected)
36 37 38 |
# File 'lib/head_music/style/guideline/melodic_context.rb', line 36 def starts_on_tonic? tonic_spelling == first_note.spelling end |