15
Jun

Audio Configuration in Raspberry pi

When you know how it is really easy to set up the audio system. The only thing you have to do is loading the audio module, install alsa and unmute the sound. So let’s do it step by step.


colorful-sound-boxes-Wallpaper.redimensionado

1) Configuration

First of all you need to load the sound module at boot. This is easily done with the following commands :

1
2
echo "# Load snd-bcm2835.ko at boot" > /etc/modules-load.d/snd-bcm2835.conf
echo "snd-bcm2835" >> /etc/modules-load.d/snd-bcm2835.conf

After that it is necessary to install Alsa packages:

1
2
pacman -S alsa-utils
reboot

After rebooting you should use alsamixer to unmute the loud speakers. Just type:

1
alsamixer

Simply press the letter “M” on your keyboard to unmute, you should see the letter change to a number. You can raise or lower the volume with the up and down arrows. When you’re done press the “Esc” key.

To text if the system is working just type that and you will hear just noise.

1
 speaker-test -c 2

2) Microphone

One problem that the Raspberry-pi has is that it hasn´t microphone input so it is not possible to plugin one with out additional hardware. One possibility is buying an external usb sound card. I am afraid that is not a high performance solution but it could be enough for a general purpose.

soundCard
if you plug into a usb hub and type :

1
lsusb

You will see that the usb is already set up :

1
2
3
4
Bus 001 Device 002: ID 1a40:0101 Terminus Technology Inc. 4-Port HUB
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter
Bus 001 Device 004: ID 0d8c:000e C-Media Electronics, Inc. Audio Adapter (Planet UP-100, Genius G-Talk)

It is possible to use it by default for that edit asound file :

1
sudo nano /etc/asound.conf

And add the these lines:

1
2
3
4
5
6
7
8
9
10
pcm.!default {
  type plug
  slave {
    pcm "hw:1,0"
  }
}
ctl.!default {
  type hw
  card 1
}

After that if you reboot you will see the changes:

1
sudo reboot

3) Recording Audio

If you want to record audio you have tu plugin your microphone and type :

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

Pressing ctr+z will cancel the process. In order to listen the sound recorded type :

1
aplay test.wav

4) References

1) How to set up the sound system
2) Usb microphone in the Raspberry-pi

5) Conclusion

It was really easy, but from here you have access to the sound system that is a powerful feature. From here, let’s do the Raspberry talk.

2 comments

Hermes

November 23, 2014 at 12:07 am

Hello, in the actual version of Raspbian, I can’t find the astound.conf file. How can I configure the usb interface?

Thanks

Reply #

Jorge

November 24, 2014 at 8:36 am

Hi,
Please, if it doesn´t exist try creating a new one in the location /etc/asound.conf.

Reply #

Leave your comment