Class: HeadMusic::Style::Guidelines::NoParallelPerfectOnDownbeats

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

Overview

A counterpoint guideline

Constant Summary collapse

MESSAGE =
"Avoid parallel perfect consonances on consecutive downbeats."

Instance Method Summary collapse

Constructor Details

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

Instance Method Details

#marksObject



8
9
10
11
12
# File 'lib/head_music/style/guidelines/no_parallel_perfect_on_downbeats.rb', line 8

def marks
  parallel_perfect_downbeat_pairs.map do |pair|
    HeadMusic::Style::Mark.for_all(pair.flat_map(&:notes))
  end
end

#parallel_perfect_downbeat_pairsObject (private)



16
17
18
19
20
21
22
# File 'lib/head_music/style/guidelines/no_parallel_perfect_on_downbeats.rb', line 16

def parallel_perfect_downbeat_pairs
  downbeat_harmonic_intervals.each_cons(2).select do |first, second|
    first.perfect_consonance?(:two_part_harmony) &&
      second.perfect_consonance?(:two_part_harmony) &&
      same_simple_type?(first, second)
  end
end

#same_simple_type?(first, second) ⇒ Boolean (private)

Returns:

  • (Boolean)


24
25
26
# File 'lib/head_music/style/guidelines/no_parallel_perfect_on_downbeats.rb', line 24

def same_simple_type?(first, second)
  first.simple_number == second.simple_number
end