-   Slackware (
-   -   send audio over network (

ta0kira 06-24-2011 01:33 PM

send audio over network
I had this post entirely written, but I decided to reframe the question in terms of the solution I'm going to try vs. what else I could be doing. This solution will be replaceable without consequence, or I can extend it to the rest of my network.

I have a laptop that I want to connect to my stereo via USB, and I want the other computers on my network to be able to send sound to it somewhat transparently. By "transparently" I mean that I want to be able to send literally any audio that would go through my local speakers to the stereo via the network. As far as I know, PulseAudio can do this without rebuilding any multimedia packages. No one really has anything good to say about PulseAudio, though.

As of now I'm ready to wipe the laptop (Pentium 4) and put pretty much anything (*nix) on it. I know PulseAudio is pretty easy to get running on *buntu, so I might end up doing that. I just want to be able to turn on the laptop and connect the stereo (in any order) and without doing anything else, have it ready to go on the network. Of course, I'm willing to put in some work to get it running. I prefer Slackware and FreeBSD, but the machine will literally just be there to send sound to the stereo.

Someone on suggested NAS as a solution to a similar problem; however, I can't find anything useful regarding how to configure it, troubleshoot it, etc. I've only found random threads on the web by people who know how to use it or by people who can't find any resources for it.

Anyway, I'll be busy setting up PulseAudio to see how that works out. I can always wipe the laptop later, and I have a Kubuntu boot on my main laptop that I don't really care about.


Kevin Barry

dugan 06-24-2011 01:36 PM


Also, based on the way you describe your setup, I think it would make more sense to put MPD and the music library on the laptop, and set the laptop up with a web-based MPD frontend. Then the other computers will be able to use their web browsers to remotely control which songs the laptop plays over the stereo.

ta0kira 06-24-2011 06:18 PM


Originally Posted by dugan (Post 4394780)

Also, based on the way you describe your setup, I think it would make more sense to put MPD and the music library on the laptop, and set the laptop up with a web-based MPD frontend. Then the other computers will be able to use their web browsers to remotely control which songs the laptop plays over the stereo.

Thanks for the suggestions. I'm not setting up a media server, however. Just a sound server. For example, with my solution above (implemented since that post)
I'm able to send my npviewer.bin and DVD sound output to the stereo via wifi. The point being that I'll be able to stream sound to the server.

I set up Xubuntu and PulseAudio on the laptop and the setup works semi-good connecting from my Kubuntu boot, but I'm hoping to not have to set up PulseAudio on my Slackware and FreeBSD machines.

So far I have only a slight lag in sound and it's choppy here and there, but I don't know if that's a WAN problem or the setup I have going.
Kevin Barry

update: It turns out the screensaver, xfce-mixer, and/or xfce-volumed completely bogged down the old laptop (some combination of each at different times.) Fixing those and increasing the priority of both machines with the router got rid of the choppiness in web streaming but not Kaffeine. Dragon Player doesn't have choppy sound and the sync with video is fine. The only problem I have now is snd_usb_audio crashes when I do relatively minor things like click the XFCE menu or open pavucontrol.

peter2012 12-27-2012 10:42 AM

vlc, ffmpeg, netcat
Sorry, I know this post is oooooold, but for the benefit of others.

For streaming media content over a LAN I found there are several possible avenues. I haven't tried all of them, so you may want to do a bit of experimentation:

VLC player. Vlc player provides streaming out of the box. I did a little experiment and was able to successfully play an audio file on my laptop which I streamed from my desktop machine - I used VLC player on both machines. See

ffmpeg. I haven't tried it myself, but ffmpeg seems to support streaming. See

netcat. Netcat is the "swiss army knife" of networking. You can use netcat to stream audio. Excerpt from


Did you know you could stream audio or video on linux without any configuration? Note that this is a push model. So we have to start the streaming client first. This is what you have to do. On the streaming client, setup the listener.

$ nc -l -p 1234 | mplayer -cache 8192 -

This will wait for media from the network to play.
On the streaming server, push the media data (any mplayer playable file) thusly.

$ cat video.mpg | nc <ip/dns of streaming client> 1234
I just did a successfull netcat trial using netcat and sox:

On the receiving machine, I used an infinite loop:

$ while true; do nc -l 1234 | sox -t mp3 - -t ossdsp /dev/dsp; sleep 1; done

On the sending machine I sent an mp3 file:

$ cat ./00.mp3 | nc 1234

Bingo! Got the sound to play!

Adjusted from

which, sadly, is accessible only from the wayback machine

Relevant section:

Piping Audio Around the House

Playing audio over a pair of dinky little speakers is not all that satisfying. So how can you get it playing over a proper sound system? The kind that can rattle the walls and break crystal glasses?

Say, all your music resides on a large disk drive on a noisy server machine in the basement, while another silent PC is relatively close to your HiFi system, then you can run a cable from the sound adaptor line out to the auxiliary input of the amplifier, but you then still need a convenient way to send audio from the server over a LAN. This can be done using a combination of Sound Exchange (sox) and Netcat (nc).

On the HiFi connected PC, sox can play a file like this:

sox file.mp3 -t ossdsp /dev/dsp

However, you want sox to play music coming from the LAN, so it needs to be hooked to a server, that will listen for incoming data. Netcat can do that very conveniently.

To make sox and netcat work together, you need to tell sox the incoming file type (-t mp3, or -t vorbis) and you need to tell sox to grab the data from standard input (the empty '-'):

| sox -t mp3 - -t ossdsp /dev/dsp

Then you need to add a netcat listener before the pipe, to listen on a specific IP address and port:

nc -l -w 10 -p 12345

To be really good, you need to put an infinite loop around it, so that if netcat or sox exits, that they will start again:

while [ 1 ]
nc -l -w 10 -p 12345 | sox -t mp3 - -t ossdsp /dev/dsp

Put the above at the end of file /etc/rc.d/rc.local and it will always run when the PC is restarted and the PC will play whatever comes over the LAN - so make sure the volume is turned down a bit...

Now, on the server with the music repository, you can use netcat to send the music to the HiFi like this:

cat *.mp3 | nc 12345

That will cause netcat to pipe the music from the basement to the HiFi. Some more scripting can make the system run a playlist, or simply play everything at random.
As a neat trick, you can also show the actual data on the console whilst it's streaming to the receiver. tee to the rescue:

TTY=`tty`; while true; do cat ./00.mp3 | tee >(xxd > $TTY) | nc 1234; sleep 1; done

this sends the mp3 stream to netcat as well as to xxd, which then (in turn) sends the output to the console used. This shows a live hexdump of the data being sent to the playout machine.



schneidz 12-27-2012 11:25 AM

ive used this on occasion:

[schneidz@hyper ~]$ cat stuff/netcat.ksh
PL=$(find /root/user/music -name "*.mp3")
NUM=$(echo $PL |wc -w)
while true; do
s=$(echo $PL |cut -d ' ' -f$r)
echo "HTTP/1.0 200 OK\nContent-Type: audio/x-mp3stream\n\n"
dd if=$s bs=1024
} | nc -l -s address -p 8020

else, maybe something like sshfs on the laptop will work so you can play the file as if it is locally stored on the laptop ?

peter2012 12-27-2012 11:34 AM

Thank you so much!

All times are GMT -5. The time now is 12:37 AM.