class MIDI::TimeSig
Container for time signature events
Public Class Methods
new(numer, denom, clocks, qnotes, delta_time = 0)
click to toggle source
Constructor
Calls superclass method
MIDI::MetaEvent::new
# File lib/midilib/event.rb, line 548 def initialize(numer, denom, clocks, qnotes, delta_time = 0) super(META_TIME_SIG, [numer, denom, clocks, qnotes], delta_time) end
Public Instance Methods
data_as_bytes()
click to toggle source
Returns the complete event as stored in the sequence
# File lib/midilib/event.rb, line 553 def data_as_bytes data = [] data << @status data << @meta_type data << 4 data << @data[0] data << @data[1] data << @data[2] data << @data[3] end
denominator()
click to toggle source
Returns the denominator of the time signature. Use it as a power of 2 to get the displayed (lower-part) digit of the time signature.
# File lib/midilib/event.rb, line 576 def denominator @data[1] end
measure_duration(ppqn)
click to toggle source
Calculates the duration (in ticks) for a full measure
# File lib/midilib/event.rb, line 565 def measure_duration(ppqn) (4 * ppqn * @data[0]) / (2**@data[1]) end
metronome_ticks()
click to toggle source
Returns the metronome tick duration for the time signature. On each quarter note, there’s 24 ticks.
# File lib/midilib/event.rb, line 582 def metronome_ticks @data[2] end
numerator()
click to toggle source
Returns the numerator (the top digit) for the time signature
# File lib/midilib/event.rb, line 570 def numerator @data[0] end
to_s()
click to toggle source
Returns the time signature for the event as a string. Example: “time sig 3/4”
# File lib/midilib/event.rb, line 588 def to_s "time sig #{@data[0]}/#{2**@data[1]}" end