terça-feira, fevereiro 19, 2013

Project 7 - Raspberry Pi - Enabling Audio

While digging around in the Raspbian libraries I has a nasty surprise. The audio implementation is based on the hateful ALSA.... Good grief! I dabbled in it in the 90s when I tackled the SUSE 4.0 OS... To make matters worse, we've also got pulse-audio. Still shocked by the news I knew I was going to have a bit of a fight enabling analog audio coming out of the Pi. It's a shame that the Raspbian OS is having such a problem from the get-go. I'm also really quite surprised that the guys who built the Pi had to put out a 'full' distro like Debian to begin with. I mean, I suppose that it's designed to showcase the device's potential, but let's call a spade a spade - it's an ARM processor and little baby system, it's not designed for a full-on PC distro.

I really think they'd have done a lot better trying to use either Gentoo or Slax to start things off - Linux distros based on modularity and control instead of full-function. Gentoo is designed just for this type of product - fairly fixed hardware specs and a limited amount of memory. It's the perfect "embedded system" linux and would work wonders.

Gentoo can be a bitch to install but if Raspberry just came up with a base build it'd probably be marvelous. Then again, it could do the same thing with the debian system it has - I suppose it all depends on what it's trying to get the most out of (the hardware, in gentoo case, or the software library, in debian).

Oh well, we can't have everything on a plate...lol


To get things going, I installed ALSA, a MP3 tools, and a WAV to MP3 conversion tool via the following commands:

sudo apt-get install alsa-utils

sudo apt-get install mpg321

sudo apt-get install lame


The snd-bcm2835 module appears is already installed (see picture below). 


RPi has a Broadcom  BCM2835 system on a chip (SoC) which is a High Definition 1080p Embedded Multimedia Applications Processor.  snd-bcm2835 is the sound driver.  If  lsmod doesn’t list the snd-bcn2835 module, then it can be installed via the following command:

sudo modprobe snd-bcm2835

By default, the RPi audio output is set to automatically select the digital HDMI interface if its being used, otherwise the analog audio output. You can force it to use a specific interface via the sound mixer controls. Amixer allows command-line control of the mixer for the ALSA driver.

You can force the RPi to use a specific interface using the command amixer cset numid=3 N where the N parameter means the following: 0=auto, 1=analog, 2=hdmi.  Therefore, to force the Raspberry Pi to use the analog output:

amixer cset numid=3 1

Ready for the big test:


Success!!! Audio working...

The VLC is still buggy. That's why I used the Music Player. I've got to investigate the VLC some more...

Happy hacking. You don’t learn to hack – you hack to learn…


1 comentário:

Anónimo disse...

Porque é que o som não fica disponível no arranque como no windows?