Class MIDI::Track
In: lib/midilib/track.rb
Parent: Object

A Track is a list of events.

When you modify the events array, make sure to call recalc_times so each Event gets its time_from_start recalculated.

A Track also holds a bitmask that specifies the channels used by the track. This bitmask is set when the track is read from the MIDI file by an IO::SeqReader but is not kept up to date by any other methods.

Methods

Included Modules

Enumerable

Constants

UNNAMED = 'Unnamed'

Attributes

channels_used  [RW] 
events  [RW] 
instrument  [RW] 
sequence  [R] 

Public Class methods

Public Instance methods

Iterate over events.

Merges an array of events into our event list. After merging, the events’ time_from_start values are correct so you don’t need to worry about calling recalc_times.

Merges two event arrays together. Does not modify this track.

Return track name. If there is no name, return UNNAMED.

Set track name. Replaces or creates a name meta-event.

Quantize every event. length_or_note is either a length (1 = quarter, 0.25 = sixteenth, 4 = whole note) or a note name ("sixteenth", "32nd", "8th triplet", "dotted quarter").

Since each event’s time_from_start is modified, we call recalc_delta_from_times after each event quantizes itself.

The opposite of recalc_times: recalculates delta_time for each event from each event’s time_from_start. This is useful, for example, when merging two event lists. As a side-effect, elements from starting_at are sorted by time_from_start.

Recalculate start times for all events in list from starting_at to end.

Sort events by their time_from_start. After sorting, recalc_delta_from_times is called to make sure that the delta times reflect the possibly new event order.

[Validate]