def is_format_supported(self, rate, input_device=None, input_channels=None, input_format=None, output_device=None, output_channels=None, output_format=None): """ Check to see if specified device configuration is supported. Returns True if the configuration is supported; throws a ValueError exception otherwise. :param `rate`: Specifies the desired rate (in Hz) :param `input_device`: The input device index. Specify `None` (default) for half-duplex output-only streams. :param `input_channels`: The desired number of input channels. Ignored if `input_device` is not specified (or `None`). :param `input_format`: PortAudio sample format constant defined in this module :param `output_device`: The output device index. Specify `None` (default) for half-duplex input-only streams. :param `output_channels`: The desired number of output channels. Ignored if `input_device` is not specified (or `None`). :param `output_format`: PortAudio sample format constant (`PaSampleFormat`). :rtype: bool :raises ValueError: tuple containing: (error string, PortAudio error code `PaErrorCode`). """ if input_device == None and output_device == None: raise ValueError("must specify stream format for input, " +\ "output, or both", paInvalidDevice) kwargs = {} if input_device != None: kwargs['input_device'] = input_device kwargs['input_channels'] = input_channels kwargs['input_format'] = input_format if output_device != None: kwargs['output_device'] = output_device kwargs['output_channels'] = output_channels kwargs['output_format'] = output_format return pa.is_format_supported(rate, **kwargs)
def is_format_supported(self, rate, input_device = None, input_channels = None, input_format = None, output_device = None, output_channels = None, output_format = None): """ Check to see if specified device configuration is supported. Returns True if the configuration is supported; throws a ValueError exception otherwise. :param `rate`: Specifies the desired rate (in Hz) :param `input_device`: The input device index. Specify `None` (default) for half-duplex output-only streams. :param `input_channels`: The desired number of input channels. Ignored if `input_device` is not specified (or `None`). :param `input_format`: PortAudio sample format constant defined in this module :param `output_device`: The output device index. Specify `None` (default) for half-duplex input-only streams. :param `output_channels`: The desired number of output channels. Ignored if `input_device` is not specified (or `None`). :param `output_format`: PortAudio sample format constant (`PaSampleFormat`). :rtype: bool :raises ValueError: tuple containing: (error string, PortAudio error code `PaErrorCode`). """ if input_device == None and output_device == None: raise ValueError("must specify stream format for input, " +\ "output, or both", paInvalidDevice); kwargs = {} if input_device != None: kwargs['input_device'] = input_device kwargs['input_channels'] = input_channels kwargs['input_format'] = input_format if output_device != None: kwargs['output_device'] = output_device kwargs['output_channels'] = output_channels kwargs['output_format'] = output_format return pa.is_format_supported(rate, **kwargs)