Class: Musa::MusicXML::Builder::Internal::Metronome Private

Inherits:
DirectionType
  • Object
show all
Includes:
Helper
Defined in:
lib/musa-dsl/musicxml/builder/direction.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.

Metronome tempo marking direction type.

Represents tempo markings with beat unit and metronome value (e.g., ♩ = 120). Supports dotted beat units.

Examples:

Quarter note = 120 BPM

measure.metronome beat_unit: 'quarter', per_minute: '120'

Dotted eighth = 90

measure.metronome beat_unit: 'eighth', beat_unit_dots: 1, per_minute: '90'

Instance Method Summary collapse

Constructor Details

#initialize(beat_unit:, beat_unit_dots: nil, per_minute:, &block) ⇒ Metronome

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.

TODO complete Metronome complexity!



239
240
241
242
243
244
245
246
247
248
249
# File 'lib/musa-dsl/musicxml/builder/direction.rb', line 239

def initialize(beat_unit:, # quarter / eighth / ...
               beat_unit_dots: nil, # number
               per_minute:, #string
               &block)

  @beat_unit = beat_unit
  @beat_unit_dots = beat_unit_dots
  @per_minute = per_minute

  super
end

Instance Method Details

#_direction_type_to_xml(io, indent:, tabs:) ⇒ Object

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.



255
256
257
258
259
260
261
262
263
264
265
# File 'lib/musa-dsl/musicxml/builder/direction.rb', line 255

def _direction_type_to_xml(io, indent:, tabs:)
  io.puts "#{tabs}<metronome>"

  io.puts "#{tabs}\t<beat-unit>#{@beat_unit}</beat-unit>"
  @beat_unit_dots&.times do
    io.puts "#{tabs}\t<beat-unit-dot />"
  end
  io.puts "#{tabs}\t<per-minute>#{@per_minute}</per-minute>"

  io.puts "#{tabs}</metronome>"
end