A Simple Linux Based Network Audio Appliance
by Ole Schüsseler
Why?
Working mostly in front of a PC, I appreciate the ease of
selecting music from my library without having to look for CDs and
handling them. This comfortable listening is something I missed in my
main system where I need to leave my seat every time I want to change
the media. Also, my player often fails on CDR media, which is just
annoying. Of course I could just buy a Squeezebox, but I'd like to DIY
better.
Recently, I got Yeo's USB-SPDIF converter. Unlike most PC sound cards
or onboard SPDIF interfaces, it outputs audio data with 44.1kHz
sampling rate, which means there is no resampling of the original. What
it outputs is just the same as any CD player, provided a lossless
storage format such as FLAC is used.
A normal desktop PC is usually quite bulky, noisy and ugly, and it
needs other peripherals to work as well. Not a suitable source device
for a listening room, I'd say. However, there are mini PCs available
that have no moving parts at all. These are often intended as
control/monitoring devices for industrial applications, or thin
clients. Accordingly, CPU and memory specs are typically very low.
A while ago, I got to play with such a device, the Norhtec
MicroClient Jr.
It boots from a Compact Flash card and has a 200MHz SOC (system
on chip) CPU and 128MB RAM. That's all there is, and it's not
upgradeable. However, it has three USB ports and a LAN interface built
in. It can also be ordered with a built-in WLAN in addition. Power
supply is a small wall wart SMPS, as the box consumes only about 15W.
It also has an onboard audio chip, but it's not suitable for
high end audio.
I looked at various Linux mini distros to go with this. Some didn't
even boot, some were lacking features, finally I used Puppy Linux.
It is very easy to install on any media, and it runs on UnionFS - it
basically consists of two file systems, one read-only off the flash
disk, and a superimposed one in RAM. Changes to the filesystem are
stored in RAM while the system is up, and they are written back to the
flash disk when the system shuts down. For an appliance that normally
doesn't store any data on the local disk this is good, because it's
possible to just switch off the power without damaging anything. Nobody
wants to shut down a CD player before turning off, right?
Puppy Linux is by design a desktop system, however we don't need the
GUI for this application. It comes in handy while setting up the
system, though.
How It Works
If you are reading this article, most likely you already got your music
on your PC as MP3, Ogg or FLAC or similar. You play music
using your PC sound card or perhaps Yeo's USB-SPDIF converter with the
player program of your choice. What I'm suggesting here is almost the
same, except that the playback program resides on a mini PC, away from
your desktop, and it accesses your music files over your LAN through
shared folders on your PC. The user frontend of the playback program is
independent of either machines. The program listens for control
commands over the LAN, so you can control the playback from anywhere
you like.
You
don't have to use the Norhtec PC. Any other will do, provided it has at
least the same hardware specs. I like it because it doesn't make any
noise, looks nice and because it's really cheap. It's also quite heat
tolerant, and I have never seen it crashing.
The proposed system uses mpd
as playback software on the mini PC. So to say, it turns any PC into an audio playback
device with network remote control. It handles only audio files, not streams
like internet radio. Some of the frontends
that are available for mpd are web based, so if you run a web server
with PHP support on your desktop PC, you can use one of these and then
remote control mpd using any other PC in your LAN that has a web
browser - for example, your PDA with wireless support.
Preparing the System
Honestly, this is not for the impatient.
Many things can and will go wrong. With electronics, it means sparks,
smoke, loss of money. With computers and networks, it means
frustration, aggression, loss of time. But unlike a burnt circuit, you
can always reformat. And remember, it's DIY.
You need Yeo's USB-SPDIF converter, a CF card reader and a 1GB CF card.
Possibly 512MB are enough, too. Download the distro ISO file from their
download page and burn it on a CD. I used puppy-2.14-seamonkey-fulldrivers.iso.
Follow the instructions on their site on how to flash the system to
your CF card, there is a program in the distro that does just that.
Plug the CF card into your mini PC and boot. The initial setup is well
documented on the Puppy Linux web site, so I won't go into details
here. You should assign a fixed IP address, do not use DHCP. Once you
have configured everything to match your network environment, go on
reading.
The player software is mpd,
the Music Player Daemon. It is using several libraries: libidtag, libmad, libogg, libvorbis
and flac.
With such a low speed CPU and so little RAM, it's no fun compiling the
required libraries and programs by yourself. Therefore, I have put
together an archive with everything you need here
. Download this to your running Puppylinux, open a terminal window and
unpack the archive:
cd /
tar xvzf
/root/streaming_audio_puppylinux.tgz
Substitute your path to the archive, of course. Edit the file /etc/ld.so.conf
and make sure that the first line reads:
/usr/local/lib
Then run the command
ldconfig
You will need to edit /etc/rc.d/rc.local
and /etc/mpd.conf
to reflect your setup. In particular, you need to replace the name of
your desktop or server system where your music files are, in the
example it's YOURDESKTOP.
Your desktop or server should offer a public read-only share named music . It can
contain FLAC, MP3 or Ogg files and folders.
Edit the file /etc/profile
and comment out the line that reads
exec xwin
This will prevent the GUI from starting next time. If the GUI is
running while playing music, you will likely experience dropouts due to
CPU overload.
After this is all done, use the GUI to reboot the system. That way, all
your changes will be written to flash. Assuming you configured the LAN
properly and the USB-SPDIF converter is plugged in, it should mount the
music share, start mpd, and listen on the LAN for commands.
Operation
To play music, you need a front end program
that can talk to mpd. These typically run on your desktop PC or server,
not on the mini PC. In my case, I installed Apache and PHP on my
desktop PC and use phpMp2.
This means that you can access it through your LAN from any other PC in
your place using a web browser. I have a wireless LAN at home and a
WLAN capable PDA, so I can select songs from my library using my PDA in
the listening room, while the noisy desktop PC is running in my office
room.
It is important that your desktop PC/server is running before
you switch on the mini PC. Also, if you reboot the desktop PC while the
mini PC is up, you will need to reboot that one as well.
Optional Bluetooth
WLAN usage can drain a PDA battery quickly. If you have a Linux
supported USB Bluetooth dongle, you can use it to accept incoming PPP
connections from your PDA and route it to your LAN. Instructions on how
to make Bluetooth work on Puppylinux are here,
but it requires a lot of tinkering. You won't need to install the
mentioned kernel modules - they are already there. Note that in /etc/rc.d/rc.local
I already included the necessary commands commented out.
In addition, you will need to configure pppd with a login/password and
assign an IP address for the connecting client, but this is outside the
scope here.
You don't need Bluetooth support for controlling mpd, it's just a nice
addition if you happen to have a device that supports it. WLAN works
just fine and is faster, too.
diyparadise.com