Expand description
music21’s midi.translate below any score object: what a note, a chord,
an instrument, a meter, a key or a tempo is as MIDI events, and what
such events say back, timed in ticks.
The events are laid out in the order music21’s translating functions
list them, each delta time before the event it times, so that a caller
building music21’s event objects builds the same list. The file reader
and writer (from_midi, to_midi)
use the same encodings.
Structs§
- Channel
Plan - Which channel each program plays on, and the channels left over to
bend microtones on: music21’s
channelInstrumentData. - Misplaced
- An instrument that named a channel the plan could not give it, and was put on the first channel instead.
- Played
- An instrument as channels are planned from it: its program and the channel it names, counted from nought as music21 counts it.
- Sounding
- A key sounding: which, bent by how many cents, how loud.
- Timed
Note - A note as events time it.
Enums§
- Deltas
- Whether a list of events carries a delta time before each:
music21’s
includeDeltaTime. - EndDelay
- Whether a track ends a quarter after its last event: music21’s
addEndDelay. - Laid
- One entry of a translated list: a delta time or an event.
- Mode
- A key’s mode as MIDI writes it.
- Note
Mark - What an event is to a note: one starting or ending, keyed by its pitch and channel, or neither.
- Source
- What an instrument is read from: music21’s
midiEventToInstrument. - Start
Delay - Whether the first note waits a quarter: music21’s
addStartDelay. - Unsupported
- An event of music21’s text notation for MIDI that is not a note: its status, as written.
Constants§
- DEFAULT_
STROKE_ KEY - The key a stroke sounds on where nothing names one.
- PERCUSSION_
CHANNEL - The channel General MIDI keeps for drums, counted from one.
- TICKS_
AT_ START - music21’s
defaults.ticksAtStart: the delay before the first note and after the last, a quarter. - TICKS_
PER_ QUARTER - music21’s
defaults.ticksPerQuarter, its MusicXML divisions.
Functions§
- ascii_
file - A file written from music21’s text notation for MIDI, and the events
it left out: music21’s
midiAsciiStringToBinaryString. - chord_
events - A chord’s events: its lyric, every note-on, then every note-off, the
first
tickslater: music21’schordToMidiEvents, whose note-ons are all on the first channel whatever channel it is given. - duration_
ticks - A length in quarters as ticks: music21’s
durationToMidiTicks. - end_
events - What a track ends with: music21’s
getEndEvents. - event_
ticks - Each event paired with the tick it falls on, from a list of delta times
(
Some) and events (None): music21’sgetTimeForEvents. An event counts only right after a delta time; anything out of that order is passed over. The answer is each event’s tick and its place in the list. - instrument_
of - The instrument an event names, on its channel: music21’s
midiEventToInstrument. A name is cut at its first nul, as MuseScore ends them so, and kept as the part’s or instrument’s name unless it is a placeholder. - key_
data - The two bytes of a key: sharps, flats below nought, then the mode.
- key_
events - A key’s events. music21 names no channel on it.
- key_of
- The sharps and mode a key’s bytes say: music21’s
midiEventsToKey, which reads a first byte past twelve as flats. - meter_
data - The four bytes of a meter, or nothing for a numerator MIDI cannot
hold: music21’s
timeSignatureToMidiEvents. - meter_
events - A meter’s events, none where MIDI cannot hold it.
- meter_
of - The numerator and denominator a meter’s bytes say, or nothing for too
few bytes or a denominator past counting: music21’s
midiEventsToTimeSignature. - note_
events - A note’s events: its lyric where it has one, the note-on and the
note-off
tickslater: music21’snoteToMidiEvents. - notes_
of - Each note-on with the nearest note-off of its key after it, in the
order they start: music21’s
getNotesFromEvents. A note-on with no note-off after it is dropped. - offset_
ticks - An offset in ticks, a quarter later with the start delay: music21’s
offsetToMidiTicks, rounding as Python rounds. - percussion_
instrument - The instrument a percussion key plays, a tambourine taken to be
headless: music21’s
_midiNumberToPercussionInstrument. - plan_
channels - The channels for the instruments of each part (a conductor’s left
out), on
acceptablechannels counted from one, every channel but the drums’ where none are given: music21’schannelInstrumentData. - program_
events - A program change: music21’s
instrumentToMidiEvents. - source_
of - The source an event’s type and data name, for
instrument_of. - start_
events - What a track starts with: its name, then its program where it has one:
music21’s
getStartEvents. - status_
name - The name music21 gives a channel message’s status, for a warning.
- tempo_
data - The three bytes of a tempo of so many quarters a minute: the microseconds a quarter lasts.
- tempo_
events - A tempo’s events.
- tempo_
of - The quarters a minute a tempo’s bytes say, to two places, or nothing
for too few bytes or a quarter lasting no time: music21’s
midiEventsToTempo.