Class: HeadMusic::Style::Guidelines::RecoverLargeLeaps

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

Overview

Ok, so a rule might be that after the first leap (after previous steps) one should normally move by step in the opposite direction unless another leap (in either direction) creates a consonant triad.

  • Brian

Direct Known Subclasses

SingleLargeLeaps

Constant Summary collapse

MESSAGE =
"Recover large leaps by step in the opposite direction."

Instance Method Summary collapse

Constructor Details

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

Instance Method Details

#direction_changed?(first_note_pair, second_note_pair) ⇒ Boolean (private)

Returns:

  • (Boolean)


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

def direction_changed?(first_note_pair, second_note_pair)
  first_note_pair.ascending? && second_note_pair.descending? ||
    first_note_pair.descending? && second_note_pair.ascending?
end

#marksObject



11
12
13
14
15
16
17
# File 'lib/head_music/style/guidelines/recover_large_leaps.rb', line 11

def marks
  melodic_note_pairs.each_cons(3).map do |note_pairs|
    if unrecovered_leap?(note_pairs[0], note_pairs[1], note_pairs[2])
      HeadMusic::Style::Mark.for_all(notes_in_note_pairs(note_pairs))
    end
  end.compact
end

#notes_in_note_pairs(note_pairs) ⇒ Object (private)



21
22
23
# File 'lib/head_music/style/guidelines/recover_large_leaps.rb', line 21

def notes_in_note_pairs(note_pairs)
  (note_pairs[0].notes + note_pairs[1].notes).uniq
end

#spelling_consonant_triad?(first_note_pair, second_note_pair, third_note_pair) ⇒ Boolean (private)

Returns:

  • (Boolean)


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

def spelling_consonant_triad?(first_note_pair, second_note_pair, third_note_pair)
  first_note_pair.spells_consonant_triad_with?(second_note_pair) ||
    second_note_pair.spells_consonant_triad_with?(third_note_pair)
end

#unrecovered_leap?(first_note_pair, second_note_pair, third_note_pair) ⇒ Boolean (private)

Returns:

  • (Boolean)


25
26
27
28
29
30
31
32
# File 'lib/head_music/style/guidelines/recover_large_leaps.rb', line 25

def unrecovered_leap?(first_note_pair, second_note_pair, third_note_pair)
  first_note_pair.large_leap? &&
    !spelling_consonant_triad?(first_note_pair, second_note_pair, third_note_pair) &&
    (
      !direction_changed?(first_note_pair, second_note_pair) ||
      !second_note_pair.step?
    )
end