Class: HeadMusic::Style::Guidelines::PrepareOctaveLeaps

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

Overview

A counterpoint guideline

Constant Summary collapse

MESSAGE =
"Enter and exit an octave leap from within."

Instance Method Summary collapse

Constructor Details

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

Instance Method Details

#external_entriesObject (private)



32
33
34
35
36
37
# File 'lib/head_music/style/guidelines/prepare_octave_leaps.rb', line 32

def external_entries
  melodic_note_pairs.each_cons(2).map do |pair|
    first, second = *pair
    pair.map(&:notes).flatten.uniq if second.octave? && !second.spans?(first.pitches.first)
  end.compact
end

#external_entries_marksObject (private)



14
15
16
17
18
# File 'lib/head_music/style/guidelines/prepare_octave_leaps.rb', line 14

def external_entries_marks
  external_entries.map do |trouble_spot|
    HeadMusic::Style::Mark.for_all(trouble_spot)
  end
end

#external_exitsObject (private)



39
40
41
42
43
44
# File 'lib/head_music/style/guidelines/prepare_octave_leaps.rb', line 39

def external_exits
  melodic_note_pairs.each_cons(2).map do |pair|
    first, second = *pair
    pair.map(&:notes).flatten.uniq if first.octave? && !first.spans?(second.pitches.last)
  end.compact
end

#external_exits_marksObject (private)



20
21
22
23
24
# File 'lib/head_music/style/guidelines/prepare_octave_leaps.rb', line 20

def external_exits_marks
  external_exits.map do |trouble_spot|
    HeadMusic::Style::Mark.for_all(trouble_spot)
  end
end

#marksObject



8
9
10
# File 'lib/head_music/style/guidelines/prepare_octave_leaps.rb', line 8

def marks
  external_entries_marks + external_exits_marks + octave_ending_marks
end

#octave_endingObject (private)



46
47
48
# File 'lib/head_music/style/guidelines/prepare_octave_leaps.rb', line 46

def octave_ending
  octave_ending? ? melodic_note_pairs.last.notes : []
end

#octave_ending?Boolean (private)

Returns:

  • (Boolean)


50
51
52
# File 'lib/head_music/style/guidelines/prepare_octave_leaps.rb', line 50

def octave_ending?
  melodic_note_pairs.last&.octave?
end

#octave_ending_marksObject (private)



26
27
28
29
30
# File 'lib/head_music/style/guidelines/prepare_octave_leaps.rb', line 26

def octave_ending_marks
  return [] unless octave_ending?

  [HeadMusic::Style::Mark.for_all(octave_ending)]
end