Remote sound playback through a Nokia 770

For a while now, I’ve been using various hacks to play music from my Linux laptop, holding my main music collection, to client systems which drive the speakers.

Previously, I used this setup to play via my MythTV box. Nowadays, however, my TV isn’t in the room where I want to listen to music. Instead, I have my Nokia 770 hooked up to the speakers; this plays the BBC Radio 4 RealAudio streams nicely, and also the laptop’s MP3 collection using a uPnP AV MediaServer.

I specifically use TwonkyMedia right now, playing back via the N770’s Media Streamer app. (That works pretty well — uPnP AV is one of those standards plagued with incompatibilities, but TwonkyMedia and Media Streamer seem to be a reliable combination.)

However, TwonkyMedia sometimes fails to notice updates of the library, and nothing has quite as good a music-player user interface as JuK, the KDE music player and organiser app, so a way to play directly from the laptop instead of via uPnP would be nice…

A weekend’s hacking reveals that this is pretty easily done nowadays, thanks to some cool features in pulseaudio, the current standard sound server on Ubuntu gutsy, and the Esound server running on the N770.

Unfortunately, the N770 doesn’t (yet) support pulseaudio directly, otherwise we could use its seriously cool support for RTP multicast streams. Still, we can hack something up using the venerable “esd” protocol (again!) Here’s how to set it up…

On the N770:

You need to fix the N770’s “esd” sound server to allow public connections. Set up your wifi network’s DHCP server to give the N770 a static IP address. Log in over SSH, or fire up an xterm. Run the following:

mv /usr/bin/esd /usr/bin/esd.real

cat > /usr/bin/esd <<EOM
#!/bin/sh
exec /usr/bin/esd.real -tcp -public -promiscuous -port 5678 $*
EOM

chmod 755 /usr/bin/esd
/etc/init.d/esd restart

On the server:

Download this file, and save it as n770.pa. Edit it, and change server=n770:5678 on the fourth line to use the IP address or hostname of your Nokia 770 instead of n770. Then run:

cp n770.pa ~/.n770.pa

cat > ~/bin/sound_n770 <<EOM
#!/bin/sh
pulseaudio -k; pulseaudio -nF $HOME/.n770.pa &
EOM

cat > ~/bin/sound_here <<EOM
#!/bin/sh
pulseaudio -k; pulseaudio &
EOM

chmod 755 ~/bin/sound_here ~/bin/sound_n770

Now you just need to run ‘~/bin/sound_n770’ to redirect sound playback to the N770, and ‘~/bin/sound_here’ to reset back to laptop speaker output, for the entire desktop environment. Nifty!

Update: it appears that things may work more reliably if you add “rate=22050” at the end of the “load-module module-esound-sink” line — this halves the bitrate of the network stream, which copes better with harsh wifi network conditions. The n770.pa file above now includes this.

This entry was posted in Uncategorized and tagged , , , , , , . Bookmark the permalink. Both comments and trackbacks are currently closed.

5 Comments

  1. Zooch
    Posted December 11, 2008 at 20:48 | Permalink

    Great work. I’ve wondered about something like this for a while. Looking forward to trying it out.

  2. Bigdawgte
    Posted September 5, 2010 at 17:08 | Permalink

    Would this work on an n810? I am pretty sure it is running esd as well. What changes would have to be made? Thanks.

  3. Posted September 12, 2010 at 22:28 | Permalink

    yep, I think it’d work, most likely — unfortunately I have no idea what changes would be necessary, as I’ve never even seen an 810 :(

    It might be best seeing if there’s a port of pulseaudio for the 810, first, as that’s the more “modern”/well-supported route for networked Linux audio these days.

  4. Jochen
    Posted September 22, 2010 at 10:51 | Permalink

    Excellent – I was just pointed here because I wanted to do almost exactly that which you describe. My home music system is a WGT634U running OpenWRT with large HD and running mpd and esd and having good speakers attached via USB soundcard.

    A working pulseaudio implementation for this does not exist, so I need to use esd.

    And here you documented the complete solution for me. Now I can watch videos on my notebook and have nice sound through the good speakers…

    Thank you!

  5. GH
    Posted March 13, 2011 at 03:22 | Permalink

    Great!

    Just enabled sound on an Epatec hardware thin client from remote XRDP / XDMCP sessions using your pulse audio conf. Well done.