Wednesday, 29 July 2015

The Adafruit USB Audio Adapter

This USB module is recommended for the Raspberry Pi, but one of the sales bullet points for this module says "Not recommended for Mic input"

Why would you buy it just for the audio output when the Pi already has an audio output?

Well I need it for the audio input, and for just £4.77 post free from The Pi Hut via Amazon, it was worth a punt.

I bought one of these adapters 3 months ago, but didn't have the time to work out why it wasn't working. Now I have two applications which need it, so its time to take another look.

Adafruit USB Audio Module on PiB2

Since Raspbian and Lubuntu are closely related, I set to work from the comfort of my armchair using my laptop. I wanted to use "arecord" from a Gambas program, and this turned out to be my biggest problem.

Both Raspbian and Lubuntu 15.05 use the same version of alsa-utils (v1.0.27) which has a bug. Using arecord creates an audio file, plus a seemingly infinite number of small, 44 byte files.

The Pi process

Here is my recommendation for getting this running on a Raspberry Pi. Commands are entered in terminal.

Probably a good idea to start by updating Raspbian:-

sudo apt-get update
sudo apt-get upgrade

Connect the module to Pi, and connect a microphone (or suitable audio source) to the module mic input.

lsusb the output you should see: C-Media Electronics CM108 Audio Controller

arecord --list-devices

...the output should include:-

**** List of CAPTURE Hardware Devices ****
card 1: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0 

So far, so good. We will need to specify card 1 and device 0 when using arecord (e.g. hw:1,0)


Press F6 and select: "1 USB PnP Sound Device"
Select Mic
Un-mute Mic (press M) then up-arrow for maximum input level.

Download alsa-utils:
Download alsa-lib:

Extract both files.

Navigate to unzipped alsa-lib folder using file manager.
Hit F4 to open in a terminal.

sudo make install

Close this terminal and navigate using file manager to the unzipped alsa-utils folder.
Hit F4 to open in a terminal.

If you try to run ./configure you will get an error (error: required curses helper header not found), so install:-

sudo apt-get install --no-install-recommends libncurses5-dev libncursesw5-dev xmlto

...(not sure if xmlto is necessary)

Now try:-

./configure --disable-alsaconf --disable-xmlto

If no errors, then:-

sudo make install

Now try to record something:-

arecord -t wav -f S16_LE -r 44100 -D hw:1,0 -d 10 /home/pi/test.wav

...which should terminate after 10s and give you a 10 second audio file: test.wav

...without all those pesky 44 byte files.


  1. Stupid question, but could you achieve the same thing using a USB mic?

  2. Yes you could, if you can find one that is suitable for your application. For the bat detector I need one with a good high frequency response.

    And for BirdBox2016 I want one that is small enough to fit inside the top. I may have to crack open the Adafruit case and solder mic and USB connections directly to the pcb!