Streaming audio over the network in linux

I’ve been trying for a long time to find a simple (for me) way to get sound from my laptop to my TV. I’ve tried mpd, mediatomb, pulseaudio… basically everything short of spending actual money. Finally I found a low-overhead system that does what I need thanks to our friends ssh and alsa: Linux Network Sound on the Very Cheap. Thanks so much to Aristotle Pagaltzis for this recipe.

I’ll reproduce the instructions with my edits:

  1. On the source machine (my laptop in this case), load the loopback ALSA driver:

    modprobe snd-aloop index=1 pcm_substreams=1

    The driver provides a card with two sound devices, and when sound is output onto a stream on one device then the driver loops that back that as an input available on the same stream on the other device. You’ll need to pick an index that’s not already taken by a sound card on your machine or you’ll get an error.

  2. Add this to your ~/.asoundrc:

    pcm.loop {
      type plug
      slave.pcm "hw:Loopback,1,0"

    The original instructions also tell you to change your default soundcard to the loopback device. In this case I don’t want all my sound to go over the wire. Instead, use pulseaudio to select an application and have its sound sent to the loopback device. Yes, I know, pulseaudio. Actually it works pretty well these days! The loopback driver will then make that audio available on its other stream.

  3. On the machine with speakers you can then do this:

    ssh -C user@hostname sox -q -t alsa loop -t wav -b 16 -r 48k - | play -q -

    This command causes a simple dump to be made of the “loop” device on the source machine. That audio data is then piped into the “play” command which causes the sound to play on the machine connected to my TV. This also sets up ssh with compression which helps keep the bandwidth usage down (about 200K/s for me).

  4. All you need to do then is play something from the laptop, open the pulseaudio volume control, and tell the output to go to the loopback device. Very quickly the audio pops out the other side.

Obviously this is no solution for people wanting multiple client control, tablet support, playlists, or anything fancy like that. But as a way of just getting audio from point A to B, this is all I need.

Linux Tip: Stuttering Audio with Flash and Firefox

Problem: When playing back flash video in firefox on Ubuntu version 12.04, you may experience stuttering audio and dropped frames
Possible cause: pulseaudio may be configured for “simultaneous output”, which adds overhead that may be slowing down your system.

Solution (in my case): Click the volume icon, then click Audio Settings. Make sure the default output device is the correct sound card, not “Simultaneous output.” Also make sure the settings for the sound card are correct, including inputs and codecs. Don’t turn on anything you don’t need.

On The Boogiedownload — behind the scenes

A while back, Nick over at Beantown Boogietown asked me for a mix to post on his website, and recently I put something together that I thought was worthy of publication. Nick went all-out, doing a little mini-interview and giving the mix a very flattering review.

Check it out.

I do want to get one more thing on the record: although I didn’t have a preset tracklist, this isn’t a one-take mix. I did go back and rerecord a few of the transitions that drifted a little. If I was in the middle of a mix and things started trainwrecking a bit, I stopped everything, rewound the outgoing track to the breakdown, and redid the transition. I did that twice. And then when I listened to the recording I discovered nine or ten minutes of the recording was doubled up, making it unlistenable, so I had to go back and rerecord that section too.

I took these four or five pieces into Ardour and spliced them carefully together. I know, the magic is ruined, etc etc. Sorry. I was just really glad that the messed-up section wasn’t the whole last 40 minutes of the mix instead of just the two tracks.

Electric Chord


The electrical device in my building and the construction equipment across the street play what I think is a dead-on major chord. I think the truck outside is playing the first and fifth, with the boxy thing playing the third. Music majors please correct me if I’m wrong.

a train passes in the rain: medford.

The last time I used my neato binaural microphones was 2006, and that makes me feel guilty. Every so often I find them in a drawer and think, “I should really use these sometime.” During the last huge thunderstorm I tried to use them, but by the time I figured out how to record audio on linux (yeah, I know) the storm was basically over. Tonight it’s raining again and my recording system works. And since we live next to the train, I made sure to check the schedule first to make sure a train would pass while I was recording. Now you, too, can pretend you live in Medford next to the tracks.

This recording should be listened to with headphones. That way you’ll get the full 3D-sound effect.

(ps, I don’t know who makes this little audio playback applet, but it’s great. I stole it from another web page, but if anyone knows whose this is, let me know.)

A one-minute vacation

This is my own one-minute vacation, which is about the part of the vacation most people don’t focus on. I recorded this inside the gate at Las Vegas airport where you can hear not only the regular boring airline announcements, but also the soft, comforting plinking of slot machines.

Las Vegas airport.ogg

This is a binaural recording, and is best heard with headphones.