'Pygame bad sound quality
Im trying to play a backround music in pygame but the qualtiy is kinda bad, altough if i play the the mp3 file outside python, for example in vlc, the sound quality is perfectly fine, so there is no issue with the file itself / my headset. this is the code that i used to play the song:
mixer.music.load("song.mp3")
mixer.music.set_volume(0.6)
mixer.music.play(-1)
any ideas how to fix it?
Solution 1:[1]
Try using pygame.mixer.init()
For example:
pygame.mixer.init(44100, -16, 2, 2048) # (frequency, size, channels, buffer)
It's possible that a low buffer size is attributing to a poor audio quality. Play around with the values.
Read up on mixer.init here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Yuuty |
