Class: Musa::MusicXML::Builder::Internal::Tuplet Private
- Includes:
- Helper, ToXML
- Defined in:
- lib/musa-dsl/musicxml/builder/note-complexities.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.
Visual tuplet bracket and number notation.
Tuplet controls the visual appearance of tuplet markings: brackets, numbers, and note type indications. Unlike TimeModification, which affects playback timing, Tuplet is purely visual.
Components
Type
- start: Begin tuplet bracket/number
- stop: End tuplet bracket/number
Multiple tuplets can overlap using different number attributes.
Bracket
- true: Show bracket
- false/nil: Hide bracket (use number only)
Common practice: show brackets for beam-breaking tuplets, hide for beamed.
Number Display
show_number:
- 'actual': Show only actual number (e.g., "3")
- 'both': Show ratio (e.g., "3:2")
- 'none': Hide number
show_type:
- 'actual': Show note type for actual notes
- 'both': Show note types for both
- 'none': Hide note types
Actual/Normal Specification
Optional detailed specification of tuplet appearance:
- actual_number/actual_type/actual_dots: Actual notes representation
- normal_number/normal_type/normal_dots: Normal notes representation
Typically inferred from TimeModification and note properties.
Typical Usage
Most tuplets only need type (start/stop) and optionally bracket:
Tuplet.new(type: 'start', bracket: true) # First note of triplet
Tuplet.new(type: 'stop') # Last note of triplet
Instance Attribute Summary collapse
-
#actual_dots ⇒ Integer?
private
Actual augmentation dots for display.
-
#actual_number ⇒ Integer?
private
Actual number for display.
-
#actual_type ⇒ String?
private
Actual note type for display.
-
#bracket ⇒ Boolean?
private
Show bracket.
-
#normal_dots ⇒ Integer?
private
Normal augmentation dots for display.
-
#normal_number ⇒ Integer?
private
Normal number for display.
-
#normal_type ⇒ String?
private
Normal note type for display.
-
#number ⇒ Integer?
private
Tuplet number for nesting.
-
#show_number ⇒ String?
private
Number display mode.
-
#show_type ⇒ String?
private
Note type display mode.
-
#type ⇒ String
private
Tuplet type ('start' or 'stop').
Instance Method Summary collapse
-
#_to_xml(io, indent:, tabs:) ⇒ void
private
Generates the tuplet XML element.
-
#initialize(type:, number: nil, bracket: nil, show_number: nil, show_type: nil, actual_number: nil, actual_type: nil, actual_dots: nil, normal_number: nil, normal_type: nil, normal_dots: nil) ⇒ Tuplet
constructor
private
Creates a tuplet notation.
Constructor Details
#initialize(type:, number: nil, bracket: nil, show_number: nil, show_type: nil, actual_number: nil, actual_type: nil, actual_dots: nil, normal_number: nil, normal_type: nil, normal_dots: nil) ⇒ Tuplet
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 tuplet notation.
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 216 def initialize(type:, # start / stop number: nil, # number bracket: nil, # true show_number: nil, # actual / both / none show_type: nil, # actual / both / none actual_number: nil, # number actual_type: nil, # quarter / eigth / ... actual_dots: nil, # number, normal_number: nil, # number normal_type: nil, # quarter / eigth / ... normal_dots: nil) # number @type = type @number = number @bracket = bracket @show_number = show_number @show_type = show_type @actual_number = actual_number @actual_type = actual_type @actual_dots = actual_dots @normal_number = normal_number @normal_type = normal_type @normal_dots = normal_dots end |
Instance Attribute Details
#actual_dots ⇒ 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.
Actual augmentation dots for display.
271 272 273 |
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 271 def actual_dots @actual_dots end |
#actual_number ⇒ 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.
Actual number for display.
263 264 265 |
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 263 def actual_number @actual_number end |
#actual_type ⇒ String?
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.
Actual note type for display.
267 268 269 |
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 267 def actual_type @actual_type end |
#bracket ⇒ Boolean?
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.
Show bracket.
251 252 253 |
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 251 def bracket @bracket end |
#normal_dots ⇒ 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.
Normal augmentation dots for display.
283 284 285 |
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 283 def normal_dots @normal_dots end |
#normal_number ⇒ 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.
Normal number for display.
275 276 277 |
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 275 def normal_number @normal_number end |
#normal_type ⇒ String?
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.
Normal note type for display.
279 280 281 |
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 279 def normal_type @normal_type end |
#number ⇒ 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.
Tuplet number for nesting.
247 248 249 |
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 247 def number @number end |
#show_number ⇒ String?
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.
Number display mode.
255 256 257 |
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 255 def show_number @show_number end |
#show_type ⇒ String?
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.
Note type display mode.
259 260 261 |
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 259 def show_type @show_type end |
#type ⇒ String
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.
Tuplet type ('start' or 'stop').
243 244 245 |
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 243 def type @type 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 tuplet XML element.
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 293 def _to_xml(io, indent:, tabs:) io.puts "#{tabs}<tuplet type=\"#{@type}\"" \ "#{decode_bool_or_string_attribute(@number&.to_i, 'number')}" \ "#{decode_bool_or_string_attribute(@bracket, 'bracket', 'yes', 'no')}" \ "#{decode_bool_or_string_attribute(@show_number, 'show-number')}" \ "#{decode_bool_or_string_attribute(@show_type, 'show-type')}" \ ">" if @actual_number || @actual_type || @actual_dots io.puts "#{tabs}\t<tuplet-actual>" io.puts "#{tabs}\t\t<tuplet-number>#{@actual_number.to_i}</tuplet-number>" if @actual_number io.puts "#{tabs}\t\t<tuplet-type>#{@actual_type}</tuplet-type>" if @actual_type @actual_dots&.times do io.puts "#{tabs}\t\t<tuplet-dot />" end io.puts "#{tabs}\t</tuplet-actual>" end if @normal_number || @normal_type || @normal_dots io.puts "#{tabs}\t<tuplet-normal>" io.puts "#{tabs}\t\t<tuplet-number>#{@normal_number.to_i}</tuplet-number>" if @normal_number io.puts "#{tabs}\t\t<tuplet-type>#{@normal_type}</tuplet-type>" if @normal_type @normal_dots&.times do io.puts "#{tabs}\t\t<tuplet-dot />" end io.puts "#{tabs}\t</tuplet-normal>" end io.puts "#{tabs}</tuplet>" end |