MIDI I/O Interface¶
-
muspy.
read_midi
(path: Union[str, pathlib.Path], backend: str = 'mido', duplicate_note_mode: str = 'fifo') → muspy.music.Music[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'}) – Backend to use.
- duplicate_note_mode ({'fifo', 'lifo, 'close_all'}) –
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. Defaults to ‘fifo’. Only used when backend=’mido’.
- ’fifo’ (first in first out): close the earliest note on
- ’lifo’ (first in first out):close the latest note on
- ’close_all’: close all note on messages
Returns: Converted Music object.
Return type: muspy.Music
object
-
muspy.
write_midi
(path: Union[str, pathlib.Path], music: Music, backend: str = '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
object) – Music object to write. - backend ({'mido', 'pretty_midi'}) – Backend to use. Defaults to ‘mido’.