Skip to content

Conversation

@HalbFettKaese
Copy link

This PR adds a new backend that wraps the sounddevice python package. Currently, the sounddevice package is just imported through requirements.txt, as I was unsure if or how to add it as an optional dependency. Any new Aserver tries to use the new sounddevice backend over the previous pyaudio backend.

One benefit of sounddevice over pyaudio is that it can refresh the device list from within an IPython Notebook without needing to reload the kernel. For example:

from pya.gui import AserverGUI
# Create new server GUI.
# Disconnect/reconnect different devices, or switch the standard output device on your PC,
# and see the device list change after rebooting.
asgui = AserverGUI()
from pya import Arecorder
# Read standard input device name.
# See the result change when re-running after rebooting the server using the GUI.
rec = Arecorder().boot()
rec.device_dict["name"]

The PR also involves an internal restructuring of the AserverGUI, as the previous version was unable to handle a changing device list. One change in behavior compared to before is that the GUI now instantly initializes the default server, when previously it would only do so after the user clicked the "(re)boot" button once.

@sherlockhommel
Copy link
Collaborator

Hi, thanks for this PR, this would enhance day-to-day convenience greatly!

I have cloned your changes and tried it out, but somehow in my context they automatic reloading of the device list after plugging in a new external output device does not work. Should I do anything apart from installing sounddevice to make it work?

Apart from that, a few other general remarks:

  • Is the translation of the dict keys to camelCase necessary? (In general, I would prefer to keep the snake_case - more pythonic)
  • I would also like to add type hints and tests, but we could support in that regard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants