I can play and hear midi files on macOS with:
timidity song.mid
So I suppose my midi driver is working.
However, I can't hear any sound when playing with mido
. Here's my code:
import mido
def play(path: str):
file = mido.MidiFile(path)
with mido.open_output() as port:
for message in file.play():
port.send(message)
def list_devices():
print(mido.get_output_names())
# ['IAC Driver Bus 1', 'IAC Driver Bus 1'] if on macOS.
# ['Microsoft GS Wavetable Synth 0'] if on Windows.
if __name__ == '__main__':
play('song.mid')
# list_devices()
On macOS, it seems to be running, just inaudible. There is no error message.
On Windows, the same code runs perfectly and I can hear the music.
I wonder why mido
can't play on macOS. Does anyone have an idea how to make it work on macOS?