I’ve been a big fan of the Squeezebox system from long before Logitech purchased SlimDevices who originally made the device. I keep my music collection in FLAC format on my computer and can easily access it from my Squeezeboxes that play the music synchronised all over the house. As an added bonus, the Squeezebox also supports streaming a lot of different internet radio stations. What it doesn’t support, however, is playing arbitrary audio output from your computer. This might be handy if you’ve got access to a bunch of music through a Flash player and would like to make it available on your normal sound system.
Some plugins have been made to make SqueezeCenter, the management platform for the Squeezeboxes, support fetching audio from specific extra places, but the few that does that for Linux do not mesh very well with PulseAudio, the sound server that e.g. Ubuntu ships with by default. So rather than getting the music directly into SqueezeCenter, we can side-step the entire issue and just provide the audio output as an internet radio station that is only accessible from your local computer; this, the Squeezebox can quite easily play.
I have done this on Ubuntu 10.10, but any system using PulseAudio should be fairly analogous. You need a few prerequisites:
- icecast2: Ogg vorbis and MP3 streaming server.
- gstreamer0.10-pulseaudio: GStreamer plugin for PulseAudio.
- gstreamer0.10-plugins-base: The base set of GStreamer plugins.
- gstreamer0.10-plugins-good: A set of GStreamer plugins containing interface to icecast2.
- gstreamer0.10-plugins-ugly-multiverse: A set of GStreamer plugins containing MP3 encoder.
- gstreamer-tools: tools for use with GStreamer.
- pavucontrol: PulseAudio Volume Control
Any standard configuration of the icecast2 server will probably do, as long as you can receive music from it and send feeds to it using the configured password you should be good.
First we tell PulseAudio that we have a sink we’d like to register:
pactl load-module module-null-sink sink_name=squeezebox
Then we start playback with this easily understood and very apparent command line invocation:
gst-launch pulsesrc device=squeezebox.monitor ! audioconvert ! lamemp3enc target=1 bitrate=128 cbr=true ! shout2send ip=127.0.0.1 port=8000 password=PASSWORD mount=mystream.mp3
If you live in parts of the software patent encumbered world, you can probably make it work with Ogg Vorbis instead.
You can now point your Squeezebox at a stream at
http://127.0.0.1:8000/mystream.mp3, however, you still won’t have any sound! Why? I hear you pondering… Because above we simply said that we wanted the Squeezebox sink to be the null-sink, i.e. nothing goes on there apart from a timer keeping stuff in sync. In order to hear anything we’ll start up
pavucontrol, the PulseAudio Volume Control program and in the Recording tab, we ask it to show all streams and we should be able to see a stream called
gst-launch-0.10 and a button next to it that says ‘Monitor of null output’, click this button and select ‘Monitor of your sound card’ and presto, music should appear from your Squeezebox after it’s done buffering (provided, of course, that you are playing something on your computer at the moment).
Just be aware that this plays all audio output from your machine, but it isn’t terribly adequate for watching videos, etc. as there is a noticeable delay between what goes on in the video and when the music appears on the Squeezebox, but for streaming music, it’s perfect.