Raspberry Pi Streaming Radio Player: Ignoring a Missing Volume Knob

The Dell AC511 USB SoundBars have volume control knobs, which this udev rule turns into the /dev/input/volume device:

ATTRS{name}=="Dell Dell AC511 USB SoundBar", SYMLINK+="input/volume"

I recently wanted to use an ordinary USB “sound card” that did not, of course, have a volume knob:

Sabrent USB Audio Adapter
Sabrent USB Audio Adapter

This hack skips the configuration that makes the knob’s events visible to the Python program:

import os.path

... snippage ...

# if volume control knob exists, then set up its events

VolumeDevice = '/dev/input/volume'

vp = select.poll()
if os.path.exists(VolumeDevice):
  v = InputDevice(VolumeDevice)
  vp.register(v.fileno(),select.POLLIN + select.POLLPRI + select.POLLERR)

It turns out that if you never register a device with the event polling interface, then the interface never reports any events and the rest of the code remains blissfully undisturbed: the non-existent knob doesn’t do anything, while the volume control buttons on the keypad continue to function as usual.

The end result of this fiddling puts a Raspberry Pi 2 Model B to work as a streaming player on my Electronics Workbench, untethering the laptop from those powered speakers:

RPi 2 Streaming Player - USB sound gadget
RPi 2 Streaming Player – USB sound gadget

It’s a shame that USB audio gadget is so big, because it crowds out standard USB plugs to the side.

The most satisfactory LED configuration for a translucent case with an external WiFi adapter seems to be:


The rest of the code remains unchanged as shown in that GitHub Gist.

Bomb the bass!