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]
__init__(self, start_bpm=120)[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'

end_of_track(self)[source]

Return the bytes for an end of track meta event.

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.

key_signature_event(self, key=C)[source]

Return the bytes for a key signature event.

midi_event(self, event_type, channel, param1, param2=None)[source]

Convert and return the paraters as a MIDI event in bytes.

note_off(self, channel, note, velocity)[source]

Return bytes for a ‘note off’ event.

note_on(self, channel, note, velocity)[source]

Return bytes for a ‘note_on’ event.

play_Bar(self, bar)[source]

Convert a Bar object to MIDI events and write them to the track_data.

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.

reset(self)[source]

Reset track_data and delta_time.

select_bank(self, channel, bank)[source]

Return the MIDI event for a select bank 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.

set_key(self, key=C)[source]

Add a key signature event to the track_data.

set_meter(self, meter=(4, 4))[source]

Add a time signature event for meter to track_data.

set_tempo(self, bpm)[source]

Convert the bpm to a midi event and write it to the track_data.

set_tempo_event(self, bpm)[source]

Calculate the microseconds per quarter note.

set_track_name(self, name)[source]

Add a meta event for the track.

stop_Note(self, note)[source]

Add a note_off event for note to event_track.

stop_NoteContainer(self, notecontainer)[source]

Add note_off events for each note in the NoteContainer to the track_data.

time_signature_event(self, meter=(4, 4))[source]

Return a time signature event for meter.

track_data

Attribute of type: str ''

track_name_event(self, name)[source]

Return the bytes for a track name meta event.


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#']


Back to Index