Skip to main content

Module base

Module base 

Source
Expand description

music21’s midi.base: MIDI as bytes, below any score.

The numbers MIDI writes (big-endian and seven bits to a byte), the kinds of message, one event read off the front of a track’s data or written back, a track’s chunk, and a file’s header. What an event holds is kept as music21 keeps it: a type, a channel counted from one, and two parameters, the first of which may be bytes.

Structs§

FileHeader
A file’s header: its format, how many tracks follow, how it counts time.
ReadEvent
What reading an event sets on it: its type always, its channel and second parameter where the message has them, and its first parameter (music21’s data).
TrackEvent
One event of a track as read: the ticks since the one before, the running status it was read under and left, and what it set, None where too few bytes were left to read one.

Enums§

Division
How a file counts time.
EventType
What kind of message an event is, with its value in music21’s enum.
MidiDataError
What goes wrong with MIDI’s bytes, in music21’s words.
Param
What an event’s parameter or data holds.

Constants§

CHANNEL_MODE_MESSAGES
The controller numbers that set a channel’s mode.
CHANNEL_VOICE_MESSAGES
The messages of a channel, by music21’s names: the high nibble of the status byte.
FILE_HEADER
A file header’s tag.
METAEVENT_MARKER
The byte a meta event starts with.
META_EVENTS
The meta events, by the byte after METAEVENT_MARKER; UNKNOWN stands for any other.
SYSEX_EVENTS
The two system exclusive events.
TRACK_HEADER
A track chunk’s tag.

Functions§

event_bytes
An event as MIDI writes it, from its type, its channel counted from one and its two parameters: music21’s MidiEvent.getBytes.
file_header_bytes
A file’s header, for a format, a count of tracks and ticks to a quarter note.
get_number
The first length bytes as one big-endian number, and what follows.
get_variable_length_number
A number written seven bits to a byte, high bit set on all but the last, and what follows it.
is_note_off
Whether an event ends a note: a note-off, or a note-on of no velocity.
is_note_on
Whether an event sounds a note: a note-on of some velocity.
name_of
The name a table gives a value.
parse_channel_voice
A channel message off the front of bytes, and how many bytes it took: music21’s MidiEvent.parseChannelVoiceMessage.
pitch_bend
A pitch bend of so many cents, within a range of so many semitones, as the event’s two parameters, least significant first; beyond the range it is the range’s end.
put_number
A number as length big-endian bytes, only its low bytes kept where it is longer.
put_numbers_as_list
Numbers as one byte each, a negative one counted down from 256.
put_variable_length_number
The fewest bytes MIDI writes a number in, seven bits to a byte.
read_event
One event off the front of bytes, and how many of them it took: music21’s MidiEvent.read. A data byte first is read under the running status last, or a note-on’s where there is none. Fewer than two bytes are no event, and None.
read_file_header
A file’s header off the front of bytes, and what follows it. A format past 1 is refused, after it is read: the error carries it.
read_track
A track’s chunk off the front of bytes: its data, its events and what follows it. An event music21 cannot read is skipped, as music21 skips it.
sort_order
Where an event goes among those at one time: a note-off first, then a pitch bend, then the rest.
split_number
A number’s low length bytes, and the rest of it with those taken away: music21’s getNumber given a number.
status_after
The running status after an event whose first byte is first: a status byte other than a meta event’s replaces it.
track_bytes
A track’s chunk around its data.
track_events
A track’s data read into events.

Type Aliases§

MidiResult
Shorthand for this module’s results.