class MIDI::Tempo

Constants

MICROSECS_PER_MINUTE

Public Class Methods

bpm_to_mpq(bpm) click to toggle source

Translates beats per minute to microseconds per quarter note (beat).

# File lib/midilib/event.rb, line 509
def self.bpm_to_mpq(bpm)
  MICROSECS_PER_MINUTE / bpm
end
mpq_to_bpm(mpq) click to toggle source

Translates microseconds per quarter note (beat) to beats per minute.

# File lib/midilib/event.rb, line 514
def self.mpq_to_bpm(mpq)
  MICROSECS_PER_MINUTE.to_f / mpq.to_f
end
new(msecs_per_qnote, delta_time = 0) click to toggle source
Calls superclass method MIDI::MetaEvent::new
# File lib/midilib/event.rb, line 518
def initialize(msecs_per_qnote, delta_time = 0)
  super(META_SET_TEMPO, msecs_per_qnote, delta_time)
end

Public Instance Methods

data_as_bytes() click to toggle source
# File lib/midilib/event.rb, line 530
def data_as_bytes
  data = []
  data << @status
  data << @meta_type
  data << 3
  data << ((@data >> 16) & 0xff)
  data << ((@data >> 8) & 0xff)
  data << (@data & 0xff)
end
tempo() click to toggle source
# File lib/midilib/event.rb, line 522
def tempo
  @data
end
tempo=(val) click to toggle source
# File lib/midilib/event.rb, line 526
def tempo=(val)
  @data = val
end
to_s() click to toggle source
# File lib/midilib/event.rb, line 540
def to_s
  "tempo #{@data} msecs per qnote (#{Tempo.mpq_to_bpm(@data)} bpm)"
end