mingus.midi.midi_track¶
Methods for working with MIDI data as bytes.
The MIDI file format specification I used can be found here: http://www.sonicspot.com/guide/midifiles.html
-
class
mingus.midi.midi_track.
MidiTrack
[source]¶ -
-
bpm
¶ Attribute of type: int
120
-
change_instrument
¶ Attribute of type: bool
False
-
controller_event
(self, channel, contr_nr, contr_val)[source]¶ Return the bytes for a MIDI controller event.
-
delay
¶ Attribute of type: int
0
-
delta_time
¶ Attribute of type: str
'\x00'
-
get_midi_data
(self)[source]¶ Return the MIDI data in bytes for this track.
Include header, track_data and the end of track meta event.
-
header
(self)[source]¶ Return the bytes for the header of track.
The header contains the length of the track_data, so you’ll have to call this function when you’re done adding data (when you’re not using get_midi_data).
-
instrument
¶ Attribute of type: int
1
-
int_to_varbyte
(self, value)[source]¶ Convert an integer into a variable length byte.
How it works: the bytes are stored in big-endian (significant bit first), the highest bit of the byte (mask 0x80) is set when there are more bytes following. The remaining 7 bits (mask 0x7F) are used to store the value.
-
midi_event
(self, event_type, channel, param1, param2=None)[source]¶ Convert and return the paraters as a MIDI event in bytes.
-
play_Note
(self, note)[source]¶ Convert a Note object to a midi event and adds it to the track_data.
To set the channel on which to play this note, set Note.channel, the same goes for Note.velocity.
-
play_NoteContainer
(self, notecontainer)[source]¶ Convert a mingus.containers.NoteContainer to the equivalent MIDI events and add it to the track_data.
Note.channel and Note.velocity can be set as well.
-
play_Track
(self, track)[source]¶ Convert a Track object to MIDI events and write them to the track_data.
-
program_change_event
(self, channel, instr)[source]¶ Return the bytes for a program change controller event.
-
set_deltatime
(self, delta_time)[source]¶ Set the delta_time.
Can be an integer or a variable length byte.
-
set_instrument
(self, channel, instr, bank=1)[source]¶ Add a program change and bank select event to the track_data.
-
stop_NoteContainer
(self, notecontainer)[source]¶ Add note_off events for each note in the NoteContainer to the track_data.
-
track_data
¶ Attribute of type: str
''
-
-
mingus.midi.midi_track.
BALANCE
¶ Attribute of type: int
8
-
mingus.midi.midi_track.
BANK_SELECT
¶ Attribute of type: int
0
-
mingus.midi.midi_track.
BREATH_CONTROLLER
¶ Attribute of type: int
2
-
mingus.midi.midi_track.
CHANNEL_AFTERTOUCH
¶ Attribute of type: int
13
-
mingus.midi.midi_track.
CONTROLLER
¶ Attribute of type: int
11
-
mingus.midi.midi_track.
COPYRIGHT_NOTICE
¶ Attribute of type: str
'\x02'
-
mingus.midi.midi_track.
CUE_POINT
¶ Attribute of type: str
'\x07'
-
mingus.midi.midi_track.
DATA_ENTRY_MSB
¶ Attribute of type: int
6
-
mingus.midi.midi_track.
EFFECT_CONTROL_1
¶ Attribute of type: int
12
-
mingus.midi.midi_track.
EFFECT_CONTROL_2
¶ Attribute of type: int
13
-
mingus.midi.midi_track.
END_OF_TRACK
¶ Attribute of type: str
'/'
-
mingus.midi.midi_track.
EXPRESSION_CONTROLLER
¶ Attribute of type: int
11
-
mingus.midi.midi_track.
FILE_HEADER
¶ Attribute of type: str
'MThd'
-
mingus.midi.midi_track.
FOOT_CONTROLLER
¶ Attribute of type: int
4
-
mingus.midi.midi_track.
INSTRUMENT_NAME
¶ Attribute of type: str
'\x04'
-
mingus.midi.midi_track.
KEY_SIGNATURE
¶ Attribute of type: str
'Y'
-
mingus.midi.midi_track.
LYRICS
¶ Attribute of type: str
'\x05'
-
mingus.midi.midi_track.
MAIN_VOLUME
¶ Attribute of type: int
7
-
mingus.midi.midi_track.
MARKER
¶ Attribute of type: str
'\x06'
-
mingus.midi.midi_track.
META_EVENT
¶ Attribute of type: str
'\xff'
-
mingus.midi.midi_track.
MIDI_CHANNEL_PREFIX
¶ Attribute of type: str
' '
-
mingus.midi.midi_track.
MODULATION
¶ Attribute of type: int
1
-
mingus.midi.midi_track.
NOTE_AFTERTOUCH
¶ Attribute of type: int
10
-
mingus.midi.midi_track.
NOTE_OFF
¶ Attribute of type: int
8
-
mingus.midi.midi_track.
NOTE_ON
¶ Attribute of type: int
9
-
mingus.midi.midi_track.
PAN
¶ Attribute of type: int
10
-
mingus.midi.midi_track.
PITCH_BEND
¶ Attribute of type: int
14
-
mingus.midi.midi_track.
PORTAMENTO_TIME
¶ Attribute of type: int
5
-
mingus.midi.midi_track.
PROGRAM_CHANGE
¶ Attribute of type: int
12
-
mingus.midi.midi_track.
SEQUENCE_NUMBER
¶ Attribute of type: str
'\x00'
-
mingus.midi.midi_track.
SET_TEMPO
¶ Attribute of type: str
'Q'
-
mingus.midi.midi_track.
SMPTE_OFFSET
¶ Attribute of type: str
'T'
-
mingus.midi.midi_track.
TEXT_EVENT
¶ Attribute of type: str
'\x01'
-
mingus.midi.midi_track.
TIME_SIGNATURE
¶ Attribute of type: str
'X'
-
mingus.midi.midi_track.
TRACK_HEADER
¶ Attribute of type: str
'MTrk'
-
mingus.midi.midi_track.
TRACK_NAME
¶ Attribute of type: str
'\x03'
-
mingus.midi.midi_track.
major_keys
¶ Attribute of type: list
['Cb', 'Gb', 'Db', 'Ab', 'Eb', 'Bb', 'F', 'C', 'G', 'D', 'A', 'E', 'B', 'F#', 'C#']
-
mingus.midi.midi_track.
minor_keys
¶ Attribute of type: list
['ab', 'eb', 'bb', 'f', 'c', 'g', 'd', 'a', 'e', 'b', 'f#', 'c#', 'g#', 'd#', 'a#']