Class MIDI::Sequence
In: lib/midilib/sequence.rb
Parent: Object

A MIDI::Sequence contains MIDI::Track objects.

Methods

Included Modules

Enumerable

Constants

UNNAMED = 'Unnamed Sequence'
DEFAULT_TEMPO = 120
NOTE_TO_LENGTH = { 'whole' => 4.0, 'half' => 2.0, 'quarter' => 1.0, 'eighth' => 0.5, '8th' => 0.5, 'sixteenth' => 0.25, '16th' => 0.25, 'thirty second' => 0.125, 'thirtysecond' => 0.125, '32nd' => 0.125, 'sixty fourth' => 0.0625, 'sixtyfourth' => 0.0625, '64th' => 0.0625

Attributes

clocks  [RW] 
denom  [RW] 
format  [RW]  The MIDI file format (0, 1, or 2)
numer  [RW] 
ppqn  [RW]  Pulses (i.e. clocks) Per Quarter Note resolution for the sequence
qnotes  [RW] 
reader_class  [RW]  The class to use for reading MIDI from a stream. The default is MIDI::IO::SeqReader. You can change this at any time.
tracks  [RW]  Array with all tracks for the sequence
writer_class  [RW]  The class to use for writeing MIDI from a stream. The default is MIDI::IO::SeqWriter. You can change this at any time.

Public Class methods

Public Instance methods

Returns the song tempo in beats per minute.

bpm()

Alias for beats_per_minute

Iterates over the tracks.

Returns a Measures object, which is an array container for all measures in the sequence

Translates length (a multiple of a quarter note) into a delta time. For example, 1 is a quarter note, 1.0/32.0 is a 32nd note, 1.5 is a dotted quarter, etc. Be aware when using division; 1/32 is zero due to integer mathematics and rounding. Use floating-point numbers like 1.0 and 32.0. This method always returns an integer.

See also note_to_delta and note_to_length.

Returns the name of the first track (track zero). If there are no tracks, returns UNNAMED.

Hands the name to the first track. Does nothing if there are no tracks.

Given a note length name like "whole", "dotted quarter", or "8th triplet", return the length of that note in quarter notes as a delta time.

Given a note length name like "whole", "dotted quarter", or "8th triplet", return the length of that note in quarter notes as a floating-point number, suitable for use as an argument to length_to_delta.

Legal names are any value in NOTE_TO_LENGTH, optionally prefixed by "dotted_" and/or suffixed by "_triplet". So, for example, "dotted_quarter_triplet" returns the length of a dotted quarter-note triplet and "32nd" returns 1/32.

tempo()

Alias for beats_per_minute

[Validate]