Class: Musa::MusicXML::Builder::Internal::Backup Private
- Includes:
- Helper::ToXML
- Defined in:
- lib/musa-dsl/musicxml/builder/backup-forward.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Timeline rewind for polyphonic music.
Backup moves the musical timeline backwards by a specified duration, allowing overlapping musical content to be written sequentially. This is essential for polyphonic music where multiple voices or staves play simultaneously.
Use Cases
Multiple Voices: Write voice 1, backup, then write voice 2 starting at the same timepoint.
Multi-Staff Instruments: Write treble staff notes, backup, then write bass staff notes for the same measure.
Polyphonic Textures: Layer independent melodic lines that share temporal alignment.
Duration Units
Duration is specified in the measure's division units (not note values). If divisions=4, then duration=8 means 8 divisions = 2 quarter notes = 1 half note.
Common pattern: backup by the full measure duration to restart from the beginning of the measure.
Workflow Example
- Write notes for voice 1
- Backup to measure start
- Write notes for voice 2 (with voice: 2 parameter)
- Optionally backup again for additional voices
Instance Attribute Summary collapse
-
#duration ⇒ Integer
private
Duration to rewind in division units.
Instance Method Summary collapse
-
#_to_xml(io, indent:, tabs:) ⇒ void
private
Generates the backup XML element.
-
#initialize(duration) ⇒ Backup
constructor
private
Creates a backup (timeline rewind).
-
#to_xml(io = nil, indent: nil) ⇒ IO, StringIO
included
from Helper::ToXML
private
Converts the object to MusicXML format.
Constructor Details
#initialize(duration) ⇒ Backup
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a backup (timeline rewind).
86 87 88 |
# File 'lib/musa-dsl/musicxml/builder/backup-forward.rb', line 86 def initialize(duration) @duration = duration end |
Instance Attribute Details
#duration ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Duration to rewind in division units.
92 93 94 |
# File 'lib/musa-dsl/musicxml/builder/backup-forward.rb', line 92 def duration @duration end |
Instance Method Details
#_to_xml(io, indent:, tabs:) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Generates the backup XML element.
102 103 104 |
# File 'lib/musa-dsl/musicxml/builder/backup-forward.rb', line 102 def _to_xml(io, indent:, tabs:) io.puts "#{tabs}<backup><duration>#{@duration.to_i}</duration></backup>" end |
#to_xml(io = nil, indent: nil) ⇒ IO, StringIO Originally defined in module Helper::ToXML
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts the object to MusicXML format.
This method sets up the IO stream and indentation, then delegates to
the private _to_xml method for actual XML generation.