Raspberry Pi microphone setup with USB sound card

Two options of attaching a microphone into Raspberry Pi. One is to have USB mic, another to have an external USB sound card. Regardless the choice, the following instruction will work in setting up some basic microphone setup, before doing something cool like recording music, or experimenting with voice recognition modules. A generic such USB sound card as the ‘Sound Blaster Play!’ dongle can be purchased for this exercise.
1. Plug in the dongle and check the version of your sound card with lsusb:
$lsusb
Bus 001 Device 004: ID 041e:30d3 Creative Technology, Ltd Sound Blaster Play!
2. To enable USB audio output, load the sound driver:
$sudo modprobe snd_bcm2835

To prevent the internal sound card to appear at the top comment out line, and change index from -2 to 1:

$sudo nano /etc/modprobe.d/alsa-base.conf

options snd-usb-audio index=1

3. Enable USB audio output by default

$sudo nano /etc/asound.conf

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

4. Reboot now:

$sudo reboot

5. To record:

$arecord -D plughw:1,0 -f cd test.wav

6. To playback:

$aplay test.wav
7. You may want to adjust some volumes:
$alsamixer
8. To save your settings:
$sudo alsactl store
Have you tried anything cool with a microphone on your Raspberry Pi? Please share your experience here.

Viewed: [post_view]

(Visited 57,729 times, 2 visits today)

10 thoughts on “Raspberry Pi microphone setup with USB sound card”

  1. Urbano says:

    Hello. I’m trying to make a soun studio about the acustic contamination in my classroom, so I need that my raspberry can check the volmune or intensity or db about the sound. Can you help me ? 🙂 Ty

  2. Dipto Pratyaksa Dipto Pratyaksa says:

    Hi, sure, you can hook RPi to external sound sensors or simple microphone, and write a python program to detect the decibels.

  3. Avichal Sahai says:

    arecord -D plughw:0,0 -f cd test.wav
    sir i think it should be,
    arecord -D plughw:1,0 -f cd test.wav

  4. David Bendell says:

    Hello Urbano. Did you have any success with this project? Could you share some details of how you did this? Thanks.

  5. Yusuf Mayet says:

    Hi, can you tell what sound card you are using. I am using a C-Media based one, and really struggling, because I am just getting static. This seems to be a common problem with C-Media chipsets. Would love to know which sound card you are using?

  6. John Walsh says:

    I tried the Logitech H390 headset with PocketSphinx Speech Recognition application but failed to get PocketSphinx to recognize the microphone. This was because it was recording in stereo.

    It clearly had both mono and stereo record modes that showed up in alas mixer, but I could not figure out how to make alas use the mono channel.

    Does anyone know a way to achieve this?

    I am currently awaiting delivery of a mono microphone and will try again but need to know how to fix the stereo record problem.

    John

  7. Dipto Pratyaksa Dipto Pratyaksa says:

    You can also try the analog to digital converter chip in between the mic and gpio pins, it will take in voltages as bits, the more bits there are, the noisier the room is. https://www.adafruit.com/product/856

  8. Dipto Harendra Pratyaksa says:

    Sound Blaster Play was used in this case
    http://au.creative.com/p/sound-blaster/sound-blaster-play

  9. Dipto Harendra Pratyaksa says:

    Depending on the devices you have connected, you could re-arrange the numbers

Comments are closed.