Class: Musa::MusicXML::Builder::Internal::Forward 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 advance without producing sound.
Forward moves the musical timeline forward by a specified duration without generating notes or rests. It's used for positioning within multi-voice contexts and creating invisible space.
Use Cases
Voice Positioning: Advance to a specific point in time before adding notes in a particular voice.
Invisible Rests: Skip time without displaying rest symbols (useful in multi-voice scenarios where another voice fills the space).
Rhythmic Offset: Start a voice partway through a measure without explicit rest notation.
Duration Units
Duration is specified in the measure's division units (not note values). If divisions=4, then duration=2 means 2 divisions = 1 eighth note.
Voice and Staff
Optional voice and staff parameters indicate which voice/staff the forward applies to. This helps notation software correctly position subsequent notes.
Instance Attribute Summary collapse
-
#duration ⇒ Integer
private
Duration to advance in division units.
-
#staff ⇒ Integer?
private
Staff number (for multi-staff instruments).
-
#voice ⇒ Integer?
private
Voice number (for multi-voice contexts).
Instance Method Summary collapse
-
#_to_xml(io, indent:, tabs:) ⇒ void
private
Generates the forward XML element.
-
#initialize(duration, voice: nil, staff: nil) ⇒ Forward
constructor
private
Creates a forward (timeline advance).
-
#to_xml(io = nil, indent: nil) ⇒ IO, StringIO
included
from Helper::ToXML
private
Converts the object to MusicXML format.
Constructor Details
#initialize(duration, voice: nil, staff: nil) ⇒ Forward
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 forward (timeline advance).
178 179 180 181 182 |
# File 'lib/musa-dsl/musicxml/builder/backup-forward.rb', line 178 def initialize(duration, voice: nil, staff: nil) @duration = duration @voice = voice @staff = staff 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 advance in division units.
186 187 188 |
# File 'lib/musa-dsl/musicxml/builder/backup-forward.rb', line 186 def duration @duration end |
#staff ⇒ 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.
Staff number (for multi-staff instruments).
194 195 196 |
# File 'lib/musa-dsl/musicxml/builder/backup-forward.rb', line 194 def staff @staff end |
#voice ⇒ 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.
Voice number (for multi-voice contexts).
190 191 192 |
# File 'lib/musa-dsl/musicxml/builder/backup-forward.rb', line 190 def voice @voice 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 forward XML element.
204 205 206 207 208 209 210 211 212 |
# File 'lib/musa-dsl/musicxml/builder/backup-forward.rb', line 204 def _to_xml(io, indent:, tabs:) io.puts "#{tabs}<forward>" io.puts "#{tabs}\t<duration>#{@duration.to_i}</duration>" io.puts "#{tabs}\t<voice>#{@voice.to_i}</voice>" if @voice io.puts "#{tabs}\t<staff>#{@staff.to_i}</staff>" if @staff io.puts "#{tabs}</forward>" 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.