View my LinkedIn profile Find:
HOME BLOG CONTACT PROJECTS PUBLICATIONS LINKS

[Linux]Received 02/19/2008 13:21

Airtunes+Ruby+RAOP+Pulse+MPD = Massive Win

Have a couple of Airport Express units lying around ? Sick of having to use iTunes to manage your library of MP3's just because it's the only thing that can stream to your Airport's ? Well, let me tell you a little story.

I like MPD [1] and think it's a pretty hard act to beat, especially when combined with Theremin [2]. Unfortunately MPD is really built assuming that the "server" which hosts your music also hosts your sound card. Getting MPD plugged into your Airport Express units requires a couple of hops.

Firstly, you need to install Pulse Audio [3] - the "next gen" audio server for Linux. Then, you can configure MPD to output it's audio to the Pulse Server using the following config block in mpd.conf

audio_output {
type "pulse"
server "localhost"
name "My Pulse"
}

Then, startup the Pulse Server and install the module-pipe-sink module. This module takes any audio that enters Pulse and outputs it to a FIFO - /tmp/music.output. Make Pulse listen on the local network to incoming sound.

root@merlot:~# pulseaudio -nC
Welcome to PulseAudio! Use "help" for usage information.
>>> load-module module-pipe-sink
>>> load-module module-native-protocol-tcp listen=0.0.0.0

Then, take the Ruby:RAOP package [4] and run the following Ruby script.

#!/usr/bin/ruby

require 'raop'
raop = Net::RAOP::Client.new("192.168.1.183")
raop.connect
raop.volume = 5

while (1)
raop.play $stdin
end

FINALLY, start up your MPD daemon. If you get security errors in Pulse, make sure MPD is running as a user that has access rights to the pulse server (i.e. be naughty, just use root and don't tell anyone)

What all this get you ? MPD outputting audio to pulse, which gets sent through a FIFO into Net::RAOP::Client which then streams the audio to 192.168.1.183 .... or whatever the IP of your Airport Express unit is.

Easy, right ?


[1] - http://www.musicpd.org/
[2] - https://theremin.sigterm.eu/
[3] - http://www.pulseaudio.org/
[4] - https://rubyforge.org/projects/raop/