calling all nerds: tell me why this won't work

posted by tom / May 07, 2006 /

New project time. The SMS dealy should be released imminently — I just need to write the help system (and, uh, ignore a persistent bug and elusive bug). I should be able to wrap that up this afternoon.

I've got a new project in mind, though. For a while I've wanted to be able to pipe sound around the computers in the apartment more easily. The Linux server is connected to a pretty nice stereo system, but it's a headless unit. We tried using SliMP3 as a webserver-based MP3 jukebox for a while, but the latency was pretty irritating. And besides, I want to be able to pipe other kinds of audio around — streaming internet radio, youtube soundtracks, even mail notification beeps. And I'd like for the various computers in the house to be able to use it (not simultaneously, though).

There are various solutions to the problem of playing MP3s over a network, but I want something a little more universal and cheap. Ideally, it'd be an icon that sits in the system tray. Click on it and it turns green (or something) and all your sound starts magically coming out of a server connected to a set of nice, big speakers.

This page shows the outlines of a solution. It involves piping raw audio samples across a network to something that catches them and shoves them at the soundcard. There's no buffering, but that should be okay — I want realtime audio, so that everything stays as closely sync'ed as possible. If the wifi gets spotty and some samples get dropped from time to time, that's fine. I've managed to get a proof of concept variation on the article working:

On the server:
listen for incoming data on port 1234 and pipe it to the rawplay application
nc -l 1234 | rawplay

On the client:
convert an mp3 into raw audio samples
mpg123 -s somemp3.mp3 > somemp3.raw
print the raw data across the network to the rawplay instance on the server
cat somemp3.raw | nc <server's ip> 1234

This setup works decently — it sounds slightly weird, like the sampling rate is a tiny bit off and as if it has a weirdly flat frequency response. But I'm going to blame that on mpg123 for now. Unfortunately, this trick doesn't account for grabbing live audio off of your system — that's the hard part. But I think this example code, combined with SoundFlower and some OS X Sockets 101 (yet to be learned), should take care of that.

Justin gave a demo of OS X software development on Thursday that made everything look encouragingly awesome and easy. Ideally I'll be able to wrap everything up in a slick GUI package, then resurrect my .NET skills and build a Windows version. Construct a proper server (a few dozen lines of Python should do), throw in FLAC support to avoid wasting bandwidth, and I'd have a pretty neat app.

That's the plan, anyway. I'm sort of hoping someone will pipe up in comments and say "that's already been done, you can download it here".

Comments

I've developed a web-based app for my music catalog that uses Windows Media Services, running on a Windows Server 2003 box. The ASP pages (not yet in ASP.NET) contain an embedded Windows Media Player that streams from the server.

The nicest things about this app:
- I can listen to my music from wherever I am.
- I can search the entire collection easily, create custom playlists, manage favorites, or just play random.

I've set up the site so it's membership-based, and my friends can log in and listen to my music as well. Questionable interpretation of "fair use"? Absolutely.

Buffering/latency is not a problem, unless something else (FTP etc) is really chewing up bandwith. I listen wirelessly in the backyard with no problems.

I've considered getting the scripts to a point where anyone could install them on their server, set up the database, and point to their MP3's. This of course, is easier said than done. The database is in SQL Server, and my MP3 directory structure is tied to the primary key from the database.

We just bought a new house, and I'm planning on wiring indoor/outdoor speakers. A PC with a good soundcard and a nice receiver component are all that's required on the "client" side. I've considered getting a small PocketPC device that could be used to Terminal into the PC and act as a remote from the patio, etc.

The biggest downside to this solution is that Windows Media Player does not work in Safari on a Mac, and works with limited functionality in Firefox, provided you spend 6 hours installing the add-in and endless troubleshooting.

I started work on a VB.NET version of this, but haven't had time to get very far.

Posted by: Tom Oakes on May 7, 2006 11:18 PM

There are plenty of free things to do the above, just for music (I even used to know of one interesting possibly cross-platform but definitely linux-compatible one, but I can't remember what it is), but if I understand correctly tom wants *all* audio to go to the server, not just audio from a specific, music-playing application.

Posted by: ben wolfson on May 7, 2006 11:35 PM

MPD/Ampache, eg. (Found here.)

Posted by: ben wolfson on May 7, 2006 11:40 PM

Yeah... I used to use SliMP3, which does basically the same thing and is OSS. But I want to be able to push everything over to an audio server, not just music.

Posted by: tom on May 7, 2006 11:58 PM

Post A Comment

Name


Email Address


URL


Comments


Remember info?



Google Analytics