Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
BBB/Embedded Device Audio

Configure BeagleBone/Embedded Linux Device ALSA Audio

Running Debian Jessie in these examples. Setting up Alsa Audio to work with external USB sound card.

Steps are:

  • make sure ALSA is correctly installed
  • set up sound card recognition

Background info

Let's go: Check to see if ALSA is installed:

I'm doing this all from root.

cat /proc/asound/version

will give you the version number of the ALSA driver. You should see something like this:

Advanced Linux Sound Architecture Driver Version k4.1.15-ti-rt-r43.

If this works, go ahead and plug in a USB sound card (yes, hot swapping often works most of the time on the BB USB port!) and

alsamixer

If something resembling a mixer shows up, good! If the top left corner says "Card: USB Sound Device," you'll know that the USB audio card is properly set as the primary device. While you are here, configure your device. In particular, make sure it is not muted. MM means mute and O means on. Use the 'm' key to toggle this.

Press escape to exit alsamixer. You can save the alsamixer levels with the command:

alsactl store

If all this worked for you, you are ready to go. If not, read on.

Install ALSA if you need to

If you get an error, install ALSA. The required packages are: libasound2, libasound2-doc, alsa-base, alsa-utils, alsa-oss, alsamixergui.

apt-get install alsa-base alsa-tools alsa-tools-gui alsa-utils alsa-oss alsamixergui libalsaplayer0 gstreamer0.10-alsa

Reboot and get it started:

reboot    

alsactl init

Get ALSA to use the right sound card

If your sound card did not show up in alsamixer, you will need to configure some preferences. Find your sound card with

cat /proc/asound/cards

This result:

 0 [Black          ]: TI_BeagleBone_B - TI BeagleBone Black
                      TI BeagleBone Black
 1 [Device         ]: USB-Audio - C-Media USB Audio Device
                      C-Media USB Audio Device at usb-musb-hdrc.1.auto-1, full speed

tells me that the USB Audio card is in the hw:1 sound port. So I create /etc/asound.conf with following:

    pcm.!default {
    type hw
    card 1
}

ctl.!default {
    type hw           
    card 1
}

Replace "card 1" with the number of your card determined above. Now test:

alsamixer

You should now see your sound card listed in the upper left and the mixers showing controls for that card. If that doesn't work, reboot and test again.

If it does work, mute and unmute the appropriate controls. OO means unmute, while MM means mute. You can toggle between these by pressing 'm' on the keyboard. To save these settings

If alsamixer didn't show your card, and rebooting doesn't work, you may also have to set preference upon boot to the USB sound card over HDMI audio or disable the HDMI audio all together:

nano /boot/uEnv.txt

Uncomment or include (WARNING: Make sure you do not uncomment the line that disables both the HDMI and eMMC!):

optargs=capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN

Alternatively, you can change ordering of your cards so your USB card will be card 0 and it will work without editing asound.conf. See https://wiki.archlinux.org/index.php/Advanced_Linux_Sound_Architecture#Set_the_default_sound_card

Troubleshooting

Sound should be heard, but isn't? Run alsamixer and unmute (M key) and push the volume fader up for all channels. Check the levels for every soundcard in alsamixer (F6 key). MM means mute and OO means not muted.

Clipping? Alsamixer can also be used to reduce clipping by reducing levels.

Amixer allows command-line control of the mixer for the ALSA driver. You can force the BBB to use a specific interface using the command

amixer cset numid=3 N 

where the N parameter means the following: 0=auto, 1=analog, 2=hdmi. For example, to force the BBB to use the analog output:

amixer cset numid=3 1

Is PulseAudio installed instead of ALSA? See http://linuxg.net/how-to-properly-replace-pulseaudio-with-alsa-on-crunchbag-linux-and-debian-squeeze/

Reinstall libasound2?

apt-get install --reinstall libasound2

VU meter:

aplay -v -v -v

Nice discussion of BB audiocape:

http://www.aerodynes.fr/2014/06/04/beaglebone-black-audio-cape/

BB with PureData:

http://makezine.com/projects/beaglebone-audio-looper/

Other good resources (some are for RaspPi but are in the main true for BBB):

https://jeffskinnerbox.wordpress.com/2012/11/15/getting-audio-out-working-on-the-raspberry-pi/
http://blog.scphillips.com/posts/2013/01/sound-configuration-on-raspberry-pi-with-alsa/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.