hamiltron/py-simple-audio

Add support for specifying the ALSA device to use

Opened this issue · 3 comments

The attached diff adds support for specifying which ALSA device to use. This allows you to play audio on multiple devices in Linux. Please consider incorporating it into the mainline release.

simpleaudio-alsa-device.txt

Thanks for the interest and the submission. I looked over the patch. It's a good idea and it certainly looks functional, but there's a couple reasons I wouldn't include this as is.

The biggest one is that one of the goals of the module is to provide a uniform cross-platform audio interface. I am very hesitant to introduce any feature that is not fully cross-platform and your patch only addresses the Linux/ALSA approach to device selection. It may be possible to do essentially the same thing for both Windows and OSX but it would take digging back into their API's and coming up with a lowest-common-denominator solution.

Another issue is that of usability with respect to audio device enumeration. If there's a way to specify the audio device being used, then there needs to be a way to query for all available devices in a simple, Pythonic way. This would need to be implemented as well.

If all those goals could be met, then I'd be willing to move forward with the idea. Unfortunately, as much as I'd like to dive into all this, I have very little time to spare these days so I can't at the moment. If you'd like to take that on then I'd be happy to correspond and strategize further.

Thanks again.

I understand the goal of enabling cross-platform usage. That's why I went
with the notion of an options dict (which would be ignored on
non-compatible platforms), rather than adding a "device" parameter or
something like that. This is API-compatible, and provides reasonable
semantics when you're not on an ALSA system.

Unfortunately, I don't know that the device addressing conventions of the
three different platforms would be conducive to a single, consistent
mechanism. There would likely have to be some platform specific awareness
to identify the right device you want to use. I could certainly look into
this for ALSA and OSX, but I don't have a Windows computer to test on.

Sadly, not having support for selecting the device in the distribution
version means that I'm going to have to maintain a fork for my own uses.

-Jon

On Wed, Aug 10, 2016 at 8:33 PM, hamiltron notifications@github.com wrote:

Thanks for the interest and the submission. I looked over the patch. It's
a good idea and it certainly looks functional, but there's a couple reasons
I wouldn't include this as is.

The biggest one is that one of the goals of the module is to provide a
uniform cross-platform audio interface. I am very hesitant to introduce
any feature that is not fully cross-platform and your patch only addresses
the Linux/ALSA approach to device selection. It may be possible to do
essentially the same thing for both Windows and OSX but it would take
digging back into their API's and coming up with a
lowest-common-denominator solution.

Another issue is that of usability with respect to audio device
enumeration. If there's a way to specify the audio device being used, then
there needs to be a way to query for all available devices in a simple,
Pythonic way. This would need to be implemented as well.

If all those goals could be met, then I'd be willing to move forward with
the idea. Unfortunately, as much as I'd like to dive into all this, I have
very little time to spare these days so I can't at the moment. If you'd
like to take that on then I'd be happy to correspond and strategize
further.

Thanks again.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#11 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AQezThbVXkkk4AwFC5xdO4UUqd1XfOi-ks5qepgegaJpZM4Jgv8t
.

@jonmcclintock - This package may suit your needs: https://pypi.python.org/pypi/sounddevice/
It can be as simple to use as simpleaudio with the default sound device, but it is also very flexible, such as selecting the ALSA device. It's dependencies are already included in scientific Python distributions like Anaconda.