paoloimg
Posts: 1
Joined: Thu Oct 22, 2015 1:46 pm

Raspbian Jessie and USB Audio device as default

Fri Oct 23, 2015 10:55 am

Hi everyone,
I've spent a couple of days looking for a solution with no results, so I hope to find here someone expert enough to point me in the right direction.
A lot of people faced the same issue I have, but they appear to have different circumstances due to the different Raspian distro, which is often referred to be Wheezy while I'm using Jessie.

My aim is to configure my USB audio device as the default one, both for the speakers and for the microphone.

All the info that I was able to find was referring to those steps:
1. check for the device to be correctly hooked up & recognized by the OS (using dmesg, lsusb, aplay -l, etc).
2. edit the "/etc/modprobe.d/alsa-base.conf" file in order to indexing the USB audio device before the built-in one.
3. edit the "~/.asoundrc" file to make the USB Device as the default device.

Step 1
The system is able to see my USB Audio device as you can see in the following outputs:

Code: Select all

pi@raspberrypi ~ $ dmesg | grep C-Media
[    3.361759] usb 1-1.4: Manufacturer: C-Media Electronics Inc.
[    3.394557] input: C-Media Electronics Inc.       USB PnP Sound Device as /devices/platform/soc/20980000.usb/usb1/1-1/1-1.4/1-1.4:1.3/0003:0D8C:013C.0001/input/input0
[    3.480118] hid-generic 0003:0D8C:013C.0001: input,hidraw0: USB HID v1.00 Device [C-Media Electronics Inc.       USB PnP Sound Device] on usb-20980000.usb-1.4/input3

Code: Select all

pi@raspberrypi ~ $ lsusb
Bus 001 Device 005: ID 2001:3308 D-Link Corp. DWA-121 802.11n Wireless N 150 Pico Adapter [Realtek RTL8188CUS]
Bus 001 Device 004: ID 0d8c:013c C-Media Electronics, Inc. CM108 Audio Controller
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Code: Select all

pi@raspberrypi ~ $ aplay -l
**** 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 [USB PnP Sound Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
Step 2.
Here starts my troubles since I'm unable to find the "/etc/modprobe.d/alsa-base.conf" file... moreover I can't figure out how I can create my own alsa-base.conf file because every example I found are related to Raspbian Wheezy and they includes settings for the built-in audio device.

Step 3.
My .asoundrc contains:

Code: Select all

pi@raspberrypi ~ $ cat .asoundrc
pcm.!default {
        type hw
        card 0
}

ctl.!default {
        type hw
        card 0
}
Trying to change "card 0" to "card 1" makes the output of "aplay" to be correctly pushed to the USB Audio device, BUT the same does not happen for the "espeak" speech synthesizer which continues to use the built-in audio.
Moreover the .asoundrc seems to be restored to its original state on each boot.

I'm very confused about all that and I can't find a complete yet concise technical documentation about devices and alsa configuration.
I believe there are a lot of stuff which I'm not aware or conscious of...

Hope someone could help me in someways. :-)
Thanks,
Paolo.

lbp
Posts: 1
Joined: Mon Oct 26, 2015 7:07 am

Re: Raspbian Jessie and USB Audio device as default

Mon Oct 26, 2015 7:50 am

Hi!

First a disclaimer: I'm a beginner using the Pi and Raspbian, so there might be better ways of doing things than I've done... But anyway, this is how I did it.

The point is to get the usb audio device to be recognized as card 0 so it will automatically be the default audio device and also try tuning it to perform well.

First I opened (always with sudo) the /boot/cmdline.txt and added

dwc_otg.fiq_split_enable=0

on the already existing line and saved the file

Then there's a file /etc/modules where I added a line with

snd-usb-audio

before the line reading: snd-bcm2835 and saved that file.

I rebooted and nothing happened (but I later realized that if I had forced an update of the module order loding things might have worked already at this step). So I modified /lib/modprobe.d/aliases.conf next. I changed the line containing the options for snd-usb-audio index of -2 to now be 0 instead. Also I added a line at the bottom of that file reading

options snd-usb-audio nrpacks=1

Still nothing happened after a reboot (but again enforcing update of the modules order - sudo update-modules might have fixed this without the next "mistakes") and I was getting frustrated so I again modified the /etc/modules file and added the index=0 nrpacks=1 to the snd-usb-audio line. This broke the usb-audio module loading, giving a failed loading of it at the next reboot. Removing the index=0 nrpacks=1 from the snd-usb-audio line in /etc/modules and rebooting finally fixed so that my usb audio device now is the default card 0 and has so far stayed that way.

Kind regards

Lars P

lukbe
Posts: 2
Joined: Mon Oct 26, 2015 4:07 pm

Re: Raspbian Jessie and USB Audio device as default

Mon Oct 26, 2015 4:25 pm

I have this same problem with my CM108 :(

User avatar
clickcraftsman
Posts: 6
Joined: Sun Aug 30, 2015 2:51 am
Location: Melbourne, Australia

Re: Raspbian Jessie and USB Audio device as default

Thu Oct 29, 2015 12:49 pm

I have the newest kernel, Raspbian Jessie and a HiFimeDIY USB DAC on my RPi2. I had USB audio running under Wheezy before doing the upgrade to Jessie. It worked again straight away under Jessie after following advice in various forums about config settings.

I run either Mopidy or Kodi (GKreidl's 15.2RC3). Either I stream via Wifi (e.g. Spotify), or play FLACs stored on a solid state drive connected by USB. All the USB ports are in use, I am not using a hub. The RPi2 is not browning out.

However, I am not sure whether or not my 24 bit/96 khz FLACs are going directly to the DAC, or are being down-sampled to 16/44.1 by ALSA. Tracks sound good, don't get me wrong, but I am expecting to hear more clarity and dynamic range.

At least I am not experiencing any stuttering or crackling.

How can I tell what audio format is actually being delivered to my DAC?
-- Clickcraftsman
Playing HD FLACs, Spotify and movies through my Raspberry Pi 2 with Raspian + SSD + HiFiMeDIY DAC
Melbourne, Australia

Omnipotent
Posts: 4
Joined: Sun Nov 01, 2015 9:52 pm

Re: Raspbian Jessie and USB Audio device as default

Sun Nov 01, 2015 10:13 pm

Paolo,

Thank you for the great description of your problem. I am having the same issue, but know of a little information that might help.

In your step 2, apparently Raspian Jessie changes the location and name of the alsa-base.conf file. It is now found in /usr/share/alsa/alsa.conf. Information source: http://superuser.com/questions/989385/a ... bian-jesse. Unfortunately, once I found this file, I wasn't able to figure out what to do, as the format is different from what it used to be. So if anyone can figure out what to change, that'd be great.

Regards,
David

JoTil
Posts: 2
Joined: Mon Nov 02, 2015 9:09 am

Re: Raspbian Jessie and USB Audio device as default

Mon Nov 02, 2015 9:30 am

Hi all,

i experienced the same as paolo. I am running a Pi 2 with fresh installed Raspbian Jessie and see:

Code: Select all

aplay --list-devices
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 6/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 [USB PnP Sound Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
I followed the link David provided and finally got it working !!!-somehow...

I simply editet the configuration file:
/usr/share/alsa/alsa.conf

(Note: nothing else to be changed. I tested a lot including editing /etc/modules ... but was not successful)

I found two suspicious entries and simply change them. Since The USB device is detected as "card1" i changed the entries:

Code: Select all

defaults.ctl.card 0
defaults.pcm.card 0
to

Code: Select all

defaults.ctl.card 1
defaults.pcm.card 1
The part of the file where i found this now is:

Code: Select all

# defaults
#

# show all name hints also for definitions without hint {} section
defaults.namehint.showall on
# show just basic name hints
defaults.namehint.basic on
# show extended name hints
defaults.namehint.extended on
#
defaults.ctl.card 1
defaults.pcm.card 1
defaults.pcm.device 0
I suspect that there are some other settings which need to be changed....
This is a first step and i too would be glad if others with more knowledge would chime in...

Regards,

Jörg

JoTil
Posts: 2
Joined: Mon Nov 02, 2015 9:09 am

Re: Raspbian Jessie and USB Audio device as default

Mon Nov 02, 2015 11:08 am

Hi all,

just an update to my last post.
You don't have to change the alsa.conf file.
Just edit/create a file called /etc/asound.conf and insert this:

Code: Select all

pcm.!default {
    type hw
    card <number of your card>
}
ctl.!default {
    type hw
    card <number of your card>
}
This will automatically change to the desired output. In my case <number of your card> is "1" for the USB Soundcard and "0" for the standard audio jack of the Pi.
However, i don't know if the Microphone works this way (i don't have one..)

Hope this helps,
Regards

Jörg

Omnipotent
Posts: 4
Joined: Sun Nov 01, 2015 9:52 pm

Re: Raspbian Jessie and USB Audio device as default

Mon Nov 02, 2015 8:37 pm

It works!

Jörg is my hero. I followed his first suggestion about editing those two parameters in the alsa.conf file, rebooted, and my microphone input works! The only problem is that, even though the mic is working now, the audio jack has stopped working. If anyone knows what files or settings to change in order to get input from a USB microphone to work at the same time as getting output from an audio jack to work, then I would be greatly appreciative.

I also tested Jörg's second solution, and it works as well, but with the same issue.

Thanks,
David

brbrr
Posts: 6
Joined: Tue Mar 10, 2015 9:33 am

Re: Raspbian Jessie and USB Audio device as default

Sun Nov 08, 2015 11:22 am

Have same issue here. but not of these solutions was worked for me

Omnipotent
Posts: 4
Joined: Sun Nov 01, 2015 9:52 pm

Re: Raspbian Jessie and USB Audio device as default

Mon Nov 09, 2015 1:21 am

brbrr wrote:Have same issue here. but not of these solutions was worked for me
Can you explain your problem?

brbrr
Posts: 6
Joined: Tue Mar 10, 2015 9:33 am

Re: Raspbian Jessie and USB Audio device as default

Tue Nov 10, 2015 12:56 pm

I'm trying to use my USB audio card for Jessie, non of these configs did not help me.

My usb card is works ok for Wheezy, and it works for Jessie like so:

Code: Select all

$ speaker-test -D sysdefault:CARD=Device

Code: Select all

$ aplay -l
**** 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 [USB Audio Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
I've add this to /etc/asound.conf:

Code: Select all

pcm.!default {
    type hw
    card 1
}
ctl.!default {
    type hw
    card 1
}
But this wont affect anything, so $ speaker-test use builtin card for playback

schowe81
Posts: 1
Joined: Wed Nov 11, 2015 1:51 pm

Re: Raspbian Jessie and USB Audio device as default

Wed Nov 11, 2015 2:00 pm

The modified /etc/asound.conf from here http://www.linuxcircle.com/2013/05/08/r ... ound-card/ worked for me. Give it a try!

dionisis
Posts: 1
Joined: Sun Dec 06, 2015 10:11 pm

Re: Raspbian Jessie and USB Audio device as default

Sun Dec 06, 2015 10:38 pm

Hi, I have resolved this for me after consulting the following link: http://alsa.opensrc.org/Asoundrc#Default_PCM_device. In summary, I edited the ~/.asoundrc and replaced the default entries using my card's id, not the reference numbers.
First, try

Code: Select all

pi@raspberrypi ~ $ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
sysdefault:CARD=ALSA
    bcm2835 ALSA, bcm2835 ALSA
    Default Audio Device
dmix:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct sample mixing device
dmix:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct sample mixing device
dsnoop:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct sample snooping device
dsnoop:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct sample snooping device
hw:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct hardware device without any conversions
hw:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct hardware device without any conversions
plughw:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Hardware device with all software conversions
plughw:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Hardware device with all software conversions
sysdefault:CARD=Device
    Generic USB Audio Device, USB Audio
    Default Audio Device
front:CARD=Device,DEV=0
    Generic USB Audio Device, USB Audio
    Front speakers
surround21:CARD=Device,DEV=0
    Generic USB Audio Device, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Device,DEV=0
    Generic USB Audio Device, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Device,DEV=0
    Generic USB Audio Device, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Device,DEV=0
    Generic USB Audio Device, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Device,DEV=0
    Generic USB Audio Device, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Device,DEV=0
    Generic USB Audio Device, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Device,DEV=0
    Generic USB Audio Device, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=Device,DEV=0
    Generic USB Audio Device, USB Audio
    Direct sample mixing device
dsnoop:CARD=Device,DEV=0
    Generic USB Audio Device, USB Audio
    Direct sample snooping device
hw:CARD=Device,DEV=0
    Generic USB Audio Device, USB Audio
    Direct hardware device without any conversions
plughw:CARD=Device,DEV=0
    Generic USB Audio Device, USB Audio
    Hardware device with all software conversions
The first one, ALSA is the id of the Raspberry's sound chip, the second one with id Device is my cheap USB sound card dongle.
The one that works for me is plughw:Device.
Here is how I edited my ~/.asoundrc

Code: Select all

pi@raspberrypi ~ $ more .asoundrc
pcm.!default plughw:Device

ctl.!default plughw:Device
After a reboot, ~/.asoundrc is not restored to any default version. You may now check that USB sound card works in any of the following three equivalent ways:

Code: Select all

pi@raspberrypi ~ $ aplay /usr/share/sounds/alsa/Front_Center.wav 

Code: Select all

pi@raspberrypi ~ $ aplay -D default /usr/share/sounds/alsa/Front_Center.wav

Code: Select all

pi@raspberrypi ~ $ aplay -D plughw:1,0 /usr/share/sounds/alsa/Front_Center.wav 
The result will be the same, i.e. the above file will be played through the USB sound card.

User avatar
gaeran
Posts: 16
Joined: Mon Jan 28, 2013 1:15 pm

Re: Raspbian Jessie and USB Audio device as default

Wed Dec 30, 2015 9:23 am

Hi,

I found a link and this figure out my problem.
https://github.com/RPi-Distro/repo/issues/9

just replace volumealsa.so I can use USB audio without modify any files.

Regards,

Kevin.

housni
Posts: 2
Joined: Sun Jan 10, 2016 1:44 am
Location: Colombo, Sri Lanka.

Re: Raspbian Jessie and USB Audio device as default

Sun Jan 10, 2016 2:35 am

I had a very similar problem on Raspbian Jessie although it worked on Wheezy without a hitch. None of the solutions I found online worked for me.
After messing around with it for a few hours, I think I've figured it out. I've posted the solution on StackOverflow: http://raspberrypi.stackexchange.com/qu ... ian-jessie.

I'm new here, I hope it's ok to link to another site. If you want me to, I can copy and paste the contents here too.

Kristi-Juan
Posts: 5
Joined: Mon Jan 11, 2016 8:09 pm

Re: Raspbian Jessie and USB Audio device as default

Wed Jan 13, 2016 6:26 pm

Hi Housni,

Thank you for your answer! I followed your instructions and succeeded in switching the audio sources after rebooting:

Code: Select all

cat /proc/asound/modules
 0 snd_usb_audio
 1 snd_bcm2835
However when I try to record something I still get an error:

Code: Select all

arecord temp.wav
arecord: main:722: audio open error: No such file or directory
Do you have any idea what this might be causing? Thanks so much!

Lallala
Posts: 8
Joined: Tue Aug 18, 2015 4:08 pm

Re: Raspbian Jessie and USB Audio device as default

Thu Jan 14, 2016 9:17 pm

I've managed finally to set the USB sound card as the default one, however when I try to run speaker-test, then it fails with:

Code: Select all

Channels count (1) not available for playbacks: Invalid argument. Setting of hwparams failed: Invalid argument 
If I run speaker-test with option -c2, then it play back the test sound in stereo properly. How come that the default mono audio can't be played back? Any ideas?

Keops82
Posts: 1
Joined: Wed Feb 03, 2016 12:47 am

Re: Raspbian Jessie and USB Audio device as default

Sun Feb 07, 2016 11:02 am

Hi! @Omnipotent did you make works microphone and built in output to the speakers? I get works the microphone but no sound by output build in

Omnipotent wrote:It works!

Jörg is my hero. I followed his first suggestion about editing those two parameters in the alsa.conf file, rebooted, and my microphone input works! The only problem is that, even though the mic is working now, the audio jack has stopped working. If anyone knows what files or settings to change in order to get input from a USB microphone to work at the same time as getting output from an audio jack to work, then I would be greatly appreciative.

I also tested Jörg's second solution, and it works as well, but with the same issue.

Thanks,
David

pmousoul
Posts: 2
Joined: Tue Nov 24, 2015 8:41 am

Re: Raspbian Jessie and USB Audio device as default

Mon Feb 29, 2016 9:09 am

Hello everyone,

this is the best answer I've found for this problem:
http://raspberrypi.stackexchange.com/qu ... ian-jessie

Hope it helps,
cheers,
Panos

zebee
Posts: 3
Joined: Fri Jul 22, 2016 9:57 am

Re: Raspbian Jessie and USB Audio device as default

Fri Jul 22, 2016 10:18 am

So far everything looks right but I still have no sound.


I have
- edited /lib/modprobe.d/aliases.conf and commented out the usb entry

Code: Select all

 #options snd-usb-audio index=-2
- created /etc/asound.conf and ~/.asoundrc containing

Code: Select all

  pcm.!default {
    type hw
    card 1
 }

  ctl.!default {
    type hw           
    card 1
 }
- edited /usr/share/alsa/alsa.conf to change 0 to 1 in

Code: Select all

defaults.ctl.card 1
defaults.pcm.card 1

I now have

Code: Select all

pi@gulliver ~ $ cat /proc/asound/modules 
 0 snd_usb_audio
 1 snd_bcm283]5

Code: Select all

pi@gulliver ~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: CD002 [CD002], 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
I have used raspi-config to set sound to auto rather than forced to hdmi or the jack.

this works as expected:

Code: Select all

pi@gulliver ~ $ speaker-test -Dhw:0,0 -c2 -twav

speaker-test 1.0.28

Playback device is hw:0,0
But I can't get anything to play through the thing! alsamixer says yes it is the default, but aplay makes no noise. Nor does mplayer or mpc.

zebee
Posts: 3
Joined: Fri Jul 22, 2016 9:57 am

Re: Raspbian Jessie and USB Audio device as default

Fri Jul 22, 2016 11:01 am

I have now got mpc to work. I edited /etc/mpd.conf and uncommented everything in the audio-outout stanza for alsa and restarted mpd. I now have mpc playing through mpc which is what I wanted.

Mplayer still doesn't work though.

assassin
Posts: 3
Joined: Tue Jan 24, 2017 10:23 pm

Re: Raspbian Jessie and USB Audio device as default

Tue Jan 24, 2017 10:33 pm

Thank you this solved my problem with my CM108 :)

zombocom
Posts: 1
Joined: Sat Mar 25, 2017 10:18 pm

Re: Raspbian Jessie and USB Audio device as default

Sat Mar 25, 2017 10:21 pm

I am having an issue with kodi 17 jessie not recognizing the USB audio device I have done everything on this forum and still no luck, just pulseaudio setting in audio setting works

jackjaquejack
Posts: 4
Joined: Mon Apr 30, 2018 10:46 pm

Re: Raspbian Jessie and USB Audio device as default

Sat Jun 02, 2018 11:31 pm

the problem that i had was that my headphone jack didnt match the jack port on my usb audio card. some have three contacts, others four.
who knew there were differant types? adafruit didnt mention this on their usb sound card tutorial, and they sold me the usb sound card :oops:

Return to “Troubleshooting”