?

Log in

LazyWeb: PulseAudio, Squeezebox, music distribution/sync ... - brad's life [entries|archive|friends|userinfo]
Brad Fitzpatrick

[ website | bradfitz.com ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

LazyWeb: PulseAudio, Squeezebox, music distribution/sync ... [Mar. 3rd, 2007|10:47 am]
Brad Fitzpatrick
[Tags|, ]

Dearest Lazyweb,

Long time no talk. How've you been? Good, good.

Question for you... kinda a repeat of one I've asked before...

I want to be able to play music from any computer in the house, and have it sent to four devices, in the house, all synced. The four major devices in the house are:

-- Squeezebox, downstairs: feeds 20-some channel amp for speakers in ceilings.
-- Squeezebox, upstairs: feeds receiver upstairs for good living room speakers
-- Mac, office: pretty good computer speakers (but Mac can run software slim player)
-- Linux box, garage, hooked up to garage speakers (also can run software slim player)

Now, the Squeezeboxes can all sync with each other, but I have to play music from the kinda ghetto web interface, and often I just downloaded something to my mac desktop or somebody brought over their iPod or something, and I can't get the audio into the server to get onto the 4 devices.

So I want, from any location, to inject sound into something that then streams/pushes it to all the Squeezeboxes.

Ideally, I want a place I can plug in an iPod (just the headphone jack) or play music from iTunes in my office, and have it go everywhere.

Bonus points if your solution involves somehow what I hear is the new sexiness, PulseAudio. (finally a soundserver done right? so I read/hear, but of course skeptical.)

For the injecting-from-Mac-desktop side, is there an output sound driver I can switch to on the Mac, that sends the audio data across the network to ... something?

Any solution that involves more computers instantly loses.

Only tangentially related, USB-IP is cool and something I've always wanted, but it was just removed from -mm because of conflicts and lack of maintainership? Sad.

Love always,
Brad

P.S. This LazyWeb question would be better if I knew what I wanted more.
LinkReply

Comments:
[User Picture]From: xotiffany
2007-03-03 08:04 pm (UTC)
come out this way if you want.
(Reply) (Thread)
[User Picture]From: jope
2007-03-03 09:46 pm (UTC)
Sonos? Not cheap. Runs Linux internally, IIRC. I learned about it from joelonsoftware's massive gushing over it, so you may already be aware of it.
(Reply) (Thread)
[User Picture]From: brad
2007-03-04 01:28 am (UTC)
No, hadn't seen that, thanks! Browsed around the site but it isn't apparent that the "plug in an headphone jack" usecase is fulfilled... do you know?
(Reply) (Parent) (Thread)
[User Picture]From: gleamicus
2007-03-04 03:12 am (UTC)
The sonos ZP80s (and the 100s?) have input jacks that handle all of it for you. Plug in your mp3 player, start it playing, and use the controller to stream it to all of the other zoneplayers.

The downside of the sonos system is that it only does what Sonos wants it to do. Also, I wasn't terribly impressed with the controller when I played with one.

I'm currently looking to build out a system like yours, or like the Sonos system. Something multizone that handles flac but is easy to use. Sonos is meets all of those, but is pretty expensive and kind of feature-limited.

Right now I'm thinking of going piece-by-piece and using a Nokia N800 and some Squeezebox3s, with the Nokia770 slimserver skin. Gets me the cool portable GUI controller and all of slimserver's plugins.

I'd love to hear what you eventually end up doing.
(Reply) (Parent) (Thread)
[User Picture]From: gleamicus
2007-03-03 10:22 pm (UTC)
How about capturing the audio from iTunes/whatnot and creating an mp3 stream, and then having the slimserver play the stream? MuSE can help with that: http://muse.dyne.org/

As for the sound driver you can use that sends the audio across the network, check out Soundflower: http://www.cycling74.com/products/soundflower

The only drawback to an mp3 stream is there'll be a delay of about 5 seconds every time you change tracks, etc.

(Reply) (Thread)
[User Picture]From: brad
2007-03-04 01:30 am (UTC)
Great links, all three, thanks!
(Reply) (Parent) (Thread)
[User Picture]From: gleamicus
2007-03-03 10:25 pm (UTC)
Oh, you can also use NiceCast instead of muse.

http://www.rogueamoeba.com/nicecast/
(Reply) (Thread)
[User Picture]From: edm
2007-03-04 08:28 am (UTC)

Streaming from line-in

As I re-read this post, it occured to me that all the solutions offered so far are much too high tech. What you want to do is take incoming analogue audio, turn it into "something digital", transport it across the network (to a bunch of places, as it happens), and then turn that "something digital" back into analogue audio. The Squeezebox will handle everything after turning it into "something digital" for you, providing you give it a format it understands.

One of the formats that the Squeezebox understands is a WAV file, which is basically a small header (with number of channels, sample rate, etc), and then raw A2D output. IIRC it's the only non-MP3 format that it'll play, at least in the older models. So what you want is a network service that (a) accepts connections, (b) picks data out of the A2D buffer on the sound interface, and (c) sends it out over the network as a WAV file (ie, initial header plus A2D data).

For the encoding part you could use something like arecord (alsa-utils) to encode the audio, eg "arecord -f cd -t wav" (default output location is standard out). Or sox, eg, "sox -r 41000 -w -c 2 -t alsa hw:0,0 -t wav -". (You might prefer "-f dat" -- 48000 rather 41000 samples per second -- especially if your input sound card prefers that; -r 48000 in sox will do the same.) For the "network part", this sounds like an ideal job for (x)inetd -- just run the relevant recording command when something connects, and it'll send the WAV header followed by A2D data until killed.

Then, in theory, you just point the controlling squeezebox software at the host with the (x)inetd setup and away you go. From memory it will receive one copy of the stream, then reflect it out to all the slaves, so that should work fine. If each slave is told to connect to the stream then you'll possibly run into problems with them being out of sync (and if you're not using alsa with a card supporting multiple connects, with some of them being locked out).

