所以我用pygame做了一个游戏,我的问题是某种音效会以不同的速度播放。据我所知,只有两种速度,它会发挥正常,有时会发挥正常,另一次可能会显着更快。在
这里是我的代码的一些部分,我会包括更多,但我无法想象任何其他地方可能会出现问题。知道是什么引起的吗?在
pygame.mixer.pre_init(44000, -16, 2, 512)
pygame.mixer.init()
pygame.init()
一。在
^{pr2}$一。在
if stats1['chime'] == 'on':
playSound(rainbowPip, -1, 0, 200)
elif stats1['chime'] == 'off':
stopSound(rainbowPip)
谢谢。在
音频的速度可以通过改变采样率来改变。对于一个典型的wav文件,它可以是44100,可以加倍或减半来加速或减速。在
我没有你完整的代码,所以我创建了一个演示代码来解释这个概念。 在这里,输入音频文件
piano.wav
首先以正常速度播放,然后使其以两倍于原始速度运行。 请注意使用小于1的转换系数来减慢速度的选项。在希望你能在你的程序中使用这些代码。在
演示代码
程序输出
^{pr2}$相关问题 更多 >
编程相关推荐