Class MIDI::IO::MIDIFile
In: lib/midilib/io/midifile.rb
Parent: Object

A MIDIFile parses a MIDI file and calls methods when it sees MIDI events. Most of the methods are stubs. To do anything interesting with the events, override these methods (those between the "The rest of these are NOPs by default" and "End of NOPs" comments).

See SeqReader for a subclass that uses these methods to create Event objects.

Methods

Constants

MThd_BYTE_ARRAY = [77, 84, 104, 100]
MTrk_BYTE_ARRAY = [77, 84, 114, 107]
NUM_DATA_BYTES = [ 0, 0, 0, 0, 0, 0, 0, 0, # 0x00 - 0x70 2, 2, 2, 2, 1, 1, 2, 0   This array is indexed by the high half of a status byte. Its value is either the number of bytes needed (1 or 2) for a channel message, or 0 if it‘s not a channel message.

Attributes

bytes_to_be_read  [RW] 
curr_ticks  [RW] 
no_merge  [RW] 
raw_data  [RW] 
raw_time_stamp_data  [RW]  Raw data info
raw_var_num_data  [RW] 
skip_init  [RW] 
ticks_so_far  [RW] 

Public Class methods

Public Instance methods

Handle an unexpected byte.

Handle a channel message (note on, note off, etc.)

The default error handler.

Return the next n bytes from @io as an array.

This default getc implementation tries to read a single byte from io and returns it as an integer.

Copy message into raw data array, then call arbitrary().

Copy message into raw data array, then call sysex().

Handle a meta event.

Return a copy of the internal message buffer.

Add a byte to the current message buffer.

Initialize the internal message buffer.

Read and add a number of bytes to the message buffer. Return the last byte (so we can see if it‘s an EOX or not).

Read and return a sixteen bit value.

Read and return a 32-bit value.

The only public method. Each MIDI event in the file causes a method to be called.

Read a header chunk.

Read through ‘MThd’ or ‘MTrk’ header string. If skip is true, attempt to skip initial trash. If there is an error, error is called.

Read a track chunk.

Read a varlen value.

Write a sixteen-bit value.

Write a 32-bit value.

Write a variable length value.

[Validate]