Sorry, no use of PulseAudio in sight.

Ewen

PS: 48000 samples per second, for 2 channels, in 16-bit, is 1536000 bps (1.5Mbps). Even over a wireless link or a 10Mbps Ethernet that shouldn't be too big a load. If you have 100Mbps or 1Gbps connections I doubt you'd notice the traffic. You may need a bit of buffering if you're using a lossy link, as the audio is being "streamed" in a TCP connection, and hence you'll get retries.

PPS: Another cute hack: use the printer spooler to queue audio (it was first done by the OpenBSD folks at a hackathon IIRC, but I can't find the original link quickly). It doesn't look especially difficult to repurpose it to submit into the SqueezeBox software playback queue. But of course it doesn't give you "plug iPod headphones into line-in and music appears".

PPS: The headphone jack on the iPod (and all other devices) and the line in on audio interfaces have different impedences, and IIRC voltage ranges too. So some experimentation will probably be required to get a tolerable output, probably involving not making the output from the iPod too loud (so it doesn't clip), but then amplifying it somewhat at the encoding stage (see, eg, sox man page). If the iPod has a line-out, that would match the sound interfaces line-in much better (no idea if the iPod does though; I don't have one). Beware also of earth loops, and all the other fun of using unbalanced analogue audio connections; providing the iPod is running on battery power -- or the same power source as the input sound interface -- you'll probably avoid most of those problems.
(Reply) (Thread)
[User Picture]From: brad
2007-03-04 06:16 pm (UTC)

Re: Streaming from line-in

Whoa, thanks! Lot of good info in here. Good call on .wav.

The Squeezeboxes are all on 100 Mbps or 1 Gbps anyway, so shouldn't be a problem.

I'll let you know how it goes.
(Reply) (Parent) (Thread)
[User Picture]From: giantlaser
2007-03-04 09:19 am (UTC)
Check out Firefly Media Server / mt-daap. It may not synchronise, but since it can serve internet radio streams (effectively proxying to save the bandwidth from having multiple streams), presumably it can make streams in the first place.
(Reply) (Thread)
[User Picture]From: dakus
2007-03-05 01:13 am (UTC)
(Reply) (Thread)