简体   繁体   English

Pygame 音质不好

[英]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.我试图在 pygame 中播放背景音乐,但质量有点差,尽管如果我在 python 之外播放 mp3 文件,例如在 vlc 中,音质非常好,所以文件本身/我的没有问题耳机。 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?任何想法如何解决它?

Try using pygame.mixer.init()尝试使用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此处阅读mixer.init

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM