6

I have a USB microphone and speaker adapter connected to a Raspberry Pi 3. I have set up everything on alsamixer. I have also set the pcm.!default sysdefault:0 in file .asoundrc in the home directory which sets the USB audio adapter as the default audio card.

I have run: aplay -l and the output is:

card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
 Subdevices: 7/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 then set the pcm.!default sysdefault:0 in file .asoundrc in the home directory.

When I run the command arecord -d 5 -r 48000 test.wav I receive this error:

arecord: set_params:1233: Sample format non available Available formats: - S16_LE

Matthias Braun
  • 32,039
  • 22
  • 142
  • 171
Tonderai Ratisai
  • 533
  • 4
  • 8
  • 17

2 Answers2

15

The solution is to change .asoundrc to this:

pcm.!default {
  type plug
  slave {
    pcm "hw:1,0"
  }
}

ctl.!default {
    type hw
    card 1
}
Matthias Braun
  • 32,039
  • 22
  • 142
  • 171
Tonderai Ratisai
  • 533
  • 4
  • 8
  • 17
  • Thanks Tonderai, this worked flawlessly on Raspberry pi2 as well, using a MXL AC404 USB Conference Microphone. Apparently the device had an internal sound card with headset output so was causing some issues on my end. No I just need to figure out a snd_pcm_hw_params_t error, that I believe is derived from it reading the on board chip config instead when using ALSA. Thanks. – vsecades Mar 31 '16 at 13:31
  • This fixed issues I was having with aplay and mpg321, all without even having to reboot! thanks!! – Logic1 Aug 28 '18 at 05:41
  • Looked around for a while and this is the only solution that worked for me! However my .asoundrc file keeps getting reconfigured any time I access the volume controls in the task bar or reboot my Pi. – OJ7 Feb 01 '19 at 03:32
1

A generic configuration that works would be:

$ sudo nano ~/.asoundrc

pcm.!default {
    type asym
    playback.pcm {
    type plughw
    slave.pcm "output"
    }
    capture.pcm {
    type plughw
    slave.pcm "input"
    }
}

pcm.output{
    type hw
    card 1
}

ctl.!default {
    type hw
    card 1
}
Keiko Mori
  • 157
  • 2
  • 15