Class: HeadMusic::Style::Guidelines::NoParallelPerfectWithSyncopation

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

Overview

A counterpoint guideline

Constant Summary collapse

MESSAGE =
"Avoid parallel perfect consonances between syncopated notes."

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_with_syncopation.rb', line 8

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

#parallel_perfect_syncopation_pairsObject (private)



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

def parallel_perfect_syncopation_pairs
  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_with_syncopation.rb', line 24

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