MIDI I/O Interface
- muspy.read_midi(path, backend='mido', duplicate_note_mode='fifo')[source]
Read a MIDI file into a Music object.
- Parameters
path (str or Path) – Path to the MIDI file to read.
backend ({'mido', 'pretty_midi'}, default: 'mido') – Backend to use.
duplicate_note_mode ({'fifo', 'lifo, 'all'}, default: 'fifo') –
Policy for dealing with duplicate notes. When a note off message is presetned while there are multiple correspoding note on messages that have not yet been closed, we need a policy to decide which note on messages to close. Only used when backend is ‘mido’.
’fifo’ (first in first out): close the earliest note on
’lifo’ (first in first out):close the latest note on
’all’: close all note on messages
- Returns
Converted Music object.
- Return type
- muspy.write_midi(path, music, backend='mido', **kwargs)[source]
Write a Music object to a MIDI file.
- Parameters
path (str or Path) – Path to write the MIDI file.
music (
muspy.Music
) – Music object to write.backend ({'mido', 'pretty_midi'}, default: 'mido') – Backend to use.
See also
write_midi_mido
Write a Music object to a MIDI file using mido as backend.
write_midi_pretty_midi
Write a Music object to a MIDI file using pretty_midi as backend.