问题描述
我想我的查询音频设备,并得到所有可用的采样率。我使用PyAudio 0.2,运行于PortAudio V19之上,一个Ubuntu的机器上使用Python 2.6。
I'd like to query my audio device and get all its available sample rates. I'm using PyAudio 0.2, which runs on top of PortAudio v19, on an Ubuntu machine with Python 2.6.
推荐答案
在pyaudio分布,测试/ system_info.py
显示了如何确定设备支持的采样率。请参阅<一个href=\"http://people.csail.mit.edu/hubert/git/?p=pyaudio.git;a=blob;f=test/system_info.py;h=3c81432d7ffa3feaae06fa9804f41ffa03d4865d;hb=HEAD#l49\"相对=nofollow>开始于行49 部分。
In the pyaudio distribution, test/system_info.py
shows how to determine supported sample rates for devices. See the section that starts at line 49.
总之,使用 PyAudio.is_format_supported
的方法,例如
In short, you use the PyAudio.is_format_supported
method, e.g.
devinfo = p.get_device_info_by_index(1) # Or whatever device you care about.
if p.is_format_supported(44100.0, # Sample rate
input_device=devinfo['index'],
input_channels=devinfo['maxInputChannels'],
input_format=pyaudio.paInt16):
print 'Yay!'
这篇关于如何获取使用PyAudio或PortAudio我的设备的音频采样率的名单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!