pygame 音频播放速度 [英] pygame audio playback speed

查看:132
本文介绍了pygame 音频播放速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

快速提问.

我在 linux 下运行 pygame 只是为了播放一些音频文件.我有一些 .wav 文件,但无法以正确的速度播放它们.

I'm running pygame under linux just to play some audio files. I've got some .wav files and I'm having problems playing them back at the right speed.

import pygame.mixer, sys, time

#plays too fast
pygame.mixer.init(44100)
pygame.mixer.music.load(sys.argv[1])
pygame.mixer.music.play()
time.sleep(5)
pygame.mixer.quit()

#plays too slow
pygame.mixer.init(22100)
pygame.mixer.music.load(sys.argv[1])
pygame.mixer.music.play()
time.sleep(5)
pygame.mixer.quit()

我用 ggogle 代码搜索了一些东西,但每个人似乎都可以使用默认参数调用 init 函数.其他人可以尝试运行此脚本并查看他们是否得到相同的行为吗?有人知道如何加快速度吗?还是调整每个文件的速度?

I've ggogle code searched some stuff but everybody seems to be fine calling the init function with its default parameters. Can others try running this script and seeing if they get the same behavior or not? Does anybody know how to speed it up? Or adjust the speed for each file?

谢谢.

推荐答案

我想通了...有一个波模块 http://docs.python.org/library/wave.html 它可以读取 wav 文件的采样率.

I figured it out... There is a wave module http://docs.python.org/library/wave.html and it can read the sample rate for wav files.

这篇关于pygame 音频播放速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