Open HaroldMills opened 7 months ago
Is there another way to determine whether or not a given sample rate is supported on macOS? I tried using a stream to record, like this:
stream = sd.InputStream(**settings)
stream.start()
stream.read(settings['samplerate'])
hoping that the initializer might raise an exception for an unsupported sample rate, but it does not. The read
fails with the same console message that rec
produces, as in my original comment.
check_input_settings
does reject some sample rates on macOS, namely ones outside of the range [1000, 384000].
check_input_setting()
only calls Pa_IsFormatSupported()
from the underlying PortAudio library:
Can you please ask your question at https://github.com/PortAudio/portaudio/issues or at the PortAudio mailing list?
Thanks for the suggestion. I'll look into this as a PortAudio issue.
On my 2019 MacBook Pro running macOS 13.6.1, the following script:
(you might need to modify the device index for a different computer) first checks if the specified input settings are supported and then, if they are (i.e. if the call to
check_input_settings
does not raise an exception), attempts to record for one second with those settings. For my Mac's built-in microphone this works as expected for a sample rate of 44100 Hz. For various other sample rates, however, including 48000, 24000, and 22050 Hz, it does not. For those sample rates the call tocheck_input_settings
does not raise an exception, but the script terminates inside the call torec
with the console message:It seems that this may be a bug in
check_input_settings
, which should raise an exception for unsupported sample rates.