Configure Sound Output (Pi Zero only)
If you're using any other kind of Pi, skip this step, a USB sound card is only needed if you're using the Pi Zero, which doesn't have an audio jack.
Even with the Zero, you can avoid using a USB sound card by either using an HDMI cable and your TV's speakers:
(Raspberry Pi audio configuration instructions here.)
or by building a simple RC filter and connecting to PWM output on GPIO 18:
(Adafruit tutorial here.)
If I was serious about deploying piHole on the Pi Zero I'd choose this second option. I'll have to get around to it some day anyway, but for now I have a cheap USB sound card dongle lying around (previously used with a BBB), so I'll use that.
Configuring a USB Sound Card on the Pi Zero
I'm going to assume that you're using a recent (Jessie) version of Raspbian here. If you're using an older version of Linux, you'll have to modify the file
following instructions like those here:
(Old instructions for switching audio output.)
On Raspbian Jessie we'll be modifying the file
First let's identify our card. Plug in your USB sound card and run the command
This will display a "List of PLAYBACK Hardware Devices". The first device listed,
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
is the default PWM output described at the Adafruit link above. The second listed device should be your USB Sound Card. For me the output is:
card 1: Set [C-Media USB Headphone Set], ...
Which is great news as the "C-Media USB Headphone Set" driver is pre-installed in Jessie.
If your card type is CM108 or CM109, you'll have to install a driver by following the instructions at:
(Another great tutorial by Lady Ada.)
Assuming you've got that done, and you're running Raspbian Jessie, we can
sudo nano /etc/alsa/alsa.conf
changing defaults.ctl.card and defaults.pcm.card from the default 0 to 1.
(Don't forget to backup alsa.conf before editing!)
To avoid the default card switching back to 0, I also modified the file .asoundrc in my home directory (/home/pi.).
Mine now reads
where "Set" is the name of my USB Sound Card: the word immediately after "card 1: " in the output from "aplay -l" above.
(You can also see your card's name by running "aplay -L", some card names are set to "Audio".)
After rebooting, we should now be good to go. Connect the headphone jack of the USB sound card to some PC speakers and enter
and you should hear a young lady saying "Front Centre". If not, reboot and try again. If still not, give up. Seriously. Audio configuration is, and probably always willbe, the worst part of Linux (worse than WiFi support and suspend/resume).