本文整理汇总了Python中pyaudio.PyAudio.is_format_supported方法的典型用法代码示例。如果您正苦于以下问题:Python PyAudio.is_format_supported方法的具体用法?Python PyAudio.is_format_supported怎么用?Python PyAudio.is_format_supported使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyaudio.PyAudio
的用法示例。
在下文中一共展示了PyAudio.is_format_supported方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AudioBackend
# 需要导入模块: from pyaudio import PyAudio [as 别名]
# 或者: from pyaudio.PyAudio import is_format_supported [as 别名]
#.........这里部分代码省略.........
# method
def select_second_channel(self, index):
self.second_channel = index
success = True
return success, self.second_channel
# method
def open_stream(self, device):
# by default we open the device stream with all the channels
# (interleaved in the data buffer)
max_input_channels = self.pa.get_device_info_by_index(device)['maxInputChannels']
stream = self.pa.open(format=paInt16, channels=max_input_channels, rate=SAMPLING_RATE, input=True,
input_device_index=device, stream_callback=self.callback,
frames_per_buffer=FRAMES_PER_BUFFER)
lat_ms = 1000 * stream.get_input_latency()
self.logger.push("Device claims %d ms latency" % (lat_ms))
return stream
# method
def open_output_stream(self, device, callback):
# by default we open the device stream with all the channels
# (interleaved in the data buffer)
max_output_channels = self.pa.get_device_info_by_index(device)['maxOutputChannels']
stream = self.pa.open(format=paInt16, channels=max_output_channels, rate=SAMPLING_RATE, output=True,
frames_per_buffer=FRAMES_PER_BUFFER, output_device_index=device,
stream_callback=callback)
return stream
def is_output_format_supported(self, device, output_format):
max_output_channels = self.pa.get_device_info_by_index(device)['maxOutputChannels']
success = self.pa.is_format_supported(SAMPLING_RATE, output_device=device, output_channels=max_output_channels, output_format=output_format)
return success
# method
# return the index of the current input device in the input devices list
# (not the same as the PortAudio index, since the latter is the index
# in the list of *all* devices, not only input ones)
def get_readable_current_device(self):
return self.input_devices.index(self.device)
# method
def get_readable_current_channels(self):
dev_info = self.pa.get_device_info_by_index(self.device)
nchannels = dev_info['maxInputChannels']
if nchannels == 2:
channels = ['L', 'R']
else:
channels = []
for channel in range(0, dev_info['maxInputChannels']):
channels += ["%d" % channel]
return channels
# method
def get_current_first_channel(self):
return self.first_channel
# method
def get_current_second_channel(self):
return self.second_channel
# method