Difference between revisions of "Raspberry Pi ALSA"

From WA2IAC Wiki
Jump to: navigation, search
m (Other Audio Systems)
m (Hot Links)
 
Line 1: Line 1:
 
== Introduction ==
 
== Introduction ==
The information on this page assumes the operating system is Raspbian, which is simply a port of Debian for ARM processors recompiled so that the entire distro suppors the floating point processor on the Raspberry Pi.
+
=== Hot off the Press ===
 +
(circa 5/29/2013)
 +
Many problems I've encountered have been caused by known problems in Raspbian (see below). Because fixes are in the pipeline, I choose to wait for them to get into the distro via updates. I'm keeping track of them here for my own benefit, you're welcome to ride along...
  
At Present, most of this is lifted from [http://jeffskinnerbox.wordpress.com/2012/11/15/getting-audio-out-working-on-the-raspberry-pi/ here]. But I'll be adding more fast.
+
As of this date, some tres importante fixes still haven't made it into the pipeline, and I'm wondering now if they will -- for the version of Raspbian I'm running. I'll be reviewing this and updating shortly. I'm still pretty frustrated at not being able to use Raspbian for the purposes I have in mind... which in the meantime are hogging up other, less suitable, but more capable hardware.
 +
 
 +
==== Hot Links ====
 +
02/09/13 Raspberry PI – getting audio working  http://cagewebdev.com/index.php/raspberry-pi-getting-audio-working/
 +
 
 +
05/29/13 Stumbled across this: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=66&t=7107 but beware of the dates!
 +
 
 +
==== mmap Kernal Update ====
 +
The mmap method for driver communication is not supported in Raspbian at present. This has been solved thanks to [http://martinezjavier.wordpress.com/2013/04/27/mmap-support-for-raspberry-pi-bcm2835-alsa-driver/ Javier Martinez Canillas]. The preceeding link will take you to the details. It was dated 4/27/2013 at this writing.
 +
 
 +
Without this kernel fix, at best, ALSA performance will be "challanged". You may also want to wait on this one.
 +
 
 +
==== Jack ====
 +
Actually, it's "jackd" (the daemon). This popular package has known problems with Raspbian, and various fixes are in the pipeline.
 +
 
 +
==== Gstreamer ====
 +
Gstreamer and friends (its associated stuff) has known problems on Raspbian. This is unfortunate, because gst123 seems to be the best solution if you want to have a single command-line player that can play mp3, ogg, and FLAC formats. I use it in applications I've built that run on other distros, so I'd like to use it on Raspberry Pi, but sadly that's not possible until the fixes are in.
 +
 
 +
=== More Introduction ===
 +
(Circa 5/2013)
 +
The information on this page assumes the operating system is Raspbian, which is simply a port of Debian for ARM processors recompiled so that the entire distro supports the floating point processor on the Raspberry Pi. See other references to this wiki at the bottom.
 +
 
 +
Googling this topic produces lots of outdated junk, so I'm writing this page to be reliable for me.
 +
 
 +
At Present, some of this is lifted from [http://jeffskinnerbox.wordpress.com/2012/11/15/getting-audio-out-working-on-the-raspberry-pi/ here]. I've been adding more fast.
  
 
I want to deliver sound from my Raspberry Pi’s (RPi) Audio Output 3.5mm jack.  I’ll need to get audio drivers working on Audio Out, and to test it, I’ll need some sound files and players.  I’m choosing the [http://www.alsa-project.org/main/index.php/Main_Page Advanced Linux Sound Architecture (ALSA)] drivers because its widely supported and because [http://en.wikipedia.org/wiki/Advanced_Linux_Sound_Architecture ALSA] not only provides audio but [http://en.wikipedia.org/wiki/Musical_Instrument_Digital_Interface Musical Instrument Digital Interface (MIDI)] functionality to Linux.  I’ll also be using the popular command line MP3 players, mpg321 and the WAV player that comes with ALSA, aplay.
 
I want to deliver sound from my Raspberry Pi’s (RPi) Audio Output 3.5mm jack.  I’ll need to get audio drivers working on Audio Out, and to test it, I’ll need some sound files and players.  I’m choosing the [http://www.alsa-project.org/main/index.php/Main_Page Advanced Linux Sound Architecture (ALSA)] drivers because its widely supported and because [http://en.wikipedia.org/wiki/Advanced_Linux_Sound_Architecture ALSA] not only provides audio but [http://en.wikipedia.org/wiki/Musical_Instrument_Digital_Interface Musical Instrument Digital Interface (MIDI)] functionality to Linux.  I’ll also be using the popular command line MP3 players, mpg321 and the WAV player that comes with ALSA, aplay.
Line 13: Line 39:
 
sudo apt-get install lame
 
sudo apt-get install lame
 
</pre>
 
</pre>
 +
 +
=== Problems to Solve ===
 +
So far, many/most operations require root privs. This is a giant step backwards. Note '#' prompt where root seems needed, else the prompt shown in examples is '$'. Of course, "$ sudo ..." is an alias for "# ...".
  
 
=== WA2IAC app-specific packages needed include: ===
 
=== WA2IAC app-specific packages needed include: ===
  
liquidsoap, ogg-vorbis libraries and tools, gst123 [these need to be documented, and anything left out added], unfortunately this horse is already out of the barn.
+
liquidsoap, ogg-vorbis libraries and tools, gst123 [these need to be documented, and anything left out added], unfortunately this horse is already out of the barn. Complete step-by-step configuration cookbook instructions will have to await the next Pi!
  
 
=== WA2IAC app notes ===
 
=== WA2IAC app notes ===
 
To be added here.
 
To be added here.
 +
 +
== /etc/alsa.conf ==
 +
=== Restarting the Audio System ===
 +
For most changes to /etc/asound.conf you will need to restart the sound server:
 +
<pre>
 +
$ sudo /etc/init.d/alsa-utils restart
 +
</pre>
 +
 +
=== Early Observations ===
 +
The stock /etc/asound.conf file looks like:
 +
<pre>
 +
pcm.mmap0 {
 +
    type mmap_emul;
 +
    slave {
 +
      pcm "hw:0,0";
 +
    }
 +
}
 +
 +
pcm.!default {
 +
  type plug;
 +
  slave {
 +
    pcm mmap0;
 +
  }
 +
}
 +
</pre>
 +
... the problem here appears to be that a 'plug' channel (?) is assigned by default, however, [[jack]] is not installed. Bummer! Causes many of the players to fail.
 +
 +
Status: non-functional -- see "Discussion Page"
  
 
== Enabling the Sound Module ==
 
== Enabling the Sound Module ==
Line 26: Line 83:
 
The snd-bcm2835 module appears to be already installed. RPi has a Broadcom  [http://www.broadcom.com/products/BCM2835 BCM2835] [http://www.androidauthority.com/how-it-works-systems-on-a-chip-soc-93587/ 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:
 
The snd-bcm2835 module appears to be already installed. RPi has a Broadcom  [http://www.broadcom.com/products/BCM2835 BCM2835] [http://www.androidauthority.com/how-it-works-systems-on-a-chip-soc-93587/ 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:
  
<pre>sudo modprobe snd-bcm2835</pre>
+
<pre>$ sudo modprobe snd-bcm2835</pre>
 +
 
 +
This appears to have been necessary in the past, but not with my contemporary release of Raspberry Pi. Still, this is good to know, particularly if other distros are to be used.
  
 
== Enabling Audio Output ==
 
== Enabling Audio Output ==
 
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.  [http://linux.die.net/man/1/amixer amixer] allows command-line control of the mixer for the ALSA driver.
 
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.  [http://linux.die.net/man/1/amixer 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:
+
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 (note root prompt!):
  
<pre>amixer cset numid=3 1</pre>
+
<pre># amixer cset numid=3 1</pre>
  
 
== Sound Check ==
 
== Sound Check ==
Line 78: Line 137:
  
 
== Volume Control ==
 
== Volume Control ==
 +
[This section needs review; not checked by WA2IAC!]
 
The RPi built-in sound chips don’t have a “master volume” control, and as a result, you must control the volume via software.  I guess the RPi views itself as a preamplifier (preamp) and volume controls would be supplied down stream.  ALSA provides a software volume control using the [http://alsa.opensrc.org/Softvol softvol] plugin.
 
The RPi built-in sound chips don’t have a “master volume” control, and as a result, you must control the volume via software.  I guess the RPi views itself as a preamplifier (preamp) and volume controls would be supplied down stream.  ALSA provides a software volume control using the [http://alsa.opensrc.org/Softvol softvol] plugin.
  
Line 116: Line 176:
  
 
== Bottom Line ==
 
== Bottom Line ==
While you can get ALSA working on the Raspberry Pi, it appears only partly supported, maybe buggy, and poorly documented.  If you just want to simply get sound out of the device (like I do), you’ll be fine.  But if you have some desire to do some sound processing with ALSA, your likely to be very frustrated.
+
While you can get ALSA working on the Raspberry Pi, it appears only partly supported, maybe buggy, and poorly documented.  If you just want to simply get sound out of the device (like I do), you may be fine, or you may find yourself in a room with doors to twisty mazes branching out in all directionsIf you have some desire to do some sound processing with ALSA, your likely to be very frustrated.
  
 
== Other Audio Systems ==
 
== Other Audio Systems ==

Latest revision as of 18:08, 19 August 2015