spatialaudio / python-sounddevice

:sound: Play and Record Sound with Python :snake:
https://python-sounddevice.readthedocs.io/
MIT License
1.01k stars 148 forks source link

Error in hardware support #278

Open ullix opened 4 years ago

ullix commented 4 years ago

I am using a USB soundcard which sounddevice.query_devices() reports as: USB PnP Sound Device: Audio (hw:2,0), ALSA (0 in, 2 out), i.e. it says there is no input. However, I am using it for recording from a microphone on Ubuntu 16.04, and it clearly works.

LSUSB lists the device as 7 Bus 003 Device 049: ID 0d8c:013c C-Media Electronics, Inc. CM108 Audio Controller

Calling the device anyway raises a Valueerror:

print(sd.query_devices(device=7, kind='input'))
...
ValueError: Not an input device: 'USB PnP Sound Device: Audio (hw:2,0)'

Sounddevice is Version: 0.4.0 I purchased this device from amazon: https://www.amazon.de/gp/product/B0018DK9TA

EDIT: using this call print(sd.query_devices(device=7, kind= 'input')) I get this response: {'name': 'USB PnP Sound Device: Audio (hw:2,0)', 'hostapi': 0, 'max_input_channels': 1, 'max_output_channels': 2, 'default_low_input_latency': 0.008707482993197279, 'default_low_output_latency': 0.008707482993197279, 'default_high_input_latency': 0.034829931972789115, 'default_high_output_latency': 0.034829931972789115, 'default_samplerate': 44100.0}

so here sounddevice says there is 1 input, while it crashes because there is none?

mgeier commented 4 years ago

The number of device inputs and outputs is provided by the underlying PortAudio library.

Please ask your question on the PortAudio mailing list: http://portaudio.com/contacts.html

so here sounddevice says there is 1 input, while it crashes because there is none?

It "crashes" (i.e. raises an exception) if you explicitly request kind='input', because the specified device apparently is no input device.

If you use print(sd.query_devices(device=7)) it should not "crash".