简体   繁体   English

Python 3.9 Pygame 混频器频率改变不工作

[英]Python 3.9 Pygame mixer frequency change not working

I am using pygame (version = 2.0.1) in python==3.9.1 in windows OS laptop.我在 windows OS 笔记本电脑的 python==3.9.1 中使用 pygame(版本 = 2.0.1)。 I use the pygame.mixer module to play my mp3 file.我使用 pygame.mixer 模块来播放我的 mp3 文件。 My code:我的代码:

from time import sleep
from pygame import mixer

audio_length = 5.184

mixer.init(frequency=26500)
# mixer.init(frequency=44100)
mixer.music.load("Test.mp3")

mixer.music.play()
sleep(audio_length)
mixer.music.stop()

mixer.quit()

The above code works without errors.. BUT the audio is played at the same default frequency no matter what value I set in mixer.init().上面的代码可以正常工作。但是无论我在mixer.init()中设置什么值,音频都会以相同的默认频率播放。

This seems to be quite strange because the above code works perfectly fine (with frequency change) in python 3.7 and pygame 1.9.6这似乎很奇怪,因为上面的代码在 python 3.7 和 pygame 1.9.6 中运行良好(频率变化)

I realised this only after i thought about upgrading my python version.在我考虑升级我的 python 版本后,我才意识到这一点。

Is this a bug which I have to report?这是我必须报告的错误吗? In that case how do I proceed so?在那种情况下,我该如何进行?

Or... is it just that I'm not following the new way in python 3.9?或者......只是我没有遵循 python 3.9 中的新方法吗?

In case, the file I used for testing is required, you can download from https://drive.google.com/file/d/1vd7aO5ahFBHfoT97_0RSBU4reNAWseB6/view?usp=sharing如果需要我用于测试的文件,您可以从https://drive.google.com/file/d/1vd7aO5ahFBHfoT97_0RSBU4reNAWseB6/view?usp=sharing下载

Mixer init expects to also get the size and the channels, so you will have to do it like this: Mixer init 还希望获得大小和通道,因此您必须这样做:

mixer.init(frequency=26500, size=-16, channels=2)

For more info, see pygame docs: https://www.pygame.org/docs/ref/mixer.html#pygame.mixer.init有关详细信息,请参阅 pygame 文档: https://www.pygame.org/docs/ref/mixer.html#pygame.mixer.init

This is a known issue that hasn't been resolved as of today.这是一个已知问题,截至今天尚未解决。

https://github.com/pygame/pygame/issues/2435 https://github.com/pygame/pygame/issues/2435

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

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