Here is a small test code that I had running on my RPi 3B+, that plays a sequence of notes, which worked with no issues:
from music21 import midi, stream, converter s = stream.Stream() for i in range(3): # Create a Note (MIDI note 60 is Middle C) note = Note(60+i) # Append the note to the stream s.append(note) sp = midi.realtime.StreamPlayer(s) sp.play() Running the same code on my RPi 5, I get the following:
Traceback (most recent call last): File "/home/musicgame/game/midi_test/play_midi.py", line 16, in <module> sp = midi.realtime.StreamPlayer(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/musicgame/game_env/lib/python3.11/site-packages/music21/midi/realtime.py", line 93, in __init__ pygame.mixer.init(mixerFreq, mixerBitSize, mixerChannels, mixerBuffer) pygame.error: ALSA: Couldn't open audio device: Unknown error 524 I am currently working remotely on the RPi, and I needed to test this to make sure it works. There are currently no HDMI devices connected to the Pi, and no USB to jack device connected (if that helps).
Any ideas on how to resolve the issue?