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

Another way to stream iTunes audio from within iTunes Apps
This method allows you to stream your iTunes audio from within iTunes to another computer on your network, preferably hooked up to your stereo. In my case, it´s an old laptop running Linux, hidden behind my stereo. Any flavour of *nix should do.

Here´s what you need:
  1. The esound package from Fink or any other source.
  2. An AppleScriptable audio recording app. I use Audio Hijack Pro, and this it what my hint covers.
  3. A computer with sound capabilities running *nix, also with esound.
This hint relies on two AppleScripts and two shell scripts. The AppleScripts will be put into the iTunes scripts folder, so that they can be started from within iTunes. The purpose of these scripts is to start and stop Audio Hijack Pro (AHP), as well as the shell scripts that will do the actual streaming.

First off, create a new session in Audio Hijack Pro named iTunes stream. Set the input to Application, and then iTunes. The format under the Recording tab should be AIFF(auto). Name the recordings with stream in their names. Make a note of the folder you plan to save your recordings to; I used a subfolder of my home folder named wifistream. To make this hint as useful as possible, you should also install Instant Hijack Session when prompted, to avoid restarting iTunes every time AHP starts the hijack session.

Then install the esound package. I used Fink and the accompanying Fink Commander; search for guides on how to use this if you are unfamiliar with it. There are tons of useful and free apps there!

Then for the actual scripts. We´ll start with the two AppleScripts. Name them as you like; mine are called Stream audio and Stop streaming. These scripts can just be pasted into Script Editor. Change the folder names so that they point to where you told AHP to save the recording.

This is the Stream audio script:
tell application "Finder"
  delete every item of folder "wifistream" of folder 
   "st" of folder "Users" of disk "Harddisk"
end tell
tell application "Audio Hijack Pro"
  set visible of window 1 to false
  start hijacking session named "iTunes stream"
  start recording session named "iTunes stream"
end tell
tell application "iTunes"
  play
end tell

set volume with output muted
do shell script "streamon &> /dev/null&"
And this is the Stop streaming script; again change the folder to the one you´re using.
tell application "Audio Hijack Pro"
  set visible of window 1 to false
  stop hijacking session named "iTunes stream"
  stop recording session named "iTunes stream"
end tell

tell application "Finder"
  delete every item of folder "wifistream" of folder 
   "st" of folder "Users" of disk "Harddisk"
end tell

set volume without output muted
do shell script "streamoff &>/dev/null &"
Save these in your iTunes Scripts folder. If it´s not there, just create it. Next, on to the shell scripts. I´ve called them streamon and streamoff. If you change the names, be sure to change the AppleScripts accordingly.

streamon script:
#!/bin/bash
PATH=$PATH:/sw/bin
sleep 2
tail -f -b 500  /Users/st/wifistream/stream.aiff | esdcat -s 10.0.2.100:54546 &
Again, change the folder to point to your recording, and the IP address to the one of the remote machine. Take a note of the port number (the one after the IP address; in this case, 54546.

streamoff script:
#!/bin/bash
killall tail
killall esdcat
Paste these two into your favorite text editor, and save them as plain text in your home directory. Then, open up Terminal and issue this command:
 sudo cp streamon streamoff /usr/bin
and then
 sudo chmod +x /usr/bin/streamon /usr/bin/streamoff
OK, now we´re finished setting up your Mac. The only thing that´s left for us to do is to set up the remote machine. Assuming this already has esound installed (if it hasn´t, install it according to your Linux distribution), just issue theis command:
 esd -tcp -public -port 54546 &
Replace the port with the one you used in the streamon script. The esound daemon can, of course, be started at boot up; refer do your Linux distribution's documentation on how to to this.

There, we´re all done! To start the streaming, just open up iTunes, click on the Scripts menu and select Stream audio. To stop it, click Stop streaming on the same menu. Easy, don´t you think? It might also be a good idea to have AHP running before you start the streaming, to make things go a bit faster. And, although this works flawlessly on my wireless connection, YMMV. Good luck, and if anything is unclear, just post a comment.
    •    
  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[20,287 views]  

Another way to stream iTunes audio from within iTunes | 6 comments | Create New Account
Click here to return to the 'Another way to stream iTunes audio from within iTunes' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Another way to stream iTunes audio from within iTunes
Authored by: merlyn on Dec 27, '06 03:13:46PM

Rather than bringing all of "esound" in from fink, just use Apple's AUNetSend and AUNetRecieve.

On one machine, use AHP to hijack iTunes, and create an AUNetSend to broadcast the sounds.

On the other machine, create a "nothing to system sound" AHP stream, and use AUNetRecieve to find the sent stream. Done.



[ Reply to This | # ]
Another way to stream iTunes audio from within iTunes
Authored by: steinarlem on Dec 28, '06 04:24:05AM

Well, this would only work with two macs running AHP, adding complexity in my eyes. And frankly, getting esound isn't that big of a hassle, not to mention you can use it with any *nix, even cygwin on Windows.



[ Reply to This | # ]
Another way to stream iTunes audio from within iTunes
Authored by: CoolerQ on Dec 30, '06 11:47:59AM

The problem with setting it up this way is that you end up with a huge AIFF file on your disk if you leave it running for a while (like, a few hours). Instead, you can use the "Pipe Dream" AHP plugin to send the audio directly to esound - I use the following as my script:

# (The shell used is always /bin/sh)
#
# This is a sample script
# that dumps input to a bit bucket
#

<&0 /sw/bin/esdcat -s atlas > /dev/null

Make sure the path to esdcat and server name are correct. The just hit the Start button in Pipe Dream and start AHP's hijacking.

--Quentin



[ Reply to This | # ]
Another way to stream iTunes audio from within iTunes
Authored by: n8gray on Dec 30, '06 04:28:32PM

If you don't want to pay for Audio Hijack Pro, google for Soundflower or Jack.



[ Reply to This | # ]
Another way to stream iTunes audio from within iTunes
Authored by: steinarlem on Dec 31, '06 05:05:10AM

CoolerQ:
Thanks, I thought of this issue as well, and this is exactly what I was looking for.
I´ll try to incorporate it in my scripts, as I like things to be as transparent as possible!



[ Reply to This | # ]
Another way to stream iTunes audio from within iTunes
Authored by: steinarlem on Dec 31, '06 05:20:18AM

Well, I tried this method, and it works fine, except theres no way to start the Pipe Dream plugin from the script(the help file says this as well). And it still records to disk, at least I found no way to omit this.



[ Reply to This | # ]