Skip to main content

Module translate

Module translate 

Source
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§

ChannelPlan
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.
TimedNote
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.
NoteMark
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.
StartDelay
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 ticks later: music21’s chordToMidiEvents, 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’s getTimeForEvents. 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 ticks later: music21’s noteToMidiEvents.
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 acceptable channels counted from one, every channel but the drums’ where none are given: music21’s channelInstrumentData.
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.