spatialaudio / python-sounddevice

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

Can I use ALSA dsnoop capture devices? #441

Closed danieljlevine closed 1 year ago

danieljlevine commented 1 year ago

Hi,

I would like to share an audio capture device between a python application utilizing your sounddevice module and the ALSA arecord executable. Currently, either one or the other application can use the audio capture device and locks the other one out. The ALSA dsnoop capability seems to be the way to share access, so I created a dsnoop device. I am able to use arecord in 2 different terminals on the same system with my dsnoop device. So now, instead of using arecord for the second application, I want to use the python application using making use of sounddevice. But when I run python -m sounddevice, I get a list of devices, but none are my dsnoop device. How do I get my dsnoop device to become available in the list of sounddevice devices the application can access?

Is there a better way to share the audio capture?

danieljlevine commented 1 year ago

I see in the code that it is merely called portaudio's routines, so I guess if portaudio doesn't report the ALSA dsnoop devices, then there's not much sounddevice can do about it. And looking in the sounddevice code for ALSA, I can see they are intentionally ignoring a number of plug-ins, including dsnoop.

/ Disregard some standard plugins / static int IgnorePlugin( const char pluginId ) { static const char ignoredPlugins[] = {"hw", "plughw", "plug", "dsnoop", "tee", "file", "null", "shm", "cards", "rate_convert", NULL}; ...

So, how would one share the audio capture between so8unddevice/portaudio for an ALSA device, if dsnoop is not an option?

mgeier commented 1 year ago

I guess if portaudio doesn't report the ALSA dsnoop devices, then there's not much sounddevice can do about it

Exactly.

I don't know about the different ALSA plugins, but you should ask at the PortAudio mailing list (http://portaudio.com/contacts.html), maybe someone can help there?