Class: HeadMusic::Style::Guidelines::TwoToOne

Inherits:
NoteCountPerBar show all
Defined in:
lib/head_music/style/guidelines/two_to_one.rb

Overview

A counterpoint guideline

Constant Summary collapse

MESSAGE =
"Use two half notes against each whole note in the cantus firmus."
HALF =
HeadMusic::Rudiment::RhythmicValue.get(:half)

Instance Method Summary collapse

Constructor Details

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

Instance Method Details

#check_first_bar(bar_number) ⇒ Object (private)



12
13
14
15
16
17
18
19
20
# File 'lib/head_music/style/guidelines/two_to_one.rb', line 12

def check_first_bar(bar_number)
  bar_notes = notes_in_bar(bar_number)
  bar_rests = rests_in_bar(bar_number)
  return if two_half_notes?(bar_notes)
  return if rest_then_half_note?(bar_notes, bar_rests)
  return if single_half_note_after_downbeat?(bar_notes)

  mark_bar(bar_number)
end

#check_middle_bar(bar_number) ⇒ Object (private)



22
23
24
25
26
27
# File 'lib/head_music/style/guidelines/two_to_one.rb', line 22

def check_middle_bar(bar_number)
  bar_notes = notes_in_bar(bar_number)
  return if two_half_notes?(bar_notes)

  mark_bar(bar_number)
end

#rest_then_half_note?(bar_notes, bar_rests) ⇒ Boolean (private)

Returns:

  • (Boolean)


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

def rest_then_half_note?(bar_notes, bar_rests)
  bar_notes.length == 1 &&
    bar_notes.first.rhythmic_value == HALF &&
    bar_rests.length == 1 &&
    bar_rests.first.rhythmic_value == HALF
end

#single_half_note_after_downbeat?(bar_notes) ⇒ Boolean (private)

Returns:

  • (Boolean)


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

def single_half_note_after_downbeat?(bar_notes)
  first_note = bar_notes.first
  bar_notes.length == 1 &&
    first_note.rhythmic_value == HALF &&
    first_note.position.count > 1
end

#two_half_notes?(bar_notes) ⇒ Boolean (private)

Returns:

  • (Boolean)


29
30
31
# File 'lib/head_music/style/guidelines/two_to_one.rb', line 29

def two_half_notes?(bar_notes)
  bar_notes.length == 2 && bar_notes.all? { |note| note.rhythmic_value == HALF }
end