Fixing sound on the PhidgetSBC3

When I got my PhidgetSBC3 I was really excited because I was going to try to get go running on it (which I did) but while it recognized my Logitech Z205 speakers, playing any audio file resulted in a lot of crackling (hear for yourself). After searching until my eyes bled months ago, I gave up. But recently I took another stab (because I want our foosball table horn back at Shopify) and finally found a solution then I figured out the actual problem.

I've tried solution after solution hoping it would work because none of the regular troubleshooting would work as the device was being recognized and was able to be used. It just sounded horrible. I did find this wiki entry for archlinux for crackling sound with USB devices but that solution didn't help. But did make me try restarting the PhidgetSBC3 which then lead some actual errors when trying to use alsa.

root@phidgetsbc:~# alsamixer
cannot open mixer: No such file or directory
root@phidgetsbc:~# aplay /usr/share/sounds/alsa/Front_Center.wav 
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4720:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM default
aplay: main:682: audio open error: No such file or directory

Searching for this lead me to this forum post about a usb speaker not being detected and suggested creating a /etc/asound.conf file and restarting alsa. This solved the problem of not finding the device and the crackling. The card 1 in the file suggested an ID of some sort and then I checked the ID of the device and found it matched.

root@phidgetsbc:~# cat /proc/asound/modules
 1 snd_usb_audio

I wanted to confirm this was the device missing issue so I restored to factory and plugged the Z205 in and looked again.

root@phidgetsbc:~# cat /proc/asound/modules
 0 snd_usb_audio

And suddenly it makes sense. For whatever reason, before installing alsa-base the PhidgetSBC3 will use ID 0 for the Z205 but after that it will use ID 1. I have no idea why the crackling went away but it might have something to do with setting type hw or maybe it just doesn't like ID 0.

TL;DR

If you're trying to get sound on the PhidgetSBC3 to work. Try this and restart.

root@phidgetsbc:~# apt-get install alsa-base alsa-utils -y
root@phidgetsbc:~# cat > /etc/asound.conf
pcm.!default {
        type hw
        card 1
}

ctl.!default {
        type hw
        card 1
}
root@phidgetsbc:~# /etc/init.d/alsa-utils restart
[ ok ] Shutting down ALSA...done.
[ ok ] Setting up ALSA...done.