Class: HeadMusic::Notation::LilyPond::DurationWriter
- Inherits:
-
Object
- Object
- HeadMusic::Notation::LilyPond::DurationWriter
- Defined in:
- lib/head_music/notation/lily_pond/duration_writer.rb
Overview
Converts one link of a rhythmic value into a LilyPond duration token. Ties between links are the caller’s concern (RenderPlan joins links with the tie mark), so this writer ignores tied_value.
Constant Summary collapse
- DURATIONS_BY_UNIT_NAME =
LilyPond durations are symbolic: a power-of-two number, or a named command for the values longer than a whole note.
{ "maxima" => "\\maxima", "longa" => "\\longa", "double whole" => "\\breve", "whole" => "1", "half" => "2", "quarter" => "4", "eighth" => "8", "sixteenth" => "16", "thirty-second" => "32", "sixty-fourth" => "64", "hundred twenty-eighth" => "128", "two hundred fifty-sixth" => "256" }.freeze
Class Method Summary collapse
Class Method Details
.token(rhythmic_value) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/head_music/notation/lily_pond/duration_writer.rb', line 24 def self.token(rhythmic_value) value = HeadMusic::Rudiment::RhythmicValue.get(rhythmic_value) base = DURATIONS_BY_UNIT_NAME.fetch(value.unit_name) do raise RenderError, "no LilyPond duration is known for a #{value.unit_name} note" end base + "." * value.dots end |