Structure
This documentation covers the internal representations of MIDI constructs, such as Headers, Events e.t.c.
Represents a MIDI file header
int – length in bytes of the file, minus the length of the header
int – Type of MIDI file, can be one of 0, 1 or 2. 0 and 1 are single file MIDI songs, 2 is comprised
of multiple files
int – Number of Track
‘s in the file
float – Ticks per quarter note
-
class
Event
(data: int) → None
Metaclass representing a MIDI Event. Subclasses must implement the _process()
function
-
event_name
str – Name of event
-
indicator_byte
int – Byte that indicates the MIDI Event type
-
raw_data
int – Initial data from MIDI file
-
_process
(data: int) → None
Processes the given data. Data is in the form of the remaining bytes in the file
Called internally by __init__
Parameters: | data (int) – Data given to be processed. |
-
classmethod
valid
(data: int) → bool
Used by the parser to determine if the event is applicable
:param data: bytes of event
:type data: int
Returns: | Whether the event matches or not |
Return type: | bool |
-
class
Track
(data: typing.Union[_io.FileIO, _io.BufferedReader]) → None
Represents a MIDI track
-
track_number
int – Track index. Must be 0 or more
-
length
int – Length of the track in bytes
-
events
List[Event] – List of events present in the track
-
class
VariableLengthValue
(file_io: typing.Union[_io.BufferedReader, _io.FileIO]) → None
Parses and stores a MIDI variable length value
-
length
int – Length, in bytes, of value
-
raw_data
bytearray – raw data read from file
-
value
int – Final parsed value