Class: HeadMusic::Style::Guidelines::NoteCountPerBar
- Inherits:
-
HeadMusic::Style::Guideline
- Object
- HeadMusic::Style::Guideline
- HeadMusic::Style::Guidelines::NoteCountPerBar
- Includes:
- HeadMusic::Style::Guideline::BarSpan
- Defined in:
- lib/head_music/style/guidelines/note_count_per_bar.rb
Overview
Checks that each middle bar (not first or last) contains an exact number of
notes of a given rhythmic value. Configurable via the count: and
rhythmic_value: options; subclasses may set COUNT and RHYTHMIC_VALUE defaults.
Judged over the voice's own bars, as SustainAcrossBarlines is, so a solo line
is held to it too.
Direct Known Subclasses
Class Method Summary collapse
-
.template_key ⇒ Object
One template for all four subclasses: they differ by count and unit, not by sentence.
- .template_values(config) ⇒ Object
Instance Method Summary collapse
- #body_bar_numbers ⇒ Object included from HeadMusic::Style::Guideline::BarSpan protected
- #check_middle_bar(bar_number) ⇒ Object private
- #count ⇒ Object private
- #downbeat_of(bar_number) ⇒ Object included from HeadMusic::Style::Guideline::BarSpan protected
- #first_bar_number ⇒ Object included from HeadMusic::Style::Guideline::BarSpan protected
- #last_bar_number ⇒ Object included from HeadMusic::Style::Guideline::BarSpan protected
- #mark_bar(bar_number) ⇒ Object included from HeadMusic::Style::Guideline::BarSpan protected
- #marks ⇒ Object
- #middle_bar_numbers ⇒ Object included from HeadMusic::Style::Guideline::BarSpan protected
- #notes_in_bar(bar_number) ⇒ Object included from HeadMusic::Style::Guideline::BarSpan protected
- #rhythmic_unit ⇒ Object private
- #rhythmic_value ⇒ Object private
Constructor Details
This class inherits a constructor from HeadMusic::Style::Guideline
Class Method Details
.template_key ⇒ Object
One template for all four subclasses: they differ by count and unit, not by sentence. Named explicitly so the subclasses do not each need an entry.
20 |
# File 'lib/head_music/style/guidelines/note_count_per_bar.rb', line 20 def self.template_key = "note_count_per_bar" |
.template_values(config) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/head_music/style/guidelines/note_count_per_bar.rb', line 22 def self.template_values(config) count = config.fetch(:count) { self::COUNT } unit = config.fetch(:rhythmic_value) { self::RHYTHMIC_VALUE } { count: count, number: HeadMusic::Style::Template.number_word(count), # Pluralized because British names the value with a noun and drops the # "note" the American sentence carries: four crotchets, not four crotchet # notes. English's entries stay scalar, which I18n reads past the count. rhythmic_unit: HeadMusic::Style::Template.pluralize( "rhythmic_units.#{unit}", count: count, scope: HeadMusic::Style::Template::RUDIMENT_SCOPE ) } end |
Instance Method Details
#body_bar_numbers ⇒ Object (protected) Originally defined in module HeadMusic::Style::Guideline::BarSpan
#check_middle_bar(bar_number) ⇒ Object (private)
51 52 53 54 55 56 |
# File 'lib/head_music/style/guidelines/note_count_per_bar.rb', line 51 def () = () return if .length == count && .all? { |note| note.rhythmic_value == rhythmic_value } () end |
#count ⇒ Object (private)
39 40 41 |
# File 'lib/head_music/style/guidelines/note_count_per_bar.rb', line 39 def count .fetch(:count) { self.class::COUNT } end |
#downbeat_of(bar_number) ⇒ Object (protected) Originally defined in module HeadMusic::Style::Guideline::BarSpan
#first_bar_number ⇒ Object (protected) Originally defined in module HeadMusic::Style::Guideline::BarSpan
#last_bar_number ⇒ Object (protected) Originally defined in module HeadMusic::Style::Guideline::BarSpan
#mark_bar(bar_number) ⇒ Object (protected) Originally defined in module HeadMusic::Style::Guideline::BarSpan
#marks ⇒ Object
12 13 14 15 16 |
# File 'lib/head_music/style/guidelines/note_count_per_bar.rb', line 12 def marks return [] if notes.empty? .filter_map { || () } end |
#middle_bar_numbers ⇒ Object (protected) Originally defined in module HeadMusic::Style::Guideline::BarSpan
#notes_in_bar(bar_number) ⇒ Object (protected) Originally defined in module HeadMusic::Style::Guideline::BarSpan
#rhythmic_unit ⇒ Object (private)
43 44 45 |
# File 'lib/head_music/style/guidelines/note_count_per_bar.rb', line 43 def rhythmic_unit .fetch(:rhythmic_value) { self.class::RHYTHMIC_VALUE } end |
#rhythmic_value ⇒ Object (private)
47 48 49 |
# File 'lib/head_music/style/guidelines/note_count_per_bar.rb', line 47 def rhythmic_value @rhythmic_value ||= HeadMusic::Rudiment::RhythmicValue.get(rhythmic_unit) end |