python-sounddevice
python-sounddevice copied to clipboard
Continuous stream output to device #1 and input stream from device #2
Hi,
How to use 2 devices at the same time with sounddevice?
I'd like to use device #1 for output, and device #2 for input, both with their callback.
What is the recommended way to do this?
Based on your operating system, there may be different solutions available. On macOS, something like an "aggregate device" can be configured in the system settings. On Linux, something similar should be possible via ALSA configuration. This would be the easiest way since the code to record from and play to the device may be simpler.
If this is not an option, it should also be possible to create independent streams for two different devices. E.g., based on https://github.com/spatialaudio/python-sounddevice/issues/338#issuecomment-867131063, but with an InputStream and OutputStream with a single queue in between. Taka also a look at the rest of the thread for alternative (more complex) solutions including threading.