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

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_noteObject



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_noteObject



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)

Returns:

  • (Boolean)


36
37
38
# File 'lib/head_music/style/guideline/melodic_context.rb', line 36

def starts_on_tonic?
  tonic_spelling == first_note.spelling
end

#tonic_pitchObject (protected)



40
41
42
# File 'lib/head_music/style/guideline/melodic_context.rb', line 40

def tonic_pitch
  @tonic_pitch ||= HeadMusic::Rudiment::Pitch.get(tonic_spelling)
end