Audio not working

January 21, 2023, 16:05

pamparampam.

So right now if i plug my headphones to jack on rpi3 and manualy play music, the sounds works great. But if instead play music from python program(using pygame) the sound not only is transmited via HDMI to speakers connected to screen, the sound quality is REALLy terrible How can i fix it so the audio is always transmited via jack? And also what about the sound quality?

andy_s

how do you play it? Show your code...

andy_s

(as a text)

pamparampam.

py
pygame.mixer.music.load("audio/" + videoId + ".mp3")
                            pygame.mixer.music.play()

pamparampam.

the code works fine

pamparampam.

it works, just the audio input is messed up when using python program cuz for no reason it gives signal to hdmi not jack

andy_s

run this first in shell amixer -c 0 cset numid=3 1

pamparampam.

the problem can be simplified: If u play sound manually(either by hand opening mp3 file or from browser) the sound is on jack But if i play it with python program using pygame.mixer the sound is on HDMI

pamparampam.

After debuging its worth mentioning that if i manually run the program the audio is on jack but if systemd runs the program then its on HDMI

andy_s

what user runs it with systemd?

andy_s

make sure this user has privileges