Home networking is arriving slowly. This paper reports on a project to stream audio around the house using wireless networking. The audio stream is received by a loudspeaker running embedded Linux with a power amplifier
Two of my favourite pastimes are listening to music and cooking (with corresponding eating). These are not always compatable: like many people I have my hifi equipment in a room such as a loungeroom, well removed from the grease and heat of a kitchen. In my current flat the lounge and kitchen are separated by a long corridor, so that when I am working in the kitchen the sounds from the lounge are attenuated, to say the least.
A pair of speakers in the kitchen is the answer. One can buy "party speakers" which are hardened to withstand the outdoor environment, and so could probably cope with the kitchen environment. Most amplifiers have outputs for two or more speaker systems, so the simple solution is just to run an extra pair of speaker cables from one end of the house to the other. Cost: maybe ten dollars, depending on the quality of the cables.
In a previous house this is what I did, running the cables under the house. In my current flat there is no easy underfloor or intra-wall access, so the cables will have to run visibly. Untidy.
In addition, this relies on a device-centric view, based on the capabilities of the amplifier. The amplifier must have spare speaker outputs. If I change the amp, it has to support the same number of outputs. It is non-extensible, in that I can't just keep adding speakers to one room after another or placing speakers out in the garden to keep the gnomes happy.
My amplifier is also non-extensible in that it takes a small number of inputs: phono, cd, tape and tuner. I can plug the TV audio output into one of these, but that doesn't leave room for much else.
On the other hand, my PC is now a source of audio signals: with its soundcard I can use it to play CDs, and (if pressed) use the microphone input for karaoke while playing VCDs on the DVD player. More interestingly (and tunefully) it can be used to take streaming audio input from internet wireless stations, or to download and play MP3 files. With a range of bus types (SCSI, PCI, firewire, etc) it can support outputs and inputs to and from an increasing variety of devices and home appliances, with no limits to the number of connected devices.
There is a strong possibility that the centre of a home audio system will shift from the amplifier with a small number of inputs to the PC with a wider set of inputs. The PC with a soundcard can handle both input and output digital signals, store them and manipulate them in various ways.
The amplifier will not disappear, but may be split back into its roles of pre-amplifier and power-amplifier.
The pre-amplifier will be responsible for taking inputs from analogue sources such as phono, radio or microphone, applying the correct frequency response correction and outputting it in a form suitable for digitisation by a soundcard or other dsp. In time, the various sources will produce digital output directly, in the same way that the CD has largely taken over from the 12 inch disk. The pre-amplifier stage may eventually vanish from home audio systems, but currently it still plays a major role in producing a standard output signal from varying inputs.
The power amplifier will be needed to produce high-power signals to drive loudspeakers. Analogue amplifiers need to be fed with a suitable signal, such as that produced from a pre-amplifier (or soundcard) and analogue speakers need to be fed the output from analogue power amplifiers. These may give way to digital amplifiers driving digital loudspeakers eventually.
Once you separate the amplifier into pre-amp and power-amp and introduce a digital stage in between, then the computer becomes a natural intermediate stage. It can take analogue signals through the soundcard, and also take digital signals directly from digital devices and from the internet.
There are also other benefits: PCs can be scheduled to run programs
at arbitrary times. It is easy to set up an
to record an internet radio broadcast; much easier than
programming most VCRs for a future recording.
A computer can be used to accept and control audio input. Typically this is just used to send the audio back out through the soundcard to a set of PC speakers, which contain their own power amplifiers. Distributing audio in a home situation does not seem to have been addressed by vendors, although many of the ingredients are present in current systems
Once sound is digitised on the computer it can be sent on the network to other devices, and of course this is the basis of internet radio, IP telephones, streaming video, etc. In the home it is even easier to do this since the bandwidth of a home network (say on ethernet) is much higher than the internet. It is not even necessary to compress the sound: an audio CD delivers data at 1.35Mbps which can be sent on a 10Mbps ethernet without problems (four concurrent streams might cause problems, though).
Either wireless or wire connection can be used. IEEE 802.11b (WiFi) can broadcast at 11Mbps, about the same as 10Mbps ethernet and certainly enough for audio. Once received, the audio signal can be fed into another soundcard with output to a power amplifier and a pair of loudspeakers.
I have built a proof-of-concept wireless speaker that uses standard internet communication protocols, standard (free) software and standard hardware to receive an audio signal and play this out through a power amp built onto a loudspeaker.
The loudspeaker is built from low cost components:
An ordinary PC motherboard is fairly large (30.5cm by 21cm) since it needs room for memory, processor and several PCI and ISA slots. Smaller versions are available with fewer slots (Micro ATX form factor, 24.4cm by 22cm). A minimal motherboard for a speaker system could be quite small (for example, EMAC Inc sell an Embedded Linux Starter Kit with ethernet - but not wireless - on a 14cm by 10cm board). For now, I used a speaker large enough to fit the power amplifier inside, and with a back panel big enough to screw the motherboard, hard disk and power supply to it. The power supply for both the amplifier and PC is the original PC power supply which can deliver a 12 volt output for the car amplifier.
The PC is a 120Mhz Pentium with 32M RAM. This runs a 2.4 Linux kernel
(from Redhat 7.2). By building a fairly minimal custom installation
less than 400M of disk space was required. This included a full C
development environment, emacs and Perl (just in case). This could
be reduced drastically - some embedded Linux's require just 8M of ROM.
Because I use a hard disk and there is little possibility of soft shutdown
(no keyboard, no mouse) the
ext3 journalling file
system is used on the disk to avoid time wasting file system checks
For the proof of concept a simple TCP client/server pair of programs were
written in about a page each of C. The server runs on the speaker,
and a client on a sound source such as another Linux box will
connect to it and stream audio. Each of the client and server use
sox to control the sound cards, reading from and
writing to them. The Sun
au format was used since this
doesn't need header information including the length of the stream.
sox will support a number of other formats.
The sound drivers and network drivers (including the wireless driver)
were all standard drivers with a Linux system. The hardest part was
figuring out the keystrokes to run the BIOS
to tell the BIOS there was no floppy drive (for this old BIOS, it was
del key on the numeric keypad).
By use of open source software, the development time was about one hour to write the client and server. This can be used as the basis for other software versions, using e.g. multicast or various compression algorithms.
The project actually spanned several weeks: stripping down the old PC; trying to find motherboard mounting brackets and finally drilling them out of the old PC; trying to find a suitable pair of speakers, big enough to hold a motherboard and also with a detachable back panel; getting cheap wireless cards (the "computer swap meets" will sell old ethernet cards for $5, but none of the vendors are yet selling new wireless cards); finding Linux drivers for PCI wireless cards supporting Ad-Hoc mode (most are PCMCIA drivers for Managed mode); etc.
Shielding is an issue: the disk drive generates enough of a magnetic field when accessing the disk to produce crackling on the speaker. Even using the keyboard on a nearby computer produces "clicks" on the speaker.
The sound quality is okay for a novice ear (like mine). However, if the gain on the amplifier is turned up and the signal is turned down then a "fluttering" effect can be heard on the speaker. The cause of this was tracked down to interence between network cards and the sound card, similar to the interference effects noted above. Other possibilities that were investigated and ruled out included:
soxand send down a pipeline to a process writing to the network, and on the other end one process reads from the network and writes to a pipeline with
soxat the other end. On each end there is context switching between the processes involved in the pipeline.
soxwas modified to include network code to write to the network as a client or to act as a server reading audio from the network. This replaces pipeline I/O with direct network I/O and avoids the context switch.
The uncompressed data transfer rate for 44.1Mbps sampling is about 1.5Mbps, as expected (this is content data rate, not including TCP, IP and ethernet packet data). This is achieved comfortably using twisted pair between ordinary ethernet cards. However with wireless cards it is a different matter, and probably reflects the maturity of implementations of wireless drivers
linux-wlan-ng-0.1.13driver (the only one that currently supports the D-Link PCI card in Ad-Hoc mode) the streaming dies after a couple of packets
wvlan_csdriver in a laptop, a data transfer rate of only 400kbps can be achieved. Good enough to stream MPEG compressed data, but not good enough to stream uncompressed CD quality data - packets just get lost, and the sound is very fragmented
airodriver and the Toshiba card and
wvlan_csdriver in the laptop there is no problem, and CD data can be streamed at 1.5Mbps without loss
The proof of concept needs to be replaced by a better prototype. This will hopefully be performed in conjunction with a loudspeaker and/or amplifier manufacturer. There are issues both from the hifi viewpoint and the embedded systems viewpoint
There are various middleware initiatives such as HAVi and CEBus which provide a software model of home consumer electronics devices. These do not quite fit the network loudspeaker - neither have this concept, and neither middleware has addressed wireless networking. Integrating this into these middleware models could make the network speaker more useful. It could lead to software abstractions suitable for Jini or Web services.
The five or six speaker home theatre systems use a larger variety of control mechanisms than for simple stereo speakers:
The network speaker provides a cheap and useful device for experimenting with streaming technologies.