Whole House Audio with MPC and PulseAudio RTP multicast

Setting up whole house and synchronized audio with pulseaudio was both simpler and more complicated than I anticipated.

If you decide to take on this task, let me save you some googling and give you a couple of relevant links, including a script that I created in order to turn things on and off again.

I started with this post about using MPD and whole-house audio. I already used MPD (and am very glad for it), so the problematic parts almost entirely involved Pulseaudio RTP multicast and firewalls. I also referred to this post from danplanet and this post from fruit.je.  Here’s the important bits:

In ~/.config/pulse/default.pa, make the following changes in the server:

.include /etc/pulse/default.pa
### Load the RTP receiver module (also configured via paprefs, see above)
load-module module-rtp-recv

### Load the RTP sender module (also configured via paprefs, see above)
load-module module-null-sink sink_name=rtp format=s16le channels=1 rate=44100 sink_properties=”device.description=’RTP default'”

### Need to specify port and add loop=1 to broadcast locally as well.
load-module module-rtp-send source=rtp.monitor port=5004 loop=1

### If you’re not playing through local speakers as well, use this instead.
#load-module module-rtp-send source=rtp.monitor port=5004

and in ~/.mpd/mpd.conf make the following addition:

audio_output {
type “pulse”
name “MPD RTP”
sink “rtp”
mixer_type “software”
}

In your receiving PC(s), make sure that you allow PulseAudio to take in multicast by editing ~/.config/pulse/default.pa to include:


### Load the RTP receiver module (also configured via paprefs, see above)
load-module module-rtp-recv

Then the only problem is ensuring that your firewall will allow multicast, which you can do with my UFW script or by following the directions in my RTP switcher script.

If you’re considering this, you really ought to look at the switcher script, as PulseAudio multicast currently clobbers the crap out of anything connected to the network via WiFi, and there’s a fix in there for it.

Also, multicast means that your network has 100-200K constantly being used, even if nothing’s playing. That’s why the RTP switcher script exists at all. It’s there to allow you to be able to turn RTP multicast on and off again with minimal fuss.  (Do RTFM, though.))

Being able to play music from one source and have it be in sync throughout my home LAN is pretty freaking awesome. If you’re using PulseAudio and MPD, you could be doing it too!