I get the following error when trying to record using an USB-mic through ALSA: Channel count (2) not available for playback: Invalid argument

My initial thought was ALSA wasn't able to find the microphone, but as it turns out it finds it just fine. My next thought is that it might be because ALSA want to record in stereo, and my microphone only works as mono. How would I change ALSA to run mono if that is the case? Or am I completely at the wrong track?


It should be noted I'm using a jackstick microphone into a usb converter, which then inserts to the RPi. The USB converter both have a mic input AND a headset input, which I do not use. I was wondering if it got the error, because there was no speaker on the soundcard I was using; however even when pluggin a headset into the USB-convert as well, the issue persists.

Edit2: I'm running a Simulink model on my Raspberry Pi, which needs to real-time record. If I simulate through the laptop to the raspberry pi, it works without any faults. The issue comes when I try to run the model on my Raspberry Pi for itself, then said error appears.

Edit3: Did a check with the command amixer, and got following result:

Simple mixer control 'Headphone',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 62
  Front Left: Playback 42 [68%] [-20.00dB] [on]
  Front Right: Playback 42 [68%] [-20.00dB] [on]
Simple mixer control 'Mic',0
  Capabilities: pvolume pvolume-joined cvolume cvolume-joined pswitch pswitch-joined cswitch cswitch-joined
  Playback channels: Mono
  Capture channels: Mono
  Limits: Playback 0 - 43 Capture 0 - 63
  Mono: Playback 40 [93%] [26.00dB] [on] Capture 60 [95%] [46.00dB] [on]

I assume the issue relies in the playback of the microphone in some way. Maybe some of you guys can help me clear that out.

My .asoundrc:

defaults.ctl.card 1
defaults.pcm.card 1
defaults.pcm.device 0

Edited .asoundrc:

pcm.!default {
        type hw
        card 1
        slave {
                pcm "hw:1,0"
                channels 1

ctl.!default {
        type hw
        card 1
        channels 1

Model edit: The issue still appears when having a model with following block only: https://se.mathworks.com/help/supportpkg/raspberrypi/ref/alsaaudiocapture.html

  • What exactly did you try? – CL. Apr 20 '17 at 13:41
  • Added a .asoundrc file in my home folder, containing following: defaults.ctl.card 1 defaults.pcm.card 1 defaults.pcm.device 0 Which helped me set my microphone as default device. Now I get above said error, with no clue how to fix it. I've found very limited search results of exact same kind of error. – Jon Dier Apr 20 '17 at 13:43
  • What exactly did you do when you tried to record? What program did you run? How? – CL. Apr 20 '17 at 14:05
  • @CL. Added a second edit explaining the context. – Jon Dier Apr 20 '17 at 14:56
  • Added a bit more information, giving an overview of what ASLA sees. – Jon Dier Apr 20 '17 at 15:59

Yes, it's because if you are recording directly from hardware device, you can only record in the formats, number of channels, bitrate etc. that is directly supported by the hardware. So when you do something like

arecord -D hw:0,0 out.wav

you'll run into this problem; you will either need to add the correct parameters as in

arecord -D hw:0,0 -c 1 -f S16_BE -f44100 out.wav

(of course with the parameters for your device, not these), or you can use a conversion plugin that ALSA automatically makes available for each device, as in

arecord -D plughw:0,0 ... out.wav

and then it will convert to whatever format you specify.

The same applies to any other application that tries to record via ALSA. You can also set up your own ~/.asoundrc with reasonable defaults, if you want.

Use arecord -L to get a list what devices/plugins you can record from. Possibly you'll want to use the automatically provided dsnoop plugin, but you didn't tell us what you need the recording for, and what exactly you did when you tried to record.


Ok, the missing information was:

You are using a program called Mathworks. This program has a block for audio capture, which has a parameter called Device Name. The parameter defaults to hw:1,0.

As long as this parameter is set to any hw:... value, you can write stuff into your ~/.asoundrc until you are blue in the face, and it won't change anything, because hw:... means "use the hardware directly, never mind all the other plugins specified in ~/.asoundrc".

The first step is to identify the correct device: Do arecord -l, and you'll see something like


Now change the value of the above parameter to plughw:X,Y, e.g. plughw:1,0, delete your ~/.asoundrc to remove a possible additional source of errors, and try again. plughw:... will place a plug plugin directly in front of the given hardware device as a slave.

If it still doesn't work, there are two possible reasons, and the error message you'll get will give a hint which it could be:

(1) The Mathworks block is written in such a way that it works only directly with hardware devices, not with plugins, and it has no way to change the number of channels (maybe there's an extra parameter they forgot to mention in the documentation). In that case, there's not much you can do. You could try to use dsp.audiofilereader on a named pipe with arecord on the other end, but I'm not sure how well this would work, and it's a stopgap measure.

(2) The plughw plugin should automatically convert channels IIRC, but maybe it doesn't. Then you'll have to explicitely write a plugin in your ~/.asoundrc, but let's do that only if it's necessary.

  • Thanks for your reply! Seems like I was on the right track then, I'm just missing one step. If I want to specify channels through my asoundrc (added the current contents of this to the post), how would I set that up? To record, I start a model (.elf file) on the Pi, giving me said error. And I'm using it to real-time record. – Jon Dier Apr 20 '17 at 16:48
  • Added another version of the asoundrc I made. I tried setting it up properly after reading some documention, but it still doesn't work. Maybe you can pitch in on where I went wrong. – Jon Dier Apr 20 '17 at 17:11
  • What kind of "model" do you use? What device does this "model" use? Can you configure the "model" to use a different device? Does it work if you use arecord? The first step is really to make it work with arecord. The next step is to figure out what the program you are using is doing exactly. Then you can start writing ~/.asoundrc, because then you know where the problem is. – dirkt Apr 20 '17 at 20:50
  • Added a link with the block that 100% causes the issue. I was able to record with the microphone using arecord with -c 1. I've readen through the ALSA Recording block several times, but found nothing helpful. Maybe you see something I don't. Best regards – Jon Dier Apr 20 '17 at 21:01

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.