PulseAudio is a great network audio server for Linux. It allows me to stream audio between machines. However, the biggest problem with PulseAudio is that it doesn’t have a descent client implementation for Windows. There are a couple known workarounds such as using WinESD, but they are all pretty experimental. Also, the Win32 binary build didn’t work for me, perhaps because it’s somewhat outdated and buggy.
My first try was to use LineInCode and Netcat for Windows on the client side and to use
module-simple-protocol-tcp on the server side. After adding
-L "module-simple-protocol-tcp port=4712 rate=44100 format=s16le channels=2" option to the PulseAudio startup option, I was able to stream audio from Windows to PulseAudio server using the following command:
linco.exe -B 16 -C 2 -R 44100 | nc.exe <host> 4712
However, PulseAudio dies whenever the connection is closed because of a known issue of
module-simple-protocol-tcp. I wrote some script that restarts PulseAudio whenever it dies, but I realized there’s a better solution – OpenSSH.
I have installed a Cygwin build of OpenSSH, and replaced Netcat with it:
linco.exe -B 16 -C 2 -R 44100 | ssh.exe <[email protected]> "cat - | pacat --playback"
This solution works without
module-simple-protocol-tcp, and therefore there’s no need to restart the PulseAudio server on disconnection. Better security is another bonus. Instead, it requires a running SSH server. If SSHD is not running in the PulseAudio server, you can give it a little twist:
linco.exe -B 16 -C 2 -R 44100 | ssh.exe <[email protected]> "cat - | pacat --server <host> --playback"
In case your Windows machine doesn’t have a sound card or it doesn’t allow you to capture the audio stream, you might want to use Virtual Audio Cable. It’s a commercial software, but it is worth a purchase.
You might also want to set up a passwordless login so you don’t have to enter the password every time you stream the audio.
thank you so much %)
@rstets: You’re welcome! 🙂
Hmmm, how did you manage to send anything but microphone to PulseAudio server from Windows? Linco transfer only Audio Input on my machine 🙁
@kotnik: Virtual Audio Cable just worked for me. Perhaps linco might have an option which allows you to choose a device? I’m not sure anyway because I didn’t try that way. I’d recommend Virtual Audio Cable to save your effort. It doesn’t cost that much. Or.. perhaps there might be some open source alternative somewhere. Please let me know if you found one. 🙂
I’ll try to find some solution that doesn’t involve proprietary software. If I stumble upon anything, I’ll let you know 😉
How did you reduce the latency in your setup? I’m using Plink instead of ssh.exe, but other than that, I have the same setup as you.
However, I’m getting latencies of at least 1.5 seconds, which seems a bit ridiculous. Did you do anything to reduce it?
@Walter: Actually, I just live with it. I think it’s fine unless you are playing video. I use it only for playing music.
Thanks for this post. I run Ubuntu 8.10 as my host operating system but do development work in Windows (C#) so I run VMware Workstation. Up until this point I was never able to get sound fully working inside a guest Windows operating system – I would always get obnoxious stuttering or the audio would speed-up/cut-out randomly. I’ve tried multiple sound cards and numerous settings tweaks to both PulseAudio & the individual virtual machines.
But now, with Virtual Audio Cable and your setup with LiveIncode & SSH, I’m able to route sound over to my host Ubuntu’s PulseAudio server and have it be pretty much flawless.
@Mulchman: Great to hear that my tip was helpful. 🙂
I’m trying to mimic your initial setup of having pulseaudio stream to netcat, but when I try to run mplayer or any other program on the server, it returns:
AO: [pulse] Failed to connect to server: Internal error
Could not open/initialize audio device -> no sound.
My server doesn’t have speakers or a sound card, so my default.pa config file is empty except for the module-simple-protocol-tcp module.
Do you have anything additional in your default.pa file beyond that module?
I solved this by changing the record source in the windows volume control (on XP) from Microphone to Stereo Mix. If you don’t have the stereo mix option, you might be able to add it in Options->Properties->Recording
Thanks for this brilliant guide! It helped me work around a broken headphone jack.
Pulseaudio does NOT exit if you start it with
This is no bug. Its a feature…
Thanks for excellent guide! All works!
But i have a one little problem – a latency in 0,5 second. Is there any way to reduce it?
AFAIK, no. The situation could get better if someone ports PulseAudio server to Windows.
LineInCode has an excessively large buffer for this job, and Windows likes to use big buffers for TCP. I had much better latency with sox —buffer=1024 and nc -u.
notes on windows network audio
I did what follows to “almost” remove latency:
Windows 7 machine – install virtual audio cable – install cygwin with soc, nc etc. – “sox —buffer=1024 -t waveaudio 0 -t raw -r 48k -e signed -b 16 -c 2 – | nc -u 10.0.10.10 4713”
On linux (receiver and using jackd): – setup jackd to real-time – “nc -n -k -l -u -vvv -p 4713 | aplay -r 48001 -f S16_LE —buffer-size=2048 -c 2”
The -k parameter “almost” work. You can restart the server while client still is running. Notice the -r 48001… This is still a experiment. I had trouble over time where the latency continuously build up if my server did a lack e.g. when going to screensaver. I expect this to be a aplay buffer building up and therefore I raised the rate.
Naaah. The -r 48001 was not an succes…
Thanks for your tutorial 🙂
I’m looking to use the same thing on Android. To stream sound from Android device to my sound system through this. Any idea ?
I have done streaming with only pulseaudio on both sides.
Windows pulseaudio was v1.1 from official site. But there are some problems.
1. On windows no one program can playback through PA, but you can set in windows volume settings (sndvol32) default recording source mixer and all output will go to pulseaudio input source.
2. PA dies after disconnection. It fixes with option –exit-idle-time=-1 (mentioned in other post)
3. Only one way to control PA in windows is to load module module-native-protocol-tcp : add load-module module-native-protocol-tcp auth-anonymous=1 auth-ip-acl=192.168.1.0/24 to file [pa_path]\etc\pulse\default.pa
4. Sometimes Win version try to connect to unix pipes. To prevent this add line use-pid-file = no to file [pa_path]\etc\pulse\daemon.conf
Procedure of streaming
on Linux PC
pactl load-module module-native-protocol-tcp auth-anonymous=1 auth-ip-acl=192.168.1.0/24
on windows PC:
add to default.pa, or set PULSE_SERVER=localhost && pactl.exe …
load-module module-tunnel-sink sink=alsa_output.pci-0000_00_1b.0.analog-stereo
load-module sink_name=my server=192.168.1.4 module-loopback source=input sink=my
I got almost seamless latency.
Pingback: How to send audio between two Linux computers using netcat » Ad Terras Per Aspera