Reputation: 9
I'm trying to get pygame to run in a bigger script to play multiple overlapping audios based of key presses, basically to simulate a piano. However, I keep getting the error pygame.error: ALSA: Couldn't open audio device: Unknown error 524
whenever I call pygame.mixer.init()
. I isolated the code to see if it was a problem with the larger script but I receive the same error on the same line:
import pygame
pygame.mixer.init() # <- error
sound = pygame.mixer.Sound('audio_1.wav')
sound.play()
while pygame.mixer.get_busy():
pygame.time.delay(100)
I'm running this on a Raspi 3b+ with Bookworm installed. I'm using the latest version of pygame. As far as audio devices connected, I'm using the 3.5mm audio jack connected to a fossi audio which runs to a speaker with speaker wire. I've tried troubleshooting this to no avail by setting amixer cset numid=3 1
and restarting the ALSA daemon.
I've tested random audi files with the aplay
command and everything plays perfectly fine through the speaker setup. I've also tested with random WAV files I grabbed from online to make sure that it's not my audio files that are corrupted.
I'm pretty inexperienced with audio settings and configs so if it's something very simple I apologize in advance but I've used this setup with omxplayer in the past and had success, so I'm struggling to see what I'm doing wrong here.
Upvotes: 0
Views: 18