spatialaudio / python-sounddevice

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

Input Output Pass-Through Bit rate #386

Open Sameerhesta opened 2 years ago

Sameerhesta commented 2 years ago

Hello, I am using Input Output Pass-Through feature of sounddevice on two different devices but I am getting micro cutouts in the output device. I can use only 512 to 800 kbps bit rate, so I want to reduce the Bit Rate of the stream in Input Output Pass-Through feature, If it is possible please let me know the way.

mgeier commented 2 years ago

I'm not sure what you mean by "bit rate". You can reduce the sampling rate which leads to fewer bits per second and you could choose a dtype with fewer bits. You can also use some kind of encoding, but that is out of scope for the sounddevice module, you'll need to use an additional module or implement it yourself.

But I'm not sure if any of this would help with your problem with using two different devices.

In general, when you use two different hardware devices (that are not somehow externally synchronized), you will have some drift between their clocks and you will have dropouts at some point. This is not at all a trivial problem and you'll probably have to implement some dynamic resampling to fix it. Implementing this in Python is probably not feasible.

Depending on your operating system and your audio hardware there might be tools to combine the two devices to one virtual device, which you could then use with the sounddevice module.