Music on the LAN with SlimServer

Music Box


If you have a LAN in your home or office, why not use it for something really important - listening to music?

By Kevin Donnelly

www.sxc.hu

If you share a house with other people, particularly teenagers, you will have had the experience of looking for one of your CDs, finding it after a long search under piles of clothes and papers, opening the case, and discovering that the CD is not actually in the case. After one too many of these searches, I decided to avoid this sort of frustration by setting up instant access for everyone in the house to our entire music collection at the click of a mousebutton - Jean-Philippe Rameau, Roxy Music, and up-and-coming Welsh songstress Meinir Gwilym would then be at our beck and call!

What is Available?

Media software for Linux has come a long way in the last 2 years. In KDE, for instance, Juk [1] and AmaroK [2] are widely agreed to be a big step forward in managing music. Such programs allow you to set up a playlist on one PC and listen to it either on that PC or streamed to another location. (In versions of AmaroK before 1.2, the streaming functionality sometimes did not work properly [3].) An alternative to desktop programs are web-based music managers such as Ampache[4], Zina [5], or the more recent Jinzora [6]. These tools are usually multi-user, but on the debit side, they can sometimes be difficult to set up.

My requirements for this project were fairly specific - one box (preferably easily installed and configured) for all the music in the house, served to as many PCs as wanted it, with each listener able to control his playlist independently, and with full support for ogg files. Ideally, I also wanted some way of using a non-PC output as well, just in case I someday decide to pipe the music to the living room and don't want to put a PC there.

After reading around a bit, and testing some of the available software, I came across the Slim Devices website [7], and it rang a bell. Founded in 2000, Slim Devices was one of the first companies to use open source software as an adjunct to specially-designed hardware. In 2001, it released the SLIMP3, a small box that played an mp3 stream over the network, removing the need to use a PC-based player. In 2003, the next-generation product, called Squeezebox, appeared. The new Squeezebox 2 player was released a couple of months ago. A Perl-based GPL'ed server called SlimServer was written to provide a music stream for Squeezebox - company and community input for the project apparently amounts to 9 person-years of development time so far. The important point about SlimServer is that it can be used independently of the Squeezebox devices to stream music to PCs or, indeed, to other non-PC players. I decided to install SlimServer as a music server for my home network.

Installation and Configuration

The PC I used as my music server machine was a 7-year old box that was gathering dust. It has an AMD K6/450 processor and 128Mb of memory. I upgraded the firmware last year to allow the MSI mobo to access drives larger than 20Mb, and two 80Mb drives are currently installed. The main advantage of older machines like this is that they tend to run cooler, and they are therefore quieter than modern boxes. (This one could conceivably be used in the living room if its case was prettier and smaller!) The big disadvantage, of course, is that they can be quite slow when doing things like reindexing the music collection. (In this case, the actual CD ripping was done on faster machines, and the finished files were transferred over; see the box titled "Tag that Track" for some tips on ripping and tagging your music).

The first step was to install SUSE 9.2 on the music server box, which I called Tigris. I set up a user account and logged in. I downloaded the SlimServer Linux rpm and installed it - I used version 5.4, but a beta of version 6 is now available on the Slim Devices website. The rpm is built for Red Hat, and although it runs fine on SUSE, the startup scripts don't work correctly. However, you can run /usr/local/slimserver/slimserver.pl to start the server. If you get a message about /etc/slimserver.conf not being writable, chown it to your user.

You may want to tie SlimServer into the SUSE startup system (if, for instance, you want to set it to start automatically after a reboot). Pascal Scheffers has contributed an init script for SUSE 9.1 [8], which also seems to work for SUSE 9.2. To use it, highlight the script and save it as /etc/init.d/init.d/slimserver. Then make a symbolic link to rcslimserver by typing (as root) ln -s /etc/init.d/init.d/slimserver /usr/sbin rcslimserver. I prefer to run SlimServer from the tigris user account I set up previously rather than from the slimserver user account set up by the rpm, so I then alter three of the lines in /etc/sysconfig/slimserver:

SLIMSERVER_USER="tigris"
SLIMSERVER_CFG="/home/tigris/.slimserver.conf"
SLIMSERVER_LOG="/home/tigris/.slimserver.log"

These changes keep all the relevant files (including the two slimserver database files) in one place.

Next, create the .slimserver.conf file:

touch .slimserver.conf

and finally, as root, edit /usr/local/slimserver/slimserver.pl by commenting out line 762:

#     $0 = "slimserver";

to allow the init script to shut it down properly. Now, you can control SlimServer by running (as root) slimserver start|stop|status.

SlimServer contains its own webserver, running on port 9000. The next thing to do is to access the web server either from the music server itself (by typing http://localhost:9000 into the browser) or from another PC on your LAN (by entering the IP address or hostname into the browser - http://192.168.0.6:9000, or http://tigris:9000). (For the most part, the following description assumes you are now working from another PC, using it as a client to the music server.)

Once you have connected to the server, select Server Settings in the left-hand pane. Enter a folder for your music and press Change, and then enter a folder for your playlists, and press Change (Figure 1). If you don't specify a playlist folder, you cannot save or load existing playlists. Finally, press Rescan to list the music. This command can take some time if you have a lot of tracks. Finally, click on Home | Browse Artists to see your music sorted by artist (Figure 2). Clicking on an artist's name will show the albums associated with that artist, and clicking on the albums will show the tracks. You can also go straight to albums or genres from the homepage.

You might think that you can then start creating a playlist, but SlimServer requires that a player make a connection first.

Figure 1: Enter a music folder and a playlist folder on the Server Settings page.

Figure 2: The Browse Artists page shows the artists sorted by name.
Tag that Track

If you are going to the trouble of setting up a music server, it pays to spend a little time thinking about standard conventions for your filenames and metadata tags. Linux has a number of good rippers. Of the leading contenders, I prefer KAudioCreator, which I find easier to use than Grip. I use "artist name" and then "album" as directories, and then "track number-track title-artist name" as the filename. You can specify your own naming schema by going to Settings | Configure KAudioCreator | Encoder | Wizard and using the buttons to build up the directory tree and filename (Figure 3).

You can look up CDs in the CDDB database to speed up ripping, but note that the CDDB information for most compilation albums will break the schema above. The album artist is usually listed as "Various," which is OK, but most tracks also seem to have "Various" listed as the artist and the actual artist mentioned only in the track title. In these cases, you can adjust the filename before ripping by double-clicking the first track and changing the artist and trackname entries as desired. Next Track will then move the window to the next track. Note that, if you change the album artist and then click OK, KAudioCreator will ask you if you want to replace the track artist as well - remember to select No if you have edited track artists separately. If you are transferring your tracks from one PC to another via Konqueror's built-in ssh protocol, fish, the application may stumble on accented characters in the filenames.

While ripping, you may get a popup from KAudioCreator that damage has been detected on the CD. It is usually safe to ignore these messages - the ripping continues in the background anyway.

An alternative to editing the filename before ripping is to edit it afterwards using Jerome Couderc's EasyTAG [12], which is included on the SUSE 9.2 disks. To use EasyTAG, select Scanner | Rename File in EasyTAG, and adjust the entry in the Scan File Name field (Figure 4). (It may help to switch on the masks and legends information by clicking those two icons on the Scanner window's icon bar.) Then click on the file whose name you want to change. (You can select multiple files by clicking the first and shift-clicking the last.) Click the green scanner icon to scan the selected file(s). The highlighted files will turn red to show that they have been edited. Finally, click the Save icon in the main window to save the changes.

Renaming files is not EasyTAG's main role, however. EasyTAG is used to write metadata for mp3, ogg, flac, and other filetypes, and it is probably the current best-of-breed Linux application for slicing and dicing metadata tags. You can set a particular directory to be scanned on startup by choosing Settings | Preferences | Browser tab. After adding new files to the directory, you can add them to the display by right-clicking the directory in the file tree and choosing Refresh Tree.

Files that are deficient in some way (for instance, a file with an important tag like Title missing) are shown in red (Figure 5), as are files that have been edited but not saved, or whose filenames contain characters that EasyTAG does not like (one of which, surprisingly, seems to be the question mark). You can apply a tag to more than one file in one step - to mark a number of files as coming from a particular album, highlight the files, enter the name in the Album field, then click the button to the right of the field, and finally click the Save icon. The scanner also offers a way to write the tags based on the filename of the track, but in my experience, this feature does not work reliably.

If EasyTAG cannot see files in your directory, first check that they have the correct metadata by using vorbiscomment -l filename.ogg. One version of KAudioCreator needed to have the permissions changed from 644 to 655 and back again before the file could be seen. There are also other anomalies - one version of Grip put a number instead of a name into the genre field, as a result SlimServer tended to crash.

Figure 3: You can specify your own naming schema in KAudioCreator.

Figure 4: Use EasyTAG to edit a filename after ripping.

Figure 5: EasyTAG marks deficient or unsaved files in red.

Play that Music!

The easiest way to get started with SlimServer is to access it using a music player like XMMS from a client PC. From the client, start XMMS and click Add | URL. Enter http://<ip address of the music server>:9000/stream.mp3 and press OK. You will hear nothing, because there is nothing to play, but if you click Home on the SlimServer webpage, you should now see a new entry under Settings, which will say something like Player Settings for 192.168.0.50 (or whatever your client's IP address is). Clicking on this entry allows you to set a name for the client and also adjust settings such as the display format for your track information (Figure 6).

Figure 6: Adjust display settings and set a name for the client on the Player Settings page.

On the SlimServer webpage, browse (via artist, album, or genre) to some tracks, and add them to the playlist in the right-hand panel by clicking the + beside the name in the left-hand panel. Clicking the + beside an album name will add all the tracks from that album (although you can change this behavior in Settings). Note that you may have to refresh the browser to see the new play-list entries - this usually happens automatically, but in practice, it seems to vary depending on browser, version, and wireless/wired connection. Finally, press Play above the playlist (Figure 7).

Figure 7: Manage your playlist in the SlimServer Playlist pane.

After a short delay caused by XMMS buffering, you should hear your music on the client PC. So far so good, but buffering is a major drawback to using a streaming client like XMMS. If you change tracks by double-clicking on another track, it can take as much as 10 seconds for the sound coming out of XMMS to change. This annoyed Richard Titmuss so much that he wrote a Java emulation of the Squeezebox device called SoftSqueeze [9]. SoftSqueeze is better at syncing with SlimServer than an ordinary music player like XMMS would be, and it also uses the TCP-based slim protocol, which helps SoftSqueeze traverse firewalls if you want to listen to your home music in the office. The drawback is that, as a Java program, it can eat quite a few processor cycles.

To install SoftSqueeze, first download the Java mp3 plugin from the Sun site [10], unzip the file, and move the mp3plugin.jar in it to the /lib/ext directory under your Java Runtime Environment (on SUSE 9.2 this is /usr/lib/jvm/jre/lib/ext). Next, download the SoftSqueeze zipfile from its website (note that versions up to and including 1.17 seem not to work with SlimServer 6beta - you need to use SlimServer 5.4). Unzip, and run java -jar SoftSqueeze.jar. Once SoftSqueeze launches, the Preferences dialog will open (Figure 8).

Figure 8: The SoftSqueeze Preferences dialog appears the first time you launch SoftSqueeze.

On the Basic tab, enter the IP address of your music server in the Slimserver Hostname field, and (since the default slim skin is a bit too big) choose slim-small for Softsqueeze Skin (Figure 9). (The default skin mimics Squeezebox, but the other skins are nice too.) Press OK. If the app starts jumping around the screen, don't panic - this is due to a Java bug, which is fixed in Java 1.5. Just move it to a corner of the screen and it will calm down.

Figure 9: The SoftSqueeze music player.

The Squeezebox's controller is emulated too (Figure 10). Click the down-arrow at the bottom-left to get a vertical controller and the right-arrow to get a horizontal controller. If the keypad obscures the player, hold down Alt and drag the keypad out of the way with the mouse. On the controller, the left and right arrows step out of and into the menus, and the up and down arrows move up and down through the options. The easiest way to control SlimServer is, in fact, through the web interface, but note that sometimes, if you have pressed Pause on the controller, you may also have to press it again before you hear the music, even if you have selected Play on the webpage.

Figure 10: The SoftSqueeze controller emulates a Squeezebox controller.

Getting on Down

Your users may include younger adults, or people with fat fingers, so it may be a good idea to simplify access to Slimserver. You can do this easily by adding two icons to the desktop. The first icon will launch SoftSqueeze, and the second will open that client's webpage in Slimserver. For the player, right-click the desktop and choose Create New | File | Link to Application. On the Application tab, enter java -jar `/path/to/SoftSqueeze.jar' as the command. For the server page, right-click the desktop and choose Create New | File | Link to Location (URL). In the box, click and paste the URL from the webpage - this will include something like ?player=19:b8:89:b8:37:68 at the end, which is a fake MAC address that SoftSqueeze passes to SlimServer to identify the client. You can then tell your users to click the player icon first, then click the server icon and start choosing their music.

The number of clients you can support depends on your network bandwidth, but on a home LAN at my house, Tigris can support 4 users with no problem (although the CPU is working pretty hard at that point!). It also works fine with a wireless laptop client - I'll be working in the garden this summer, I think!

The one drawback that SlimServer seems to have is that each client's playlists seem to be accessible from any client simply by selecting the relevant client name in the drop-down box at the top right of the webpage. You therefore need to hope that users will not mess about with other users' lists. The settings are also available from any client, although there is a plugin (Michael Herger's NoSetup::Plugin.pm) that will lock these down.

SlimServer has many useful features and a lively community around it, with a very busy mailing-list and howtos on such varied topics as playing WMA and AAC files, using album art, and receiving Internet radio. You can also install SlimServer on a Buffalo LinkStation for an ultra-neat, low-priced music server [11]. One of its main attractions is that it can be used as a single source for periodic refills of a Linux-friendly portable player (see the box titled "Out and About").

Squeezebox2, especially the wireless version, is now on my list of desirable new additions to the living room. The new box offers increased range, and the ability to play Internet radio directly, without going through a PC. A bridging feature allows non-wireless devices (like a PlayStation) to connect to a wireless LAN and the Internet through the Squeezebox2. When considering buying one of the music appliances now coming onto the market (see the box titled "Players Everywhere"), it is worth taking the time to ask whether the companies behind these products are actually prepared to support Linux at all, never mind support the development of a GPL'ed application like SlimServer. Buying products from those companies that do support Linux, as opposed to similar products from companies that don't, is a good way to encourage manufacturers to support Linux.

Out and About

Even though SlimServer allows you access to your music from virtually anywhere, you still need a PC or music player device such as Squeezebox2 to access SlimServer. If you are traveling, though, it can be nice to take a subset of favorite tracks with you in a small package, hence the rise of portable players. I personally consider Apple iPod/iTunes one of the biggest cons in consumer electronics - for me, key features in any player are full accessibility from a Linux box, the ability to play ogg files as well as mp3s, and no digital rights encumbrances. A flash-based player currently offers size advantages over hard-disk based players, and ideally the player should run on an ordinary battery, so you don't have to worry about recharging cables, power points, and so on during your journey.

I spent some time looking for one player that meets all these requirements and eventually picked the iAudio G3, from the Korean company Cowon [13]. This is a very stylish little player that also offers FM wireless and digital recording, but although the USB file transfer apparently works with no problems on other Linux distributions, on SUSE 9.2, transferring files will result in a hard lock of the PC, requiring a reboot. This problem probably has something to do with subfs (and appears to be fixed in 9.3), and to avoid it, you need to manually mount the player.

First of all, you need to know what device the player is assigned to. Open a terminal, and (as root) enter tail -f /var/log/messages. Connect the USB cable to the player and plug it into your PC. The terminal will show the player being detected - for instance, on a non-SATA system, it might be assigned to sda1, while on a SATA PC, it might be sde1. By this time SUSE 9.2 will probably have offered to open a file browser - refuse this offer. In another terminal, go to root, and enter umount /dev/sde1 (or whatever device your drive was assigned to). Make a mount directory:

mkdir /media/iaudio

and then mount the player by entering mount /dev/sde1 -t vfat -o users,gid=users,umask=002 /media/iaudio.The additional options are necessary to allow non-root write access to the player. You can then open Konqueror at /media/iaudio/music and drag and drop your music files into that directory.

Players Everywhere

A rash of new hardware is now appearing to take advantage of the increasing trend towards centralizing your music in one place, but a brief review suggests that not much of it is Linux-friendly!

The product most similar to Squeezebox2 is the Roku Soundbridge [14]. This product can use SlimServer 5.4, and users may even get some email support from Roku. However, Roku notes that the SoundBridge is "optimized for Windows Media Connect and iTunes," and that they have tested the SoundBridge with SlimServer "on Windows and Macintosh platforms, but not Linux." The Netgear MP101 [15] is similar to Squeezebox2 as well, but it seems to play only mp3 and WMA files and requires Microsoft Windows as the server platform.

Various "multimedia hubs" will handle photos and videos as well as music - examples are the D-Link MediaLounge DSM-320 [16], the ViewSonic WMA100 [17], the Prismiq MediaPlayer [18], and the Philips Streamium SL300i [19]. None of these seem to play ogg files, and most are completely dependent on a TV for user interaction (though the Streamium has a small onboard display). They also seem to require Microsoft Windows as the server platform, using either Microsoft Media Server or their own software.

One step up in cost are boxes like the the Hifidelio [20] and the Sonos ZonePlayer ZP100 [21]. The former is an all-in-one box that rips and stores the music tracks, as well as providing access to them. It plays ogg files, but PCs apparently need to use iTunes to connect to it (and there is as yet no native port of iTunes to Linux). The ZonePlayer is by far the best-looking of these media players, with a PDA-style remote control, but it is also the most expensive. Although it does not support ogg files yet (but apparently will shortly), it is the only media player appliance apart from Squeezebox 2 to specifically support Linux as a server, via Samba (although Red Hat 9.0 is the only distribution officially supported).

INFO
[1] http://developer.kde.org/~wheeler/juk.html
[2] http://amarok.kde.org/
[3] http://marc.theaimsgroup.com/?l=suse-linux-e&m=110822924029212&w=2
[4] http://www.ampache.org
[5] http://pancake.org/zina
[6] http://www.jinzora.org
[7] http://www.slimdevices.com
[8] http://lists.slimdevices.com/archives/developers/2004-July/009722.html
[9] http://softsqueeze.sourceforge.net
[10] http://java.sun.com/products/java-media/jmf/mp3/download.html
[11] http://fieldnetworks.com/slim/linkstation.html
[12] http://easytag.sourceforge.net
[13] http://eng.iaudio.com
[14] http://www.rokulabs.com/products/soundbridge/index.php
[15] http://www.netgear.com/products/details/MP101.php
[16] http://www.d-link.com/products/?pid=318
[17] http://www.viewsonic.com/products/tventertainment/wirelessmedianetworks
[18] http://www.prismiq.com/products/product_mediaplayer.asp
[19] http://en.streamium.com/whatisstreamium
[20] http://www.hermstedt.com/english/hifidelio
[21] http://www.sonos.com