12

I am facing a similar problem as described in this question. However I am running Jessie on Raspberry Pi and that it does not have a /etc/modprobe.d/alsa-base.conf file.

So can someone tell me where and how to set the default input and output audio device on Jessie.

  • You could just try creating that file; I don't know if it was removed because of something to do with device tree, and if so whether that will make any difference. What they are called actually doesn't matter (beyond determining the order in which they are read), as long as they end in .conf. It's what's in them that counts. – goldilocks Dec 23 '15 at 15:13
  • ok I will create it but then what will the contents of the same. Should I add just one line "options snd-usb-audio index=0" ?? – Parth Doshi Dec 23 '15 at 15:19
  • I think there are two lines suggested there, that one and options snd_bcm2835 index=1. – goldilocks Dec 23 '15 at 15:21
  • Hi i tried adding the same but still the default is the snd_bcm2835 only. I also did a reboot – Parth Doshi Dec 23 '15 at 15:50
  • Leave that there, and if you aren't using device tree for anything (e.g. I2C), try adding device_tree= (with nothing after it) in /boot/config.txt to disable it, then reboot again. If that doesn't work, you might as well remove that line from config.txt so you do not forget later. – goldilocks Dec 23 '15 at 15:54
9

Ok, first delete the file /etc/modprobe.d/alsa-base.conf Raspbian Jessie does not use this config file like Wheezy did.

To find what address your device uses you need to first enter the command aplay -l this shows all audio output devices, and their address. For example, my USB sound card comes up as device 1 in the output which looks like this.

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 1: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

Now, to set the device to your default card you will need to edit the file /usr/share/alsa/alsa.conf with the command sudo nano /usr/share/alsa/alsa.conf scroll down until you find the lines

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

and change them to (if your device is also listed as device 1, if not change the 1 to whatever address it was listed at)

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

Explanation: USB sound cards are registered as card 1 on Raspbian Jessie. On Wheezy they would be registered as card -2 by default and editing /etc/modprobe.d/alsa-base.conf would change that.

I do not know if this next step is necessary but without it my card wouldn't work.

Create and edit the file ~/.asoundrc by using the command sudo nano ~/.asoundrc and change it so that it only reads this:

pcm.!default {
    type hw
    card 1
}

ctl.!default {
    type hw
    card 1
}

Now your default audio out (speakers) and audio in (mic) are your usb device.

  • @ParthDoshi I edited the question, in case you aren't using a USB sound card. – Patrick Cook Dec 23 '15 at 18:53
  • thanks Patrick for the quick reply. I will check this and let you know. I am using a USB mic as input and audio speakers as output. My speakers are connected via a 3.5 mm audio jack. – Parth Doshi Dec 23 '15 at 18:54
  • @ParthDoshi so your speakers are using the standard sound card on the pi? – Patrick Cook Dec 23 '15 at 18:55
  • yes they are using the standard sound card. I did a test by running the speaker-test command...I am able to play a sample mp3 file on my PI that I can hear via my speakers clearly, The only problem is the mic as of now – Parth Doshi Dec 23 '15 at 18:56
  • Ok, then you do not need to change one of the lines in those files, I'm figuring out which line right now. – Patrick Cook Dec 23 '15 at 18:57
4

Question is referring to another post which has already an answer that simply states that with Jessie there is no need to edit /usr/share/alsa/alsa.conf, just create ~/.asoundrc and type in

pcm.!default {
    type hw
    card 1
}

ctl.!default {
    type hw
    card 1
}

PS: I just tested it with a clean installation on a raspberry 2 connected with Logitech Z-5 speakers, works perfectly

3

If you have a different device for input and output (e.g. usb mikrophone and 3.5mm audio speaker), you can write it like this in your ~/.asoundrc:

pcm.!default {
  type asym
  playback.pcm
  {
    type hw
    card 0
    device 0
  }
  capture.pcm
  {
    type hw
    card 1
    device 0
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.