|
150 | 150 | void *hostApiSpecificStreamInfo; |
151 | 151 | } PaStreamParameters; |
152 | 152 | /* not implemented: paFormatIsSupported */ |
153 | | -/* not implemented: Pa_IsFormatSupported */ |
| 153 | +PaError Pa_IsFormatSupported( const PaStreamParameters *inputParameters, |
| 154 | + const PaStreamParameters *outputParameters, |
| 155 | + double sampleRate ); |
154 | 156 | typedef void PaStream; |
155 | 157 | #define paFramesPerBufferUnspecified 0 |
156 | 158 | typedef unsigned long PaStreamFlags; |
@@ -677,6 +679,46 @@ def query_hostapis(index=None): |
677 | 679 | } |
678 | 680 |
|
679 | 681 |
|
| 682 | +def check_input_settings(device=None, channels=None, dtype=None, |
| 683 | + samplerate=None): |
| 684 | + """Check if given input device settings are supported. |
| 685 | +
|
| 686 | + All parameters are optional, :obj:`default` settings are used for |
| 687 | + any unspecified parameters. If the settings are supported, the |
| 688 | + function does nothing; if not, an exception is raised. |
| 689 | +
|
| 690 | + Parameters |
| 691 | + ---------- |
| 692 | + device : int or str, optional |
| 693 | + Device ID or device name substring, see :attr:`default.device`. |
| 694 | + channels : int, optional |
| 695 | + Number of input channels, see :attr:`default.channels`. |
| 696 | + dtype : str or numpy.dtype, optional |
| 697 | + Data type for input samples, see :attr:`default.dtype`. |
| 698 | + samplerate : float, optional |
| 699 | + Sampling frequency, see :attr:`default.samplerate`. |
| 700 | +
|
| 701 | + """ |
| 702 | + parameters, dtype, samplesize, samplerate = _get_stream_parameters( |
| 703 | + 'input', device=device, channels=channels, dtype=dtype, latency=None, |
| 704 | + samplerate=samplerate) |
| 705 | + _check(_lib.Pa_IsFormatSupported(parameters, _ffi.NULL, samplerate)) |
| 706 | + |
| 707 | + |
| 708 | +def check_output_settings(device=None, channels=None, dtype=None, |
| 709 | + samplerate=None): |
| 710 | + """Check if given output device settings are supported. |
| 711 | +
|
| 712 | + Same as :func:`check_input_settings`, just for output device |
| 713 | + settings. |
| 714 | +
|
| 715 | + """ |
| 716 | + parameters, dtype, samplesize, samplerate = _get_stream_parameters( |
| 717 | + 'output', device=device, channels=channels, dtype=dtype, latency=None, |
| 718 | + samplerate=samplerate) |
| 719 | + _check(_lib.Pa_IsFormatSupported(_ffi.NULL, parameters, samplerate)) |
| 720 | + |
| 721 | + |
680 | 722 | def sleep(msec): |
681 | 723 | """Put the caller to sleep for at least `msec` milliseconds. |
682 | 724 |
|
|
0 commit comments