Class: HeadMusic::Style::Guidelines::ThreeToOne

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

Overview

A counterpoint guideline

Constant Summary collapse

MESSAGE =
"Use three quarter notes against each dotted half note in the cantus firmus."
QUARTER =
HeadMusic::Rudiment::RhythmicValue.get(:quarter)
DOTTED_HALF =
HeadMusic::Rudiment::RhythmicValue.get(:dotted_half)

Instance Method Summary collapse

Constructor Details

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

Instance Method Details

#check_final_bar(bar_number) ⇒ Object (private)



30
31
32
33
34
35
# File 'lib/head_music/style/guidelines/three_to_one.rb', line 30

def check_final_bar(bar_number)
  bar_notes = notes_in_bar(bar_number)
  return if one_dotted_half_note?(bar_notes)

  mark_bar(bar_number)
end

#check_first_bar(bar_number) ⇒ Object (private)



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

def check_first_bar(bar_number)
  bar_notes = notes_in_bar(bar_number)
  bar_rests = rests_in_bar(bar_number)
  return if three_quarter_notes?(bar_notes)
  return if rest_then_two_quarter_notes?(bar_notes, bar_rests)
  return if two_quarter_notes_after_downbeat?(bar_notes)

  mark_bar(bar_number)
end

#check_middle_bar(bar_number) ⇒ Object (private)



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

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

  mark_bar(bar_number)
end

#one_dotted_half_note?(bar_notes) ⇒ Boolean (private)

Returns:

  • (Boolean)


54
55
56
# File 'lib/head_music/style/guidelines/three_to_one.rb', line 54

def one_dotted_half_note?(bar_notes)
  bar_notes.length == 1 && bar_notes.first.rhythmic_value == DOTTED_HALF
end

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

Returns:

  • (Boolean)


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

def rest_then_two_quarter_notes?(bar_notes, bar_rests)
  bar_notes.length == 2 &&
    bar_notes.all? { |note| note.rhythmic_value == QUARTER } &&
    bar_rests.length == 1 &&
    bar_rests.first.rhythmic_value == QUARTER
end

#three_quarter_notes?(bar_notes) ⇒ Boolean (private)

Returns:

  • (Boolean)


37
38
39
# File 'lib/head_music/style/guidelines/three_to_one.rb', line 37

def three_quarter_notes?(bar_notes)
  bar_notes.length == 3 && bar_notes.all? { |note| note.rhythmic_value == QUARTER }
end

#two_quarter_notes_after_downbeat?(bar_notes) ⇒ Boolean (private)

Returns:

  • (Boolean)


48
49
50
51
52
# File 'lib/head_music/style/guidelines/three_to_one.rb', line 48

def two_quarter_notes_after_downbeat?(bar_notes)
  bar_notes.length == 2 &&
    bar_notes.all? { |note| note.rhythmic_value == QUARTER } &&
    bar_notes.first.position.count > 1
end