Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Simulate Airport Express network audio Network
Have you ever wanted to wirelessly stream all audio from your Mac to the Unix/Windows/Mac box in your cupboard connected to your beefy stereo? Here is an alternative to buying an Airport Express for the purpose.

This tip is similar to this hint but after experimenting with that technique and various other options I think I've hit on an improved setup.

Steps to perform on your Mac:

  • Download and install Soundflower. This will allow you to redirect all audio played on your Mac over the network.
  • Install MacPorts as well; this will make it easy to install esound and ffmpeg which are needed later.
  • Install esound with the command sudo port install esound in Terminal.
  • Similarly install ffmpeg with sudo port install ffmpeg.
  • In System Preferences » Sound, select Soundflower (2ch) as the Input and Output devices.
  • Run Soundflowerbed that came with Soundflower, found in the Flower menu item, and select None (OFF) under Soundflower (2ch). This turns off your built in speakers so only the network sound will play.
  • Start esd with the Terminal command: esd. Note we are not actually using esd to transfer the audio over the network, just for recording local audio.
  • Record the audio captured by Soundflower and stream it over the network using the rtp protocol with
    esdrec |  ffmpeg -f s16le -ac 2 -i - -acodec libmp3lame -ab 320k -f rtp rtp://myIP:1234 
    
    Here myIP is the IP address of the box you want to stream to.
Steps to use on a machine connected to your stereo:
  • Install VLC. On an ubuntu/debian box you can use sudo apt-get install vlc-nox for a console version.
  • Run VLC to stream your audio from your mac with: vlc rtp://myOtherIP:1234 where myOtherIP is the address of the box you are running VLC on.
You should now have all audio from your Mac playing over the network.

How it works:
  • Soundflower captures any output going to the speakers and redirects it to the microphone input (this is all done digitally, so there is no loss in quality).
  • The program esd opens the sound device and makes it available to other local programs.
  • Then esdrec connects to esd and records input to the microphone and passes it on to ffmpeg.
  • After that ffmpeg takes the raw audio and encodes it as mp3 then publishes it on the network as an rtp stream.
  • The other computer connects to the rtp stream and plays the audio.
Caveats:
  • There is about a two second delay between playing on the Mac and hearing on the receiving machine. This makes watching videos with network audio a bit rubbish, but using VLC or MPlayer you can adjust the audio sync to compensate for this.
  • The program esound isnt really needed, as we are only using it to record audio rather than using its network audio abilities. Whenever I've tried using esd to stream audio I've experienced a big delay and garbled audio, hence using ffmpeg/vlc instead. In this setup esound/esdrec can be replaced with any commandline tool that records audio and streams to stdout. The only tool I could find to do this is esdrec.
  • Some CPU time is used on the Mac transcoding and streaming the audio, but it is fairly small (about 5 percent on my MacBook Pro).
  • The audio is transcoded as mp3, which is lossy so there will be a slight degradation in sound quality. I tried using lossless codecs (e.g. flac) with ffmpeg streaming but couldn't get it to work.
  • This same ffmpeg technique can be used to stream video as well as audio, which would let you make your cupboard machine act more like an Apple TV.

[crarko adds: I haven't tested this one, but I might try it at some point in the future. It sounds like a lot of hoops to jump through, but I'm always looking for new ways to stream content to my iPad. Also note that using MacPorts requires having the Developer Tools installed.]
    •    
  • Currently 4.00 / 5
  You rated: 1 / 5 (7 votes cast)
 
[18,837 views]  

Simulate Airport Express network audio | 12 comments | Create New Account
Click here to return to the 'Simulate Airport Express network audio' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Simulate Airport Express network audio
Authored by: waw74 on Feb 23, '11 08:04:31AM
or just head over to iospirit.com and get remote buddy, it costs a few dollars for the transmitter, but they have a free receiver program that runs on windows, mac, linux, and iOS. you can send to all of those in addition to airport expresses, and apple TVs. and do it to multiple units in sync with each other. you can pick a single program to grab the audio from, or send the entire system audio.

[ Reply to This | # ]
Simulate Airport Express network audio
Authored by: soapbeard on Feb 24, '11 11:31:45AM

That product doesn't seem to be performing the same function, it seems to be allowing control of a mac's audio output from other devices over the network, like an iphone or linux pc with a remote control.

This hint is about streaming audio from a mac to another computer over the network.



[ Reply to This | # ]
Alternative: Airfoil
Authored by: lullabud on Feb 23, '11 10:11:47AM

Airfoil is an app that will do this in a more elegant way. It has free audio receiver apps on iOS, Windows, Mac OS and Linux. I've used it for years and had decent success with it. In a wireless network there can be serious sync issues when you stream to lots of devices, but that's the only real problem I've had.

http://rogueamoeba.com/airfoil/

Edited on Feb 23, '11 10:38:17AM by lullabud



[ Reply to This | # ]
Alternative: Airfoil
Authored by: chadvonnau on Feb 23, '11 12:12:45PM

Airfoil works, but calling it elegant is a bit of a stretch.

I recommend Soundfly if you have 2 macs. It's so simple and perfect. The only down side is that, since OS 10.5, audio can break up when the receiving computer has high network usage. If you get bitten by this, airfoil or this soundflower setup might be more reliable, but otherwise, soundfly is the way to go.

http://www.abyssoft.com/software/soundfly/



[ Reply to This | # ]
Alternative: Airfoil
Authored by: everkleer80 on Feb 24, '11 06:09:37AM

There is also an iPhone client app - great for when you want to listen to audio from your computer with [wired] headphones, but still be free to move around!



[ Reply to This | # ]
Alternative: Airfoil
Authored by: soapbeard on Feb 24, '11 11:21:12AM

I tried airfoil and I wouldn't say it was elegant either. First, the airfoil speakers program for linux uses mono to run which means lots of extra libraries to install. Second the linux version on their site doesn't actually work unless you copy some DLLs out of the windows version into to Forth, with it all set up the sound stuttered, was garbled and has a large delay so it was useless. Fifth, you have to buy it, thankfully I could trial it before finding out it didn't work well.



[ Reply to This | # ]
Simulate Airport Express network audio
Authored by: jdan on Feb 23, '11 01:54:41PM

I think the easiest way to do this is to use Soundflower in combination with RaopX. Instructions can be found on the website of RaopX - see at the end.
I have made two apps with AppleScript-Editor to start and stop the RaopX stream. One click on the start app and seconds later you can listen to your favourite music. The start app changes the system preferences, starts the terminal, types RaopX and starts the stream and it opens grooveshark.com in Safari. One click on the other app to stop the stream, close the terminal and reset the system preferences. The apps work flawlessly on my laptop but are of course written for my Dutch Mac Os. It should not be too much of a problem to make the necessary changes in the scripts, though. You then save the scripts as programs (Save as …). Put them in the program folder, drag the icons onto the dock.
The two scripts can be found here: http://users.fulladsl.be/spb12567/GeluidRaopX.scpt and http://users.fulladsl.be/spb12567/GeluidLaptop.scpt
(I originally posted this on the RaopX website: http://www.hersson.net/raopx/comment-page-4#comments - look for jdan)



[ Reply to This | # ]
Simulate Airport Express network audio
Authored by: soapbeard on Feb 24, '11 11:37:01AM

Using raopx is only useful if you have an airport express to stream to, this is about streaming from a mac to a generic networked computer



[ Reply to This | # ]
Simulate Airport Express network audio
Authored by: everkleer80 on Feb 25, '11 08:50:28AM
...this is about streaming from a mac to a generic networked computer
Of course the title suggests the opposite... which got me falsely excited when I read it since I've been looking for ways to stream to an Airport Express outside of iTunes.

[ Reply to This | # ]
Simulate Airport Express network audio
Authored by: La_Tristesse on Feb 23, '11 02:32:57PM

Thank you so much. Worked flawlessly. This is the only solution for me to transfer a audio stream from my macbook to my linux plug computer. In the past I tried to connect directly over the esound deamon but for some strange reason I didnt got any output (see http://blog.haynberg.de/?p=14 ).
Im getting some strange errors while launching vlc in command line mode:

VLC media player 1.1.3 The Luggage (revision exported)
Blocked: call to unsetenv("DBUS_ACTIVATION_ADDRESS")
Blocked: call to unsetenv("DBUS_ACTIVATION_BUS_TYPE")
[0xa6718] inhibit interface error: Failed to connect to the D-Bus session daemon: /usr/bin/dbus-launch terminated abnormally without any error message
[0xa6718] main interface error: no suitable interface module
[0x9c1c8] main interface error: no suitable interface module
[0x120d8] main libvlc error: interface "globalhotkeys,none" initialization failed
[0x9c1c8] dummy interface: using the dummy interface module..

Any suggestions?



[ Reply to This | # ]
Simulate Airport Express network audio
Authored by: joostjodel on Feb 24, '11 09:16:06AM

Haven't tried this hint, but wouldn't using JackOSX be much easier (http://www.jackosx.com)? The advantage is it that - unlike some suggestions posted in comments here - it is free, runs on older systems (down to 10.4 Tiger), and is way easier to set up.

Basically the idea is that you install and run JackOSX on both computers. One acts as the "master", and is connected to the audio output device, e.g. a stereo. The computer sending the audio (may even be multiple computers) acts as a "slave".

1) After having installed Jack, on the master you simply run in a terminal:
$ jack_load netmanager

2) And on the slave you run:
$ jackd -r -d net

3) Then you open up Jackpilot on the master and route the slave computer to "system" output.

4) On the slave you route the music player to "system" as well. Et voila.

All happens in a network-transparant way, i.e. no IP/port configuration (assuming you have enabled unhampered LAN to LAN traffic). See for a more thorough explanation here: http://trac.jackaudio.org/wiki/WalkThrough/User/NetJack2.

Caveat 1: On that page it is written that it is less suited for wireless networks, but it may just work for you if you have fast WiFi at home… On my WiFi-G network with less-then-optimal signal I did notice some dropouts once in while. Haven't tried it on N.

Caveat 2: It pretty much hogged the CPU on my old powerbook acting as master… May work better on Intel-based macs.



[ Reply to This | # ]
Simulate Airport Express network audio
Authored by: sgaide on Feb 25, '11 09:32:29AM

Thank you very much for this hint.

esound was the missing link to be able to stream audio from my mac to my squeezebox devices.
Using a combination of esound, icecast and ices2 I'm now able to stream anything from my laptop to any squeezebox in the house.

Thanks again,

Sebastien.



[ Reply to This | # ]