LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-24-2011, 01:33 PM   #1
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
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 forums.freebsd.org 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.

Thanks!

Kevin Barry
 
Old 06-24-2011, 01:36 PM   #2
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,225

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Icecast?

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.

Last edited by dugan; 06-24-2011 at 01:52 PM.
 
Old 06-24-2011, 06:18 PM   #3
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by dugan View Post
Icecast?

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.

Last edited by ta0kira; 06-24-2011 at 08:16 PM.
 
Old 12-27-2012, 10:42 AM   #4
peter2012
LQ Newbie
 
Registered: Dec 2012
Distribution: Kubuntu, LUbuntu, Mint, Debian
Posts: 16

Rep: Reputation: Disabled
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 http://wiki.videolan.org/Documentati...ming_HowTo_New

ffmpeg. I haven't tried it myself, but ffmpeg seems to support streaming. See http://ffmpeg.org/trac/ffmpeg/wiki/StreamingGuide

netcat. Netcat is the "swiss army knife" of networking. You can use netcat to stream audio. Excerpt from http://aplawrence.com/Girish/nc.html:

Quote:
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 10.18.22.250 1234


Bingo! Got the sound to play!


Adjusted from http://aeronetworks.ca/ogg2mp3-howto.html

which, sadly, is accessible only from the wayback machine http://web.archive.org/web/200902110...mp3-howto.html

Relevant section:
Quote:
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 192.168.1.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 ]
do
nc -l -w 10 192.168.1.10 -p 12345 | sox -t mp3 - -t ossdsp /dev/dsp
done


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 192.168.1.10 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 10.18.22.250 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.

HTH

P

Last edited by peter2012; 12-27-2012 at 01:07 PM.
 
1 members found this post helpful.
Old 12-27-2012, 11:25 AM   #5
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
ive used this on occasion:
Code:
[schneidz@hyper ~]$ cat stuff/netcat.ksh
#!/bin/bash
PL=$(find /root/user/music -name "*.mp3")
NUM=$(echo $PL |wc -w)
{
while true; do
r=$(($RANDOM%$NUM))
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
done
} | 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 ?

Last edited by schneidz; 12-27-2012 at 11:29 AM.
 
1 members found this post helpful.
Old 12-27-2012, 11:34 AM   #6
peter2012
LQ Newbie
 
Registered: Dec 2012
Distribution: Kubuntu, LUbuntu, Mint, Debian
Posts: 16

Rep: Reputation: Disabled
Thank you so much!
 
Old 10-18-2017, 12:54 AM   #7
yuris
LQ Newbie
 
Registered: Feb 2016
Posts: 1

Rep: Reputation: Disabled
To play webm format, use command below

server command:
cat song.webm | nc 127.0.0.1 1234

client required "mpv" player
can be installed by running: sudo apt-get install mpv

client command:
while true; do nc -l 1234 | mpv -; sleep 1; done
 
Old 10-18-2017, 03:26 AM   #8
peter2012
LQ Newbie
 
Registered: Dec 2012
Distribution: Kubuntu, LUbuntu, Mint, Debian
Posts: 16

Rep: Reputation: Disabled
webm files, too

Good to hear it works for webm files, too! Thanks for that!

It would be interesting to do some latency studies when transferring digital audio over a wireless connection. In the past I've had to cable-connect audio systems to each other that were running from different mains phases. This needs great care! In Europe, we have 380V between phases and all we need is a faulty power supply! One cannot always avoid such inter-phase situations, but it's risky. A friend of mine connected a sound system running from one mains connection to a system running from another mains connection and got some burnt electronics in response.

For such situations a wireless bridge is a welcome tool. Unfortunately, a professional transmitter/receiver pair for audio is quite expensive. Using a WLAN bridge is much cheaper.

With digital audio latency can become an issue. For example, when I send a microphone feed from my mixer to an FOH amp I should really have less than 30 ms latency; I really need a near-instantaneous audio transfer from my microphone to the FOH speakers.

I'm sure there are ready--to-buy professional low latency WLAN solutions for audio transmissions, but most of them will be expensive plus it's much more exciting to experiment than to buy. Alas, it'll be a while before I will come round to do the fiddling...

Last edited by peter2012; 10-18-2017 at 03:29 AM.
 
  


Reply

Tags
freebsd, linux, nas, network audio, pulseaudio



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Network Audio Sink and Audio Mastering for Radio Station dutler Linux - Software 1 11-30-2009 04:33 PM
Possible to send audio to multiple bluetooth headsets at once? damonhastings Linux - Software 3 06-30-2009 11:10 AM
Postfix : mail cannot send to send outside ( can send/receive locally) bobbinsupport Linux - Networking 3 12-15-2007 10:40 PM
send packets at network Jamesminh Linux - Networking 0 10-01-2004 02:38 AM
Cd player wont send audio to sound card linuXBOX Linux - Hardware 6 07-28-2003 09:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 07:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration