The Linux Audio Server Project - Revisited

Combining LIRC, XMMS, GRIP, VNC, Festival and some BASH scripting

Acknowledgements and related links

Thanks to all GNU/Linux / FLOSS developers in general and the developers of the following things in particular:
LIRC - Linux Infrared Remote Control
XMMS - X Multimedia System
ALSA - Advanced Linux Sound Architecture
FLAC - Free Lossless Audio Codec
Festival from the Centre for Speech Technology Research, University of Edinburgh
Mandriva Linux

The original 2004 vintage lirc.html page

Related files

System files:

User files:

Site news

Latest site additions:

Updated January 13rd 2008:
My LIRC page: The Linux Audio Server Project - Revisited

Added January 3rd 2008:
My (K/X/)Ubuntu review: Ubuntu - beyond the hype

Added December 2nd 2007:
My Mandriva 2008.0 review

Added November 20th 2007:
The configuration page of Mandriva Linux 2008.0

Added November 18th 2007:
The Installation walkthrough of Mandriva Linux 2008.0

Added November 17th 2007:
The review of openSUSE 10.3

Added July 8th 2007:
The Configuration page of Mandriva Linux 2007.1 Spring

Added July 1st 2007:
The Installation walkthrough of Mandriva Linux 2007.1 Spring

Added December 18th 2005:
The third and final part of my Mandriva Linux 2006 review

Added November 14th 2005:
The second part of my Mandriva Linux 2006 review

Added November 6th 2005:
The first part of my Mandriva Linux 2006 review

For older additions please see the articles page.


Return to top

January 2008: the orignal "Linux Audio Server Project" article was first written back in 2004, talking only about the LIRC setup with my headless server to use it as any other hifi element: stop, play, pause, etc. I soon needed more functionality, which was easy to implement, but which I never actually updated this article for.

Most notably, I have set my audio server up such that upon the press of a button on the remote, it will say the name of the artist, album and titel of the song that is being played. It can even do that for the songs playing on the radio, all to the astonishment of our guests. Aside that, it cuts short lots of silly arguments I sometimes had with my wife about which song or artist is on. I won't go so far as to say that this system is a saver of relationships, but it sure is practical...

So now I'm rewriting this whole article to include the updates that I have made since the orginal upload. The latest essential modification that I have done is the addition of a Nokia N770 Internet Tablet which is capable of running a VNC viewer, and the resizing of the VNCserver to fit the 800x480 resolution of the N770's display, to have a fully functional remote control. Yes, that could take the LIRC part out of the loop now, as well as the speaking HiFi, but the N770 is less impressive and more costly...
BTW If you want to read the original article as it was uploaded in 2004, use the link from the related links section at the right hand side of this page. With no further ado, here we go...

Since I have a server (paris) that is always on, I figured I could turn it into a music server, aside from being an internet/file/print/scan server. The real 'problem' in my situation was twofold: first, the server is headless mouseless and keyboardless; second, it resides in a different room than the HiFi that I wanted to connect it to.

Luckily, there is such a thing as LIRC (Linux Infrared Remote Control), which allows you to use almost any IR remote control to give commands to the programs on your computer that have a plugin for LIRC. I had some experience with LIRC due to my Hauppauge WinTV-FM (which, btw is very well supported in Linux, so don't let the product name fool you - check my configuration page -note: there are newer configuration pages but that one goes into details about the wintvfm the most - to see how to set that one up with LIRC) that comes with its own IR remote sensor and remote control. This time around, I had to build my own IR receiver, since the server had none, and I wasn't going to put a TV-card in my server just for the IR eye.
Also, the Hauppauge IR receiver only lets me use the IR remote control that came with it; I know it says (for instance in the LIRC FAQ) that the Hauppauge remote receivers should also function with any RC5-standard remote, but I tried with the various Marantz (CD-50) and Philips (Garbo Projector remote) remotes that I have lying around here, and they just don't work with the Hauppauge IR receiver.
Moreover, the living-room HiFi is a Denon, which has a remote that uses a different standard altogether.

Apart from the remote control issue, I would normally set my audio program to 'random' or 'shuffle' mode (naturally, I would want to be able to toggle the playback mode with the remote as well). But this would mean that with lots of songs, it may not always be clear which song is being played, from which artist or album. So I wanted to have a means to check, instantaneously or later, which songs got played. Since I have no displays in the living room (not even a tv), and the server has no display either, the options I had were:

So all in all, it became clear to me what I had to do, I only had to figure out how to do it. With google and some man-page reading, I figured things out and so I:

Connecting the audio server with the HiFi system was straightforward; I just got 10m of (male-cinch to male-cinch) audio cable (which was just long enough), clipped the cinch connectors off of one end and substituted that for the mini-jack that fits into the audio output of the soundcard in the server. If you don't want to modify your cable, you can also get a connector with cinch on one end and a mini-jack on the other; you can find those at most computer stores. In my case I had to cut off the connectors on one side anyway to fit through a hole in the wall.

Before jumping into details, just a little note: I use Mandriva (this project started out using Mandrake 9.2 and now runs on Mandriva 2005LE), but this should not be very different for other Linux distributions. So if you want to do something similar with another distribution just replace the Mandriva specific things with the equivalent of your distribution (in Mandriva, urpmi / RPMDrake is for program installation, MCC is for system configuration).

A last remark before diving in: at the right hand side you'll find links to all related files for this project.

Assembly of the LIRC receiver

Return to top

For the receiver, few parts are needed: a connector to the serial port (Dsub-9), one remote receiver (I got the Siemens SFH 5110, 36kHz type), one diode, one resistor and one voltage regulator. You can check on the LIRC serial page for more details. Since I needed to have the IR detector in the living room, I got a 10m serial cable with Dsub9 connectors on both ends. Again, I cut off the connector on one end. I decided to just solder all components onto eachother, so not use any pcb or so, and directly connect it to the 3 wires of the serial cable. (Note: I got the serial cable so that at some later point, I might still get an LCD...)
The assembled receiver looks as follows (front and side shot), and just to show the size, I put a centimeter ruler and a 1 euro coin next to it.

The black part most to the right is the IR eye, the other part sticking out is the voltage regulator. As you can see, I used some shrinkwrap to cover most of the parts (the resistor, capacitor and diode); before putting that on, I put some isolation between the various 'legs' of the components, so that squeezing the receiver would not short-circuit things. Before connecting to the serial port, I verified with an impedance meter that the relevant pins on the Dsub-9 connector were not shorted. My server only has 2 serial ports, and I wasn't going to lose one of those due to some silly bad soldering.... afterwards I had a talk with some colleagues and they assured me that you really need to connect some voltages higher than 12V to actually destroy a serial port, but anyway, better safe than sorry.
On the whole, I can say I was quite pleased with the end result - it is very small and thanks to the shrinkwrap quite professional looking too. On to testing the thing!

Setup of LIRC

Return to top

The next step was to setup LIRC, naturally after connecting the serial port IR receiver.
I did, as root:
urpmi lirc lirc-remotes
which installed the lirc rpm (included in the download edition cds) and the lirc-remotes package, which is in the contrib repository and got downloaded from the web. I found I didn't need the lirc-remotes because my remote wasn't included, but if yours is it saves you some time.
(Note that since Mandriva 2008.0 this should be:
urpmi lirc lirc-remotes dkms-lirc
because the lirc kernel modules have been split off for some reason.)

Configuration of lircd

Return to top

I did:
vi /etc/sysconfig/lircd
and made it look as follows: (I left out most of the lines that are commented out with a hash)

# Customized settings for lirc daemon

# The hardware driver to use, run lircd --driver=? for a list


# Hardware driver module to load


# Serial port for the receiver (for serial driver)
DRIVER_OPTS="irq=4 io=0x3f8"

I knew that I was connecting the serial connector to the first port, which is /dev/ttyS0. (This was logical as there were 4 COM ports indicated in the file.) I didn't change anything of the DRIVER_OPTS since I had no clue what else to put, and actually I figured that they would put reasonable defaults. Which I found to be true.

Be aware that dependent on which version of the lirc module you use (different distribution or different release of Mandriva), the device may be /dev/lirc/0 or /dev/lirc/lirc0 or so. On my Mandriva 2008.0 desktop with WinTV-FM card, the remote device is actually /dev/lirc/0. Make sure you adapt the above file accordingly.

Next I entered the following command:
chkconfig --list | grep lircd
to verify that the lircd daemon would be started automatically at boot time, on my server I use runlevel 3 (init 3), and the response to the previous command confirmed that all was well:
lircd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
If the above had shown 'off' for any relevant runlevel, the above setup can be had by doing:
chkconfig --level 2345 lircd on
Next, I did:
modprobe lirc_serial
Note: instead of the chkconfig-command, I could have done: Mandriva Control Center, System, Services, and selected 'start on boot' for lircd if it wasn't selected yet. It should be set to start on boot after installation of this service.
After that last command, I could tell the device got properly created (which should normally happen whenever you load the correct module for the device):
[root@paris root]# ls -l /dev/lirc0
showed me the device node:
crw-rw---- 1 root root 61, 0 Feb 5 2007 /dev/lirc0
so all seemed well from the device side.
Note that on the LIRC website, there are indications that you have to do: ln -s /tmp/.lircd /dev/lircd if you use Mandrake; my guess is that this is true only if you are compiling from source -- which is definitely not necessary in this case. That being said, it won't harm your system either.

I then verified (this you may execute as a regular user too) that the device was functional with:
mode2 -d /dev/lirc0
which gives no output, until you start pressing the remote buttons. A lot of codes flash by for each keypress if all is well. (Note that once the deamon "lircd" is running, you can no longer do this.)

Then I did, as root (as most commands here):
service lircd start
(You can also do:
/etc/rc.d/init.d/lircd start)
to which the system responded with:
Starting Linux Infrared Remote Control daemon: [ OK ]

Setup of lircd.conf

Return to top

If there is a lirc-remotes configuration file for your remote (it can be that your remote behaves the same as another one from the same factory): just copy the file for your remote control from the directory /usr/share/lirc-remotes/
cp /usr/share/lirc-remotes/[yourremotehere] /etc/lircd.conf
If it asks whether you want to overwrite the file /etc/lircd.conf you naturally have to confirm. Note that only root can do this.

In case your remote is not included in the directory /usr/share/lirc-remotes/ you are going to have to do what I did: the manual configuration to create the /etc/lircd.conf file with mode2. Just run (as regular user)
irrecord -d /dev/lirc/serial testfile
and by following instructions you will end up with a remote-definition in your current directory. As with a predefined remote you will have to copy this file over (as root) to /etc/lircd.conf:
cp [freshlycreated-remotefile] /etc/lircd.conf
You can check (after starting lircd, as explained further on) with the program/command irw whether the signals of your remote are seen and as which keypress.

Configuration of ~/.lircrc

Return to top

The file .lircrc in your user home directory is needed to setup the program response to the various remote control keys. The program needs to have a LIRC plugin (switched on, naturally). The names of the keys correspond to those in the file /etc/lircd.conf and are not case sensitive. For each program that you want to control with LIRC, you have to check what options/commands exist.
You find my configuration file here: ~/.lircrc. And for kicks, the one I use on my workstation: ~/.lircrc of zurich. (Taking a closer look at the ~/.lircrc, you may notice that I use some nesting; this is to avoid from the commands 'shuffle' and 'cancel' (PLAYLIST_REMOVE) to get executed twice -- which can easily happen since the remote I use has no toggle-bit.)

Configuration of xmms

Return to top

For the configuration of xmms, I used the xmms-lirc and songschange plugins.

Install the lirc plugin for xmms:
urpmi xmms-lirc
(don't let the IRMan entry in the plugins list fool you, this is something else! That actually cost me quite a bit of time to realise it was quite futile to try to get that one to work in my setup...)
Switch it on: options >> preferences, effect/General plugins - tab, select the LIRC Plugin [] and enable the plugin.

(BTW don't worry about the configure option, it allows you to select a font for the popup windows that you can get to select new songs -- the LIRC setup is in ~/.lircrc )
Hint on the sideline: for xine, just do xine --keymap=lirc to get all possible codes.

Now that we are there, you might as well also switch on the Song Change plugin, which can execute any command at each change of song. This I set up so that at any later moment it could be checked from any of the two computers with a monitor (mine and my wifes) which song had been playing at what time.

In my case, I chose to execute the script ~/bin/xmmssongchange which resides in the bin subdirectory in the homedir. The arguments that are passed are %f for the filename (this is the complete absolute path) and %s for the songname (if they are not between quotes, they actually get passed as if they are one single command). The script xmmssongchange takes these arguments and creates a webpage on the fly, indicating the time and the name of the song, where the name is clickable and points to the songfile on the server. Since the path is the full path as the audio file resides on the server, I had to adapt the file paths somewhat to match how this partition is mounted via NFS on the 2 other machines. Once that was correct, I could open the file with the songs that got played, and clicking any of the songtitles will start playing that song.

Note: the file xmmssongchange must of course be executable:
chmod +x ~/bin/xmmssongchange

After this the result looks as follows:

One click on any name starts playback of the corresponding audio file in Totem.
As a last remark: I use ALSA, with OSS there is quite a delay when doing next, previous, stop, etc... With ALSA, the system is so responsive it is almost uncanny. The behaviour is like a (very large) cd changer, but with no delay between the songs (which you normally get when the changer changes discs).

Note that it became tedious to have to look on a computer what the living room hifi was playing, so I added speech capabilities to my server; for this I did:
urpmi festival
which gets you the festival speech synthesis, and in the file ~/bin/xmmssongchange I have added the necessary lines to create a wav file that when played back will speak out the artist, album name and song title. Naturally, this wav file can be triggered with the IR remote control to play, so the living room HiFi system seems to speak. It's not really a dj-voice, but it does the job fine. Note that you have to have the directory songlist in your home dir for the xmmssongchange script to work (mkdir songlist), and this file must be executed to say the songname: ~/bin/speaksong

Configuration of VNC

Return to top

I ran, as user, the command:
and entered a password for the vncserver.
Next, I use a script ~/bin/ containing the following lines to start my server:

rm -f /tmp/.X7-lock
rm -f /tmp/.X11-unix/X7
cd /home/music
vncserver :7 -geometry 800x480 -depth 16
export DISPLAY=:7
xsetroot -solid navy -d :7
xmms &

As you might tell from the above commands, this starts a vncserver on display nr 7, and starts xmms in this graphical session. If you want to start this kind of thing at boot, all you have to do is (as root):
echo "sudo -u [username] /home/[username]/bin/" >> /etc/rc.local
Anyway, all I have to do to connect to that session is to point any java enabled webbrowser to the address: http://paris:5807/ and all is dandy. Naturally, it is also possible to start a vncviewer paris:7 and in either case, the password is required.

(Before you ask: yes, that is the Kaboodle KJofol skin that came with Mandrake 9.2; I just copied the skin over to the dir in ~/.xmms/kjofol ... )

As I mentioned, I have purchased a Linux based Nokia N770 Internet Tablet, for which a vnc client is available, so I can use that to connect to my music server now. It's a bit expensive as just a remote control, and luckily it can be used for so many other things too, but it is very cool for this purpose. In general, the talking HiFi is more impressive to guests, but this is more convenient to actually control the playback system.

Configuration of grip

Return to top

I use grip to add audio cds, naturally I encode to ogg-vorbis:
In the grip Config tab, go to 'Encode' and select oggenc as the encoder type; as the command line for the encoder I use:
-o %m --genre "%G" -q 8 -a "%a" -l "%d" -N "%t" -t "%n" %w
file format: /path/to/audio/dir/on/server/%A/%d/%t_%n.ogg
since the partition is mounted via nfs, direct writing to the server is possible and practical. On my workstation, ripping goes at ~5x, encoding at about ~7 or 8x. In case either grip or oggenc are not available, just do (as root):
urpmi oggenc grip

Update: I have changed my preference to ripping to flac, because of the lossless nature it's the ideal format for audio backups. A flac compressed file can be uncompressed to the original .wav file, hence it can be used to create mp3 or ogg vorbis files as well. The disadvantage that flac files are larger than mp3 or ogg vorbis file at similar perceived quality (full cd quality, ~256 kbit/s for mp3 and ogg vorbis) is not very relevant with today's hard drive prices... Soon it won't even be relevant with flash memory prices, but we're not there yet.

Tell me what's on the radio

Return to top

Since the whole system looks like a regular HiFi set (plus a cable for the audio signal from the server in the other room, plus the LIRC IR eye), acts like a regular HiFi, and indeed contains a HiFi, we sometimes also use it to actually listen to the regular radio. One channel that's quite popular in our home is Swisspop, it has no ads, just plays pop music (indeed, it is itself one big ad, and it seems the music industry is paying to get their songs to be played on this channel) and is relatively easy to have as non-disturbing background music.
The one thing that it doesn't have is DRS information about the song being played. Naturally, this is quite strange in the time and age we live in, until you visit their website, that is purely aimed at selling music. They have an overview of all the songs being played, for the whole week as well... With a bit of scripting which I put here: ~/bin/ it is easy to create the same kind of .wav audio file that tells the name of the artist, album and song.
Naturally, you can adjust this for whatever radio channel you are listening to, provided the information of what's being played is available on the web.

User setup

Return to top

Some words on the small changes I made for the user account ('music') that I use to play music. You may skip this if the only account that any 'regular' user logs onto is the one that you also use to play music.
What (Mandriva) Linux sometimes does, is attribute the audio devices (all 'files' - actually device nodes - in /dev/sound and /dev/snd) to the first user who logs onto the system. The group membership of these files is 'audio' on all my systems, but all on some Linux systems (Mandrake 9.2 for instance) files were only owner read-writable, meaning: even members of the audio group cannot read from or write to these devices (this last part is no longer true for Mandriva since a while). To end this geek-speak, this means that only the first user to log onto the system can use the audio devices; all other users get an error message when they try to play an audio file, usually something like: device busy, using null output device.
As root, it is certainly possible to change the ownership, but I used a different method: I changed the group membership of the user 'music' to be member of the group 'audio' (Mandrake Control Centre, System, UserDrake, select the user, click the tab 'Groups' in the newly opened window, and check the group 'audio').
Next I made all devices group read-writable (this should not be necessary on more recent Mandriva releases):
chmod g+rw /dev/snd/*
chmod g+rw /dev/sound/*
but only to find that msec (a security system, that I really want since this machine is always on, always connected) automatically changes file permissions according to a settings file. Naturally it took me some time to figure this out. In any case, I edited the file: /etc/security/console.perms and changed the line:
<console> 0600 <sound> 0600
<console> 0660 <sound> 0660
which then did the trick.
For those who really don't want to type out of aversion, the special copy-me service is on the next 3 lines, just execute that as root; just remember, I'm not a guru, and the responsability is all yours:
cat /etc/security/console.perms | sed 's/0600 <sound>/0660 <sound>/' | sed 's/0600' > /etc/security/console.perms-new
mv /etc/security/console.perms /etc/security/console.perms.old
mv /etc/security/console.perms-new /etc/security/console.perms

Time investment and conclusions

Return to top

Total time to figure everything out whilst implementing: 4 evenings. Total time for just the implementation (what people should count on if they follow my footsteps: 1 to 2 hours.
LIRC assembly: less than 1 hour (if you have some soldering skills; if you have none, just ask someone who has).
IRRemote Control configuration: 2 minutes if your remote is included in lirc-remotes, 10-15 minutes if it isn't or for any other reason you use irw to make a /etc/lircd.conf file by hand.
Creation of ~/.lircrc: 15 - 30 min (with my example given, it should not be more)
Configuration + installation of various programs, such as xmms, xmms lirc: 5 minutes
Setup and debugging of the songchangescript, including writing a valid html played-songs-page: 15 minutes
Creating this webpage and trying to be complete and precise about the whole process: 4 evenings or so.
Fulfilled feeling afterwards: timeless! ;-)

Since I have updated the system with speech capabilities and the VNC server to use the N770 as remote, the above can be seen in the following alternative way:
Extra cost for speech capabilities and scripting: a few more hours.
Cost of N770: a few hundred dollars (well, Swiss Francs, but they're almost on par..).
The look on the faces of guests when the HiFi system tells them which song is playing: Priceless!

Valid HTML 4.0!
Page first created: January 2004. Page last updated: 2008-01-14 21:50

Pages tested with but not specifically made for: lynx, konqueror, galeon, Opera, Mozilla, Firefox using, Quanta + and the Gimp on Mandriva Linux by aRTee
All contents © copyright 2003 - 2007, unless mentioned otherwise, published under the GNU Free Documentation License (FDL) by aRTee. Artwork and CSS don't fall under the FDL, standard copyright applies. Tux image from Larry Ewing. You may use anything published under the FDL on this site freely, as long as you include this copyright notice and a reference to the main address of this site: