The better solution seemed like a simple enough idea - build a linux based PC to sit in the bottom of my home hifi cabinet and load it up with all the tracks off our audio CD's. Stick a wireless network card in the back and let it join my existing home wireless network, with a "jukebox" network service to allow other client PC's to connect and ask for tracks to be played.
Leisa thought this was a great idea - she would be able to command the Jukebox to play music from her notebook computer (a sony Vaio) without leaving her chair. Soon after suggesting this, I was presented with a list of required features - the system must support user-defined playlists, a command history (a-la GNU readline), a locate command for searching for particular tracks and so on...
Well, I got there in the end. It has taken about a month from start to finish, and I have found a few surprises along the way. I thought it was interesting enough to write this summary page for anyone else who wants to try doing this.
In the end I decided to store the data as WAV files, so that I had more options for playback. I experimented briefly with using gzip to compress the files, but decided against it because it made seeking around on the input files a bit trickier (and I am conscious of the amount of CPU time needed by the player. Too much wasted CPU cycles and the audio will skip.)
There are a few lossless audio compressors around (e.g. FLAC) which can reduce the size of the audio data by around 50 percent or so - I might try one of them in the future, but I have enough space to do without and I am still wary of CPU usage.
My home hifi unit can take a digital S/PDIF audio input, so I planned to feed the digitally sampled audio tracks out to the hifi unit (a Yamaha RX-V2095) via a sound card with S/PDIF ouptut. This turned out to be a surprisingly difficult goal to achieve without losing sound quality - my opinion of various sound card manufacturers has dropped quite a bit as a result of this experience.
As a complete neophyte to digital audio, I had assumed that the "digital" connectors on soundcards were able to output the raw PCM audio in my sound files without any processing, giving my Jukebox the same sound quality as I get when playing audio discs through my DVD player (44.1kHz PCM sounds clearly better than the audio coming out the analogue RCA connectors on my existing CD player). My first attempt at a proof-of-concept used my existing Soundblaster Live! card. The S/PDIF digital output was at 48kHz, and sounded awful. It turns out that the SBLive! always resamples its input signal up to 48kHz, and the algorithm that it uses for this is not very good. Maybe it's ok for small computer speakers or something, but it's a complete waste of time for home hifi use.
This, as I then discovered, is part of the "AC97 sound specifiction". The S/PDIF output will always be at 48kHz regardless of the input on cards which are "AC97 compliant". This means that audio CD samples at 44.1kHz will always be resampled up to 48kHz, probably with audible loss of quality.
AC97 is very popular among the manufacturers of soundcards and motherboards. It is also hopeless for use in this kind of hifi jukebox.
I have found only one sound chip which is able to pass through audio samples at 44.1kHz unchanged via S/PDIF - the C-Media CM8738-MX. There may be others, but after a couple of days of R&D this was the only candidate that I could find. Various motherboards by ASUS use this as their onboard sound, and it is also used as the basis for a number of soundcards. It is perfect for use in the jukebox, and comes with good Linux support.
There are many nice things to like about this chip - for example the S/PDIF output is disabled when it is not in use (unlike many other chips, where the 48kHz carrier is permanently on), so it integrates nicely into my hifi system. My amplifier can auto-sense whether the "CD" audio is coming from the analogue or S/PDIF input, so it is important that the jukebox shut up when it's not in use.
In the end I found a sound card with this chip (Leadtek WinFast 6X Sound). They are cheap - this cost me $60 Australian (about US$30 or so). I think this series is actually discontinued, so you might have trouble finding one of these. I bought a spare just in case :-)
This card is also nice enough to provide the optical and coaxial S/PDIF connectors, saving me the trouble of building an adaptor.
Note: DO NOT try using the low-end versions of this chip (the 8738-LX and 8738-SX) as they do not provide S/PDIF output. These low-end versions of the cmedia chip are _very_ common on really really cheap soundcards.
The Harddisk is a Samsung SV1204H. This seemed to be to be clearly the best choice. Check out reviews in various places (Toms Hardware for example).
The CDROM drive is a RICOH MP7320A CDROM / CDR / CDRW drive. This drive is almost silent and makes a nice counterpart to the Hard Disk. Has anyone else noticed that CDRW drives are now ridiculously cheap and fast?
It is important to turn on DMA for the Hard disk. This just required editing /etc/sysconfig/harddisks. I also set the readahead to 128 sectors. What the heck - it can't hurt :-)
My motherboard is old, so it only supports up to UDMA2. A newer motherboard will get you better performance (or, more importantly, lower CPU usage). Anyway, the current system sits almost totally idle, even when playing multiple audio streams (locally + across the wireless link) and simultaneously ripping tracks from an audio disc.
The Power Supply was an A-Open "Noise Killer" which runs almost totally silent.
The end result is a system which is very quiet. If I dropped in a VIA C3 CPU with passive cooling then it should be completely silent - all I can hear now is the CPU fan.
I am using Samba to make all these tracks visible across the network as a WinDoze mapped drive so that I can also play them on other machines. Now I can access all my stored music even if I am downstairs in my office.
Almost all of the playback and user-interface software is written in Perl (my favourite language). For a while I was using SoX to drive the sound device (/dev/dsp) but in the last couple of days I have figured out how to do that from Perl as well, meaning that my "playback" service is now a single perlscript.There are two programs that make up the jukebox playback service - one program (playtrack) which is permanently running in memory, and another program (mediaserver) which provides the user interface. These two communicate via shared memory, so there can be many mediaserver clients all talking to the one central "playtrack" server.
In practise this means that I can connect into the jukebox from anywhere in the house and see what it is currently playing, and upload or alter the list of tracks.
There is currently very rough docs, and copies of the source and binaries here.
So there you go - large/cheap harddisks and wireless networking now make buiding a Jukebox system relatively easy. The only trick (if you are interested in "perfect" sound quality) is finding the right sound chip.