How to switch to USB Audio on Raspberry Pi (Model B/Raspbian Wheezy September 2014)

Serious beats for the Pi!

Serious beats for the Pi!

February 2016 Edit: The article below does not pertain to the newest February 2016 build of Jessie Raspbian! A lot of improvements where made and you can now switch and set your default audio input- as well as output device directly in the UI. Editing and saving .asoundrc in your home folder also works without any problems if you are using the non UI Lite version.

After publishing our updated Raspberry Pi hardware list, some elaboration is needed on how to use the USB-AUDIO adapter as your default playback device.

This little how-to, should enable you to use the USB-AUDIO as default playback device.

  • To get started, plug your USB-AUDIO into the Pi and run the following command:
    aplay -l

    Within the output you should find: card 0: Device [USB Audio Device], device 0: USB Audio [USB Audio], which means the Pi has recognized the USB-AUDIO adapter and we can move on to configuration. If this is not the case, some further troubleshooting is needed (try power cycling your USB hub or plug the audio adapter directly into the Pi and alternatively use the lsusb command).

  • Use your favorite editor to modify /etc/modprobe.d/alsa-base.conf (be sure to make a backup of this file before editing in case something goes wrong!)
  • Change:
    options snd-usb-audio index=-2

    to:

    options snd-usb-audio index=0

    and also add the following on the next line:

    options snd_bcm2835 index=1

    This is essentially forcing the default sound module (snd_bcm2835) to be disabled while the usb sound module (snd-usb-audio) is enabled; rearranging the hierarchy of the sound modules.

  • Reboot and test for audio output

As the distros get updated and change over the months, this tutorial might not be an exact 1 : 1 representation of what your .conf may look like, or how the audio adapter enumerates. The main point here is to set the audio adapter to 0. The .conf itself has the following comment: “Keep usb-audio from being loaded as first soundcard”. This clue is what you are looking for to set to 0.

48 comments on “How to switch to USB Audio on Raspberry Pi (Model B/Raspbian Wheezy September 2014)”

  1. Mark Davis

    Thanks for the details re: audio output using the USB-AUDIO adapter on a Raspberry Pi (rpi).

    I’ve got the b+ (i.e. latest) model of the rpi. Can you tell me how to setup and use the audio _input_ (i.e. microphone) plug of the adapter? I’ve struggle with this for 2 days with no success.

    Thanks, Mark

    • Patric Neumann

      Hello Mark,

      I am sorry to hear this. Can you please post the output of the “aplay -l” command? Can you also please post the content of the /etc/modprobe.d/alsa.base.conf file?

      Kind regards,
      Patric
      Plugable Technologies

      • Mark Davis

        Thanks for the quick reply. I was delayed in responding because I chose to start with a fresh copy Raspbian Wheezy.

        aplay works fine when the output device is defaulted or when -D plughw:0 is specified. And there’s no complaint from arecord when -D plughw:0 is specified or the default is taken. But when I try to play the audio file generated by arecord, there is no audio.

        I also used alsactl to see that the mic was not muted and that it’s gain was set to 60.

        Here are the results you asked for:

        aplay -l
        **** List of PLAYBACK Hardware Devices ****
        card 0: Device [USB Audio Device], device 0: USB Audio [USB Audio]
        Subdevices: 1/1
        Subdevice #0: subdevice #0
        card 1: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
        Subdevices: 8/8
        Subdevice #0: subdevice #0
        Subdevice #1: subdevice #1
        Subdevice #2: subdevice #2
        Subdevice #3: subdevice #3
        Subdevice #4: subdevice #4
        Subdevice #5: subdevice #5
        Subdevice #6: subdevice #6
        Subdevice #7: subdevice #7
        card 1: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
        Subdevices: 1/1
        Subdevice #0: subdevice #0

        ===============================
        alsa-base.conf
        ===============================
        # autoloader aliases
        install sound-slot-0 /sbin/modprobe snd-card-0
        install sound-slot-1 /sbin/modprobe snd-card-1
        install sound-slot-2 /sbin/modprobe snd-card-2
        install sound-slot-3 /sbin/modprobe snd-card-3
        install sound-slot-4 /sbin/modprobe snd-card-4
        install sound-slot-5 /sbin/modprobe snd-card-5
        install sound-slot-6 /sbin/modprobe snd-card-6
        install sound-slot-7 /sbin/modprobe snd-card-7
        # Cause optional modules to be loaded above generic modules
        install snd /sbin/modprobe –ignore-install snd &install snd-rawmidi /sbin/modprobe –ignore-install snd-rawmidi &install snd-emu10k1 /sbin/modprobe –ignore-install snd-emu10k1 &# Keep snd-pcsp from beeing loaded as first soundcard
        options snd-pcsp index=-2
        # Keep snd-usb-audio from beeing loaded as first soundcard
        #options snd-usb-audio index=-2
        options snd-usb-audio index=0
        options snd_bcm2835 index=1
        # Prevent abnormal drivers from grabbing index 0
        options bt87x index=-2
        options cx88_alsa index=-2
        options snd-atiixp-modem index=-2
        options snd-intel8x0m index=-2
        options snd-via82xx-modem index=-

      • Mark Davis

        Your suggestion, by way of David Roberts, to question the plug type was spot on. I was using a mono plug and apparently a stereo plug is required. Thanks to you both for your help.

  2. Paul

    *earlier post not showing up this may be repeated.

    Can this file be edited in openelec 5.03 using a raspberry pi 2 with a Plugable USB audio ? I just need audio out not mic.

    Thanks

    • Patric Neumann

      Hello Paul,

      You should be able to go into your system settings and be able to select the “ASLA: USB Audio device, Analog” instance in your audio output settings. I verified this with a Raspberry Pi2 running openELEC 5.0.3.

  3. Vladimir Ota

    I am using Rpi2. I followed your howto. I encountered two differences.

    1) name of the file on my Rpi is /etc/modprobe.d/alsa-base.conf and not/etc/modprobe.d/alsa.base.conf as it is said in howrto.
    2) my device does not appear as card0 but as card1.

    I edited the conf file anyway as instructed in howto. After reboot the desktop panel (‘task bar’) is flashing. I can play an audio file, I saw some complaints about mic input, but I did not research deeper, because desktop was half dead because inoperative (blinking) panel.

    After I returned original conf file, desktop works OK.

    This is what aplay -l command returns:

    **** List of PLAYBACK Hardware Devices ****
    card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
    Subdevices: 8/8
    Subdevice #0: subdevice #0
    Subdevice #1: subdevice #1
    Subdevice #2: subdevice #2
    Subdevice #3: subdevice #3
    Subdevice #4: subdevice #4
    Subdevice #5: subdevice #5
    Subdevice #6: subdevice #6
    Subdevice #7: subdevice #7
    card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
    Subdevices: 1/1
    Subdevice #0: subdevice #0
    card 1: Device [C-Media USB Audio Device], device 0: USB Audio [USB Audio]
    Subdevices: 1/1
    Subdevice #0: subdevice #0

    Contents of alsa-base.conf are:

    # autoloader aliases
    install sound-slot-0 /sbin/modprobe snd-card-0
    install sound-slot-1 /sbin/modprobe snd-card-1
    install sound-slot-2 /sbin/modprobe snd-card-2
    install sound-slot-3 /sbin/modprobe snd-card-3
    install sound-slot-4 /sbin/modprobe snd-card-4
    install sound-slot-5 /sbin/modprobe snd-card-5
    install sound-slot-6 /sbin/modprobe snd-card-6
    install sound-slot-7 /sbin/modprobe snd-card-7
    # Cause optional modules to be loaded above generic modules
    install snd /sbin/modprobe –ignore-install snd &install snd-rawmidi /sbin/modprobe –ignore-install snd-rawmidi &install snd-emu10k1 /sbin/modprobe –ignore-install snd-emu10k1 &# Keep snd-pcsp from beeing loaded as first soundcard
    options snd-pcsp index=-2
    # Keep snd-usb-audio from beeing loaded as first soundcard
    options snd-usb-audio index=0
    options snd_bcm2835 index=1
    # Prevent abnormal drivers from grabbing index 0
    options bt87x index=-2
    options cx88_alsa index=-2
    options snd-atiixp-modem index=-2
    options snd-intel8x0m index=-2
    options snd-via82xx-modem index=-2

    I believe that the index in the options shuld be different because I am dealing with card1 and not card0, but I was not able to figure what I have to do by myself.

    I’d greatly appreciate any help and/or suggestion

    • David Roberts

      Hi Vladimir,

      Thank you for the detailed report of what you experienced. We haven’t tested this yet with the Pi2, but will do so tomorrow and let you know what we discover.

    • Patric Neumann

      Hello Vladimir,

      You are absolutely right, I need to correct the conf file! Thank you for bringing this to my attention. I just successfully tested the following configuration (I will only post the bottom half):

      # Keep snd-pcsp from beeing loaded as first soundcard
      options snd-pcsp index=-2
      # Keep snd-usb-audio from beeing loaded as first soundcard
      options snd-usb-audio index=0
      # Prevent abnormal drivers from grabbing index 0
      options bt87x index=-2
      options cx88_alsa index=-2
      options snd-atiixp-modem index=-2
      options snd-intel8x0m index=-2
      options snd-via82xx-modem index=-2

      By default “options snd_bcm2835 index=1” is not present in the conf so I left this line out and gave the above mentioned a try. I need to dig deeper for a more satisfying explanation between the Pi B and Pi 2 why this is the case but this should get you going.

      • Vladimir

        Hi Patric

        I left the snd_bcm2835 line out of .conf, and I set snd-usb-audio to index of 0. Status now is: aplay -l shows USB device as card 0; when I play the sound it goes to Rpi2 on-board AV connector and not to USB device; issue with xwindows panel (blinking) is still there.

        Digging around I found that it loading of bcm2835 module is controlled by /etc/modules file. It is reffered there as ‘snd-bcm2835’ and not as ‘snd_bcm2835’ like you are reffering to it(?). I commented out the bcm2835 of /etc/modules to see what happens. After reboot aplay -l shows only USB device (i.e. no bcm2835). But when I play the sound – audio goes to Rpi2 AV connector instead to USB! And sure enough – xwindows desktop still have th same trouble with its panel ..

        So, my xwindows trouble persists until I enable snd-bcm2835 in /etc/modules and put snd-usb-audio to any index but 0 in /etc/modprobe.d/alsa-base.conf.

        So I ended up on square 1 with no USB sound …

        • Patric Neumann

          Hi Vladimir,

          Can it be that you are using an older Raspbian build or you took the SD card out of the B and used it on the 2?

          I strongly suggest to start from scratch by re-imaging the SD card with latest Rasbian build. By using this radical method, everything is reset to default, plus this would also take care of the flashing panel.

          With a clean/fresh build you will still encounter the same initial enumeration of the audio adapter. After editing the conf (setting the audio adapter to 0) and rebooting you will see how the audio adapter is set to card 0, device 0 and this should take care of the audio portion. I double verified this myself and got audio to work on a clean install with the following asla-base.conf found in /etc/modprobe.d:

          # autoloader aliases
          install sound-slot-0 /sbin/modprobe snd-card-0
          install sound-slot-1 /sbin/modprobe snd-card-1
          install sound-slot-2 /sbin/modprobe snd-card-2
          install sound-slot-3 /sbin/modprobe snd-card-3
          install sound-slot-4 /sbin/modprobe snd-card-4
          install sound-slot-5 /sbin/modprobe snd-card-5
          install sound-slot-6 /sbin/modprobe snd-card-6
          install sound-slot-7 /sbin/modprobe snd-card-7
          # Cause optional modules to be loaded above generic modules
          install snd /sbin/modprobe –ignore-install snd && { /sbin/modprobe –quiet snd-ioctl32 ; /sbin/modprobe –quiet snd-seq ; : ; }
          install snd-rawmidi /sbin/modprobe –ignore-install snd-rawmidi && { /sbin/modprobe –quiet snd-seq-midi ; : ; }
          install snd-emu10k1 /sbin/modprobe –ignore-install snd-emu10k1 && { /sbin/modprobe –quiet snd-emu10k1-synth ; : ; }
          # Keep snd-pcsp from beeing loaded as first soundcard
          options snd-pcsp index=-2
          # Keep snd-usb-audio from beeing loaded as first soundcard
          options snd-usb-audio index=0
          # Prevent abnormal drivers from grabbing index 0
          options bt87x index=-2
          options cx88_alsa index=-2
          options snd-atiixp-modem index=-2
          options snd-intel8x0m index=-2
          options snd-via82xx-modem index=-2

          • Vladimir Ota

            Hi Patric,

            I downloaded the raspbian from Raspbery Pi site last Wednesday, bsash shell reports kernel to be 3.18.7- v7+. But I’ll:

            – first test with alsa-base.conf you provided
            – if that would not work, I’l go from scratch (I can do it while I do some other things, I was half decided to do it even before you suggested anyway).
            Right this moment I am occupied with some other things, so I’ll do it sometime tomorrow morning and report back to you.

            Regards

      • Vladimir Ota

        Hi ,
        1) your alsa-base.conf turned out to be exactly the same as mine, so there was no change.
        2) I started from scratch (2015-02-16-raspbian-wheezy.img). One thing did change. There is a change. Destop manager works OK now. Unfortunatelly that does not slolve the USB Audio issue.

        Yet – after all I tried, I think the USB device can be a problem (although it works on Win7 PC). Thing is – it quite old (4 years +), so its firmvare could be unsupported(??). I have ordered a new one (supposedly RPi compatible), so I’ll proceed with RPi2 sound stuff when it’ll be delivered to me. Until then I’ll live with RPi ‘native’ audio.

        Thank you for all your help and patience.
        Regards, Vladimir

        • Patric Neumann

          Oh, I assumed we are dealing with Plugable’s own audio adapter.

  4. Rob Ryan

    i did what you did above and my usb audio works but vol is really really low, can barely hear anything

    • Rob Ryan

      ok, did sudo alsamixer from terminal and raised the output of the usb card to 100%
      I have a rPI1 B+ not a rPi2, using an AQ Dragonfly 1.2 USB DAC….still can’t get the DAC to work in XMBC (KODI) though

      • Patric Neumann

        Wish I could help, but you need to contact the manufacturer for assistance. The above mentioned conf and post is meant for the Plugable’s USB-AUDIO.

  5. Lars R.

    What about the input, is that also working (ALSA) on the Raspberry Pi?

  6. Ion

    Thank you Patrick.
    Working on Raspberry Pi 1.0 model B+ running Raspbian wheezy

    • Patric Neumann

      You are welcome, and thank you for confirming this for us.

  7. Trung
  8. Pingback: KX3 Companion | Use A Raspberry Pi2 and KX3 Companion App To Remotely Control The KX3 With Audio Streaming! #elecraft #hamradio #QRP

  9. karthi

    hi Patric,
    i have worked b+. i am not getting audio out.after recording it by using arecord -D plughw:0 -r 48000 test.wav command. while playing that audio file it completely silent. can you please help me?

  10. Don Cross

    I ran into an issue getting the USB sound card working, but I figured out the problem. I thought I would mention it here in case it helps others.

    One of the first things I did with my RPi is to create a new user for myself (called “don”) instead of the default “pi” user. While logged into this “don” account, I plugged in the USB sound card, but when I did “aplay -l”, I would always see “aplay: device_list:252: no soundcards found…”. Of course I rebooted and fiddled with various settings to no avail.

    It was puzzling because lsusb showed the device as “C-Media Electronics, Inc.”

    It turns out all I had to do was add my new account to the “audio” group:

    sudo addgroup don audio

    Then I logged out and back in again, and BOOM… “aplay -l” shows both the build-in audio (bcm2835) and the USB Audio Device.

    So if you enter “aplay -l” but it says “no soundcards found”, try the “groups” command. If you don’t see “audio” as one of the groups, add your account to the audio group, log out, log back in, and try “aplay -l” again.

    • Patric Neumann

      Hi Don,

      Excellent point! I would also like to thank you for sharing this us on our post to help out others which would potentially run into the same problem.

    • Alex A

      omg! I had this exact problem and NONE of the ‘rpi usb microphone’ tutorials mentioned this. Worse still, googling this exact error ‘no soundcards found’ never EVER came up with any answer saying you had to either be the ‘pi user’ or to add your user to the audio group.

      thank you thank you thank you! 🙂 i had been struggling with this for 2 days and just couldn’t understand why alsa was not working… i even got extra different branded microphones incase it was.. blah blah lbha you can imagine the pain.

      thank you!

      • Kevin Lamb

        Hello Alex,

        Thanks for reaching out to us! It’s always good to hear from other Raspberry Pi tinkerers. Ah, sorry for the trouble with the audio. I know what you mean, it isn’t explained very well in a lot of other documentation. We’re glad to see this article did the trick for you. Feel free to contact us directly at: support@plugable.com with any other questions, and we’ll be here to help.

        Thank you,

        Kevin
        Plugable Support

  11. Ric de Mowbray

    Hi Patric,
    I’m stuck at the beginning I’m afraid!

    card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
    Subdevices: 1/1
    Subdevice #0: subdevice #0
    card 1: Audio [USB2.0 High-Speed True HD AudioDevice [USB Audio Device], device 0: USB Audio [USB Audio]

    I’m using a 7.1 USB surround card and it seems like it’s recognized, in fact in the GUI I can set it as the default audio device. But it doesn’t occupy card 0 spot. Tried /etc/modprobe.d/alsa-base.conf to modify the config anyhow but was told I didn’t have permission. Sure I’m being really stupid so apologese in advance 🙂

    • Patric Neumann

      Hi Ric,

      Sounds like you need to either edit the .conf with the root user or “sudo” edit the .conf with your favorite editor. Beyond this tip, you would have to contact the manufacturer if the audio adapter does not work.

    • Joe Marshall

      In case anyone comes to this on a google, I had problems with this on recent versions of raspbian (Jessie), where there is a file called aliases.conf in /lib/modprobe.d which contains the line options snd-usb-audio index=-2 and overrides the etc/modprobe.d/ files, so you need to change that one.

  12. Woki

    I recently bought this USB Audio Adapter to enable microphone recording on my Raspberry Pi 2 model B. I made all the settings suggested on this page. However, the speaker and microphone are not working at all.

    the Speaker even does not play when I typed the following: $ aplay /usr/share/sounds/alsa/Front_Center.wav

    • Patric Neumann

      Please use the latest build of Raspbian (Jessie) -> https://www.raspberrypi.org/downloads/raspbian/. The latest build does not involve fighting configs anymore… just select and set your default devices in the UI or in the backend and never look back. The selections stick and work without any extra effort.

  13. Woki

    Yes, it works fine. I recorded and played back – both the mic and Speaker works.

  14. JG27

    Hello, I am confused because with my raspberry PI3 and latest Raspbian Jessie, I can see my USB audio card in the UI try to select it but I can’t… I can toggle from HDMI to jack without any problem, but my USB card is seen but not selectable….
    Do you have any idea?

    • Patric Neumann

      The combination with our USB-AUDIO and the Pi3 should work right in UI environment. Maybe Rasbian has changed something yet again and is conflicting. Initially I would connect the audio adapter to a PC or other computer to ensure the audio adapter works. Then I would try reinstalling Rasbian from scratch to see if this makes a difference. Beyond that, you would need to play with audio configuration on the backend to get it to work.

      If the USB-AUDIO turns out to be defective, please contact us directly at support@plugable.com for a replacement.

  15. Jager

    i try modifying /usr/share/alsa/alsa.conf
    i changed the following lines:
    defaults.ctl.card 0 i change 0 to 1
    defaults.pcm.card 0 0 to 1

    and it works perfectly well, the only trouble is a black screen when i cast a song using raspicast but wont affect anything

  16. Santhosh Panambur

    This is awesome. It works like a christmas tree. Just the way it was described.

Comments are closed.