spotify / pedalboard

šŸŽ› šŸ”Š A Python library for audio.
https://spotify.github.io/pedalboard
GNU General Public License v3.0
5.24k stars 261 forks source link

Audio Stream device names are not exposed in documentation and missing device error message is not user friendly. #380

Open djangohenk opened 2 weeks ago

djangohenk commented 2 weeks ago

Hi,

I'm trying to use Pedalboard with a live audio stream, following the example provided in the documentation (version 0.9.16) titled "Running Pedalboard on Live Audio." However, I keep running into issues with specifying input_device_name and output_device_name.

My computer is running Ubuntu 22.04, and Iā€™m using a Focusrite Scarlett 2i2 4th Gen as the USB audio device. When I run $ python3 -m sounddevice, I get the following information for the device:

'5 Scarlett 2i2 4th Gen: USB Audio (hw:3,0), ALSA (4 in, 2 out)'

No matter what I try as the input and output device names, I keep getting an error like: ValueError: No such device: hw:3,0

Any help would be greatly appreciated.

Kind regards,
Henk

psobot commented 2 weeks ago

Hi @djangohenk!

What comes up when you run the following line?

print(AudioStream.input_device_names)
djangohenk commented 2 weeks ago

Hi @psobot

This is the output ['JACK Audio Connection Kit', 'HD-Audio Generic; USB Stream Output (1)', 'Logitech BRIO, USB Audio; Direct hardware device without any conversions', 'Logitech BRIO, USB Audio; Direct sample snooping device', 'Logitech BRIO; USB Stream Output', 'HD-Audio Generic, ALC897 Analog; Direct hardware device without any conversions', 'HD-Audio Generic, ALC897 Analog; Direct sample snooping device', 'HD-Audio Generic; USB Stream Output (2)', 'Scarlett 2i2 4th Gen, USB Audio; Direct hardware device without any conversions', 'Scarlett 2i2 4th Gen, USB Audio; Direct sample snooping device', 'Scarlett 2i2 4th Gen; USB Stream Output']

psobot commented 2 weeks ago

Looks like you should be able to do:

scarlett = 'Scarlett 2i2 4th Gen, USB Audio; Direct hardware device without any conversions'

with AudioStream(scarlett, scarlett) as stream:
    # do stuff with `stream` here!

Let me know if that doesn't work; the error message could be improved on our end to show potential matches instead of just saying No such device, and it seems like the device name parsing may be broken for device names that contain parentheses or semicolons.

djangohenk commented 2 weeks ago

@psobot That's it!! I didn't expect that I would have to use such a long string as an ID. Thank you for your quick help. Kind regards, Henk