How to: AirTunes without AirPort
This how-to describes how to set up a linux (or mac or even windows) machine to serve as a sound client for your mac so that it will play any sound from your mac over network. For example you can sit on the couch with your MacBook on your lap and don’t have to shredder your music with these tiny internal speakers. Or, you could play music in your living room from the mac in your office. Apple calls this functionality AirTunes and sells it with its AirPort or TimeCapsule products.
Wonderful world? Almost. What you will need:
- Joy on fixing computers
- Time
- A linux box or a mac that is connected to the speakers. E.g. your stereo.
It should potentially be able to run forever so you don’t have to turn it on every time you want to use your speakers. If you already have an existing set-top-box for your TV running linux (e.g. the Reelbox or any other VDR) you can of course use this! I’m using an VIA EPIA Mini-ITX board with fanless cooling. You could also use a windows machine with cygwin on it.
No matter how this machine is shaped, I will reference to it as the client from now on (because it receives the sound stream). - Some kind of network connection between the mac (we call it the server here) and the client.
Most likely this connection is wireless through your router.
If you would have to buy an extra router for this purpose anyways, think about spending the money on an Apple AirPort and have it working out of the box. But, on the other hand if you already meet the four prerequisites, then you can save at least a hundret bucks!
0. Before you start:
- Have an OS running on the client. Installing Linux or cywing is a chapter that cannot be covered here.
- Make sure you have a working network connection between server and client. This too, is another chapter for itself.
- Connect the stereo or other speakers to the client. (this is important for testing)
A. Setting up the client-side (receives sound)
We need to get sound out of it and the Enlightment Sound Deamon (esd) working.
Important: I assume a debian system here. If you use another distro, you should know what to do there.
- See if you have it already installed. Type
# esd -tcp -publicin the promt. If it starts and makes a funky sound, you’re half way there! Continue with B. Setting up the server side
If not, install it with# apt-get install esoundand try the above again. If it still doesn’t work, do the following. - To get your soundcard working, it’s easiest to use ALSA (established and works with most cards). To do so, install alsa-base and alsa-utils with
# apt-get install alsa-base and# apt-get install alsa-utilsresepctively. Restart. Then configure your soundcard with# alsaconf. This assistant should find your soundcard and configure it for you. Then try 1 again.
If not, see section C. for Troubleshooting.
- Download Soundflower 1.3.1 from my webspace soundflower-131 or from MacUpdate
The developers homepage (cycling74) only has an older version.
After installation, go to your System Preferences and choose the Soundflower driver as your default output device and as your default input(!) device (and if you like, as default system sound device). What it does is to forward the sound (from the output) to the Soundflower driver (to the input) so we can access it with ESD. - Next, we have to install ESD. For this, we need MacPorts. If you already have it installed, jump to the next step. If not, don’t hesitate to install it! You might need it for other purposes in future anyways. You can get it from here: macports.org.
Optional: After installing, you might want to add/opt/local/binto your PATH. See my other post how to do this properly. - Now install the esd via macports by typing
# sudo /opt/local/bin/port install esound - Almost done! Run the esd and stream it’s input to the client by doing (not as root):
# esd -tcp -bind ::1 &(makes it listen to your computers ipv6 stream, “&” starts it in background)
Hit return twice to get the promt (Apple Terminal specific thing…) and pipe the input to the streamer with# (esdrec -s ::1 | esdcat -s <client-ip>) &
- When trying to start esd you get
error /dev/dsp not found.
? Have you installed alsa-base? Run alsa-conf again. It’s neccessary to restart afterwards! - alsaconf doesn’t find your soundcard.
? If it’s an onboard soundcard, make sure it’s enabled in the BIOS! - Both ESDs run but no sound.
? Stereo on? Stereo’s volume up? iTunes’ volume up? Song is not playing its last seconds?
? Does the client make a funky sound when starting ESD? This is essential. If not, make your soundcard work with ALSA.
? Can you ping the client IP?
? Is there a firewall somewhere inbetween? Make sure you can send on TCP port 16001
? Make sure you have started esd on the client first and then on the mac.
? Do not start esd as root! Do it as the user you’re logged in as (default).
? I had some trouble with background processes before. Try# esd -tcp -bind ::1then open another Terminal window and type# esdrec -s ::1 | esdcat -s <client-ip>
? Both processes on the mac and the process on the client should not quit. Test this by not appending the & sign to the command. If one of them quits immediately you found the problem. Try restarting the client and deleting the ~/.esd_auth files on the client and do it all again in the right order. - Some useful links
Similar tutorial: Mac OS X hints
ALSA official WIKI: alsa-project.org
S.o. who had ALSA trouble: nicktips.blogspot.org
ALSA sound mini How-To: ALSA sound howto
Official EsounD Manual: http://www.tux.org/~ricdude
Debian Packages. You might find something useful for tests here: packages.debian.org
- Startup script on client. Again, I assume a debian system here.
Modify your/etc/esound/esd.confto look like this esd.conf. Important is to set theautospawnto1and thedefault_optionsto-tcp -public.
Warning: This config makes esd listen for any incoming stream. Replace-publicby-bind <server-ip>to make it listen only to your mac!
Then extract this startup script Esound (for init) to/etc/init.d/and make proper symlinks by runningupdate-rc.d Esound defaults. That’s it. On next boot, esd should start automatically. If you ever need to start it by hand you can simply doesd & - Startup script on the server. This is still beta and not working 100% reliable. If you made any progress here, I would be thankful to hear from you.
Download this startup script: Esound for mac and extract it to/Users/SharedThen set it to be executed at login by typing:sudo defaults write com.apple.loginwindow LoginHook /Users/Shared/Esound
Hint: Give the ESD some time to respawn after waking up your mac from sleep. - Troubleshooting
If the whole machinery doesn’t work after wakeup or reastart, you probably have to restart the deamon on the client. To do this, find out it’s PID withps aux | grep esdandkillit. Then restart it withesd &. Next, on the server side kill it the same way and restart streaming by doubleclicking on the/Users/Shares/Esoundscript. Any suggestions are welcome!
Do you see a way to output the same sound both through ESD and a local Line Out? How about synchrony?
Tim
Hello Tim,
Yes, it is possible to output the sound on both devices. In Soundflower, you have two output channels. If you Install Soundbed (included here http://www.cycling74.com/download/soundflower121.dmg) you can choose the Built-In Output as the second channel.
Your second question: Unfortunately it’s not synchronous in my setup. I’m using a wireless connection through a router and have a shift of about a half second. It might be better through a direct wired network connection, though.
This time shift makes it also impossible to watch movies with wireless sound (sound doesn’t fit to the pictures)!
Regards,
Rolf
Ok, I played around with this.
- Your setup works just as well with default installation of Pulseaudio on Ubuntu 8.04 (Hardy). All I had to do on the client side was to install Pulseaudio Device Chooser and enable network access. Everything else is done bei Pulseaudios ESD-Module.
- I had discovered Soundflowerbed in the meantime (couldn’t wait for your answer
and also faced asynchronous sound. But I was able to solve that with Airfoil and “Airfoil speakers” from http://www.rogueamoeba.com. While Airfoil is pretty well known amongst Airport owners, I didn’t know that the free speakers app is available for Linux. Now everything is playing in perfect sync and my Airfoil-License finally makes sense
Tim
I forgot to mention that Airfoil also is a solution for synchronous playback of video on the mac and audio via Airport Express / Airfoil speakers.
Hello,
I’m trying to set this up the other way, streaming sound from a linuxbox to a G4 mac mini. Do you know if there is something special you have to do to get esd working on the mac client. I’m not getting the funky sound you are talking about.
Hello lePlaid,
First of all, have you managed to install the ESD on your Mac and on your linux box?
Secondly, If you want to use the Mac as the Client (s.t. it receives the sound stream) you’ll have to select the ESD as an output device there. Maybe Sunflower helps. Then on the server side (linux in your case) you will have to select ESD as your input and output device (I have no idea how to do this. Maybe you can select it among your soundcard drivers).
Good luck!
Hello,
Thanks for your answer, this is how far I’ve gotten until now.
I have managed to install esd on the mac, my client (which is connected to my living room sound system and working as a sort of entertainment system). It was an easy install using macports just
sudo port install esound
and sit back and take a coffe while the G4 is compiling.
Next I also installed esd on my linux box, I belive it’s in the repositories of most linuxdistros, since I’m using Arch just
sudo pacman -S esound
Ok, now the fun begins, to test it I took down the firewall on the mac (only for testing I’m on a secure lan).
The start the esound daemon on the mac using the terminal
esd -tcp -public
Now from the linuxbox, open a terminal and just play something to test it, (use a file that is playable using esdplay, in my case a wav). First test that esd is working by starting a local esd
esd &
then
esdplay –server=localhost Turdus_merula_2.wav
So, it’s play and everything is nice, test play it on the mac
esdplay –server=ip.of.the.mac.client Turdus_merula_2.wav
And yes! My problem was I was not hearing the “funky sound”, but I’m still not hearing when staring esd on the mac, so maybe you are not suppose to?
Next step is to get it to work to actually play something usefull. Then I will have to use some loop mechanism on my soundcard on the linuxbox, there is also the possibility of using PulseAudio. I can get back when I considered the alternatives. (Now I must study, I’ll probably have a go at it in the weekend)
Thanks for your help, I will probably put this on my (swedish) blogg, if you object to that please tell me. It will be in swedish then, but if I have time I can make a translition for you to put here.
Hi lePlaid,
Thanks for your report.
You wrote about the loop mechanisim: Maybe one solution could be to use a pipe as I described in my article: esdrec -s ::1 | esdcat -s
When you have the article on your Blog, give me a Trackback or Pingback!
Hi Rolf,
Many thanks for the clear explanations: I got it to work, streaming sound from MackBookPro on Snow leopard (wireless) to an old iBook on Tiger, cabled up to a stereo and to the LAN.
A note on watching movies with this setup: as mentioned, there is a noticeable delay between image and sound (about 500ms on my setup). But this is actually very easy to fix if you use VLC player (http://www.videolan.org), as there is a setting called Audio desynchronization compensation. This is accessible in Preferences > Audio (visible when choosing the ALL option). This can also be set dynamically with keyboard shortcuts F & G (check the shortcuts on your system in Preferences > Hotkeys)..
On my setup, audio and video are perfectly in synch with an audio delay setting of -500ms.
I’d like to post a question here:
Suppose I want to pipe sound to BOTH esd AND a set of connected speakers (or the mac’s built-in speakers) at the same time? Any hints?
Hi,
I do not know, how this is possible at the moment but you probably would not want that anyways. The delay of the network connected speakers is so high, that the sound would be noticably out of sync with the built-in speakers.
If you solve your problem, it would be nice, if you leave a comment here, how you did it for the next visitors to come.
Regards,
Rolf
Hi,
I have been trying to make my G4 Ibook the client ( connected to the stereo ).
But I seem to have trouble with the sound coming out. I think it has to do with the driver
but I seem not to come able by any info to install ALSA drivers or make esound use core audio.
Any suggestions
thanks a lot, great post