This is a rather crazy idea.
I am planing to set up a configuration that would send audio being played on my laptop to my home server via local network so that the sound is played on the server connected to a hi-fi with good speakers.
It’s supposed to serve the purpose of watching movies on the laptop with sound on the speakers without rearanging cables.
I suppose it can be done similarly to writing text to a file mounted via sftp, but with the /dev/audio or /dev/mixer
But I have no idea how to intercept the audio output.
Looking forward to tips from Pros 😉
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
What you’re looking for is a sound server. These programs send sound over the network. Choices include JACK, NAS, Pulseaudio and more.
Pulseaudio is the default audio system on Ubuntu and is widely available on Unix. JACK is widely available on desktop operating systems and prides itself on its low latency. I’d try these two first. See Jack vs Pulseaudio — how is it faster? for a short comparison.
To play music on a different computer, any of these programs would do as long as you manage to install the same program on both machines (they use incompatible protocols, though some have translation modules). But when playing movies, you may have trouble because forwarding sound over the network introduces perceptible latency. Some movie players allow you to fine-tune the alignment between audio and video, you may need to play with this setting.
Method 2
As Gilles said, you’re best of looking into updating your soundserver config.
You can use pulseaudio to listen to a TCP port.
Be sure to check padevchooser, which is a GUI frontend to update your config.
You can find a tutorial on the archlinux wiki.
Method 3
Your best bet is probably VLC/VLS, but expect some nasty problems with synchronization drift as it is hard to keep video playing here in lockstep with audio data playing there.
Method 4
MPD allow for streaming audio over http, just not setup by default. The limitation is that MPD streams from your MPD audio library, where as a sound server will allow you to stream any audio on the computer.
Method 5
Direct access to the loopback Alsa Buffer in the operating system would be the most efficiant and reduce redundant translation layers so the latency be reduced as well. The only drawbacks in any case, over the internet, you have ssh or vpn overhead latency.
This person is using a binary that works really well (trx), and the alsa-loop
http://www.pogo.org.uk/~mark/trx/streaming-desktop-audio.html
Method 6
After some fiddling with raspicast managed to send audio from an android client to a raspberry pi over ssh. The only dependency (for audio only) is omxplayer which can be installed with apt-get install omxplayer.
The android client is open-source and available on github. Looking at the code it appears that the android app wraps around dbus-send and omxplayer so I’d expect it should also be possible to stream from other OS’s than android, although it’s not very clear what specific commands need to be sent to dbus on the remote box. For a generic linux server the code would probably need to be modified to use something like mpv instead of omxplayer.
NOTE: The android app defaults to
HDMIoutput for the audio. If you are connecting your speakers through the audio jack then you’ll need to change it to ALSA (under Settings > Audio output or otherwise you won’t get any sound.
There are also a few tutorials like this one which go into more details on getting raspicast to also play videos and show photos.
Method 7
I myself used SoundWire (http://georgielabs.net) for this.
The client is only available for Android, but running it in a VM also works.
Method 8
Use MPD on your laptop to stream the music to your computer at home.
I suggest, however, that you run MPD on the computer at home, and just connect to MPD with your Client from your laptop (I suggest GMPC).
It is how I listen to music all the time, I have just one computer with music on it, and clients on my laptop and other computers.
MPD can stream the music through network, so you can feed that to a server or directly play it with mplayer.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0