Using AS to control multiple instances of Airfoil

Posted on
Thu May 03, 2012 6:50 am
roussell offline
User avatar
Posts: 1108
Joined: Aug 18, 2008
Location: Alabama

Using AS to control multiple instances of Airfoil

So, I found that by drilling down to the airfoil executable in the app bundle and creating multiple copies of that executable (airfoil1, airfoil2, airfoil3, etc.) that I could then dblclick on those separate copies and effectivly launch separate instances of airfoil. ps ax |grep Airfoil in Terminal correctly shows the renamed executable with unique PIDs. What's more interesting is that with multiple instances running, I am able to send one source to one remote speaker, and a different source to another. I've only tried it with 3 sources/instances and 4 'zones', which were mixtures of ATVs, AF remote speaker clients on Mac and PC, and the remote speaker app on my iPhone. It worked as expected, correctly routing or merging zones depending on what I clicked in the AF instances.

Here's the question: How can I control those multiple instances using AppleScript? I've tried various combinations of telling "application process" and/or "unix id" to do something but I've had no luck in getting it to work. "Tell application" seems to work in a fifo manor - controlling the earliest-launched copy of the executable.

I just priced out a few 'true' whole house audio systems for the new home we're building and the prices are in the $6,000 to $7,000 range. I'd much rather buy a dozen Air Port Expresses and then figure out a way to control multiple instances of Airfoil through Indigo. BTW, for sources - at a minimum I'm looking at iTunes, possibly two Pandora clients (the command line pianobar app piped through two virtual audio devices created with Soundflower) and possibly something piped through the line-in jack on the mini...

Thanks in advance,
Terry

Posted on
Thu May 03, 2012 8:58 am
jay (support) offline
Site Admin
User avatar
Posts: 18224
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Using AS to control multiple instances of Airfoil

I don't believe you'll be able to get the scripting working - AppleScript targets an application based on it's creator id - which in the case of multiple copies of the same app running will make it impossible to distinguish which is which. At least I believe that's the case.

Did you look at the Sonos devices? It might not be quite that expensive. I don't personally use them but I've heard really good things about it and there's a plugin being developed.

And, if you don't mind my asking, before the sheetrock goes up, you are planning on pulling speaker wire to all the rooms, right? It's cheap to do it when there's no sheetrock. When I built my house, I pulled speaker wire to every room (as the electrician was pulling his wire) - each through a location where I could install a volume control (some I actually installed others I just left the wires in the wall for future use). Then home run the wires back to a central location. Then you have all sorts of options. For instance, in my house I have 3 amplifiers: one dedicated to the media room, one in the master bedroom, and one for the rest of the house. I have an AE connected to the whole-house amp and stream iTunes to that since I don't need different music in any of the "whole house" rooms. However, if I wanted to I could have separate sound to each room by putting in more hardware.

Just my experience, YMMV. :)

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu May 03, 2012 10:21 am
roussell offline
User avatar
Posts: 1108
Joined: Aug 18, 2008
Location: Alabama

Re: Using AS to control multiple instances of Airfoil

Thanks, I was afraid you say something like that... I'll keep poking around looking for hacks/workarounds and post back if I find anything useful.

I've looked at and like Sonos devices - it's still about a $4800 commitment though. At that price-point I'd probably go ahead and go the traditional route. On the traditional whole-house-audio front it's between a Nuvo Concerto or HTD Lync 12 system (whichever I get I'll develop and release an Indigo plugin :) ) with a slight edge going to HTD at the moment. A low-end option that is still partially on the table is a Breathe Audio system. They seem like decent systems and are connected to Nuvo corp. in some way, but apparently they have been discontinued or end-of-lifed for a while, yet manufacturing and distribution continues. Through outdoorspeakerdepot.com I could get a 12 zone system (base and expansion - not including speakers for about $1,800). Again the system seems nice but not sure if I want to gamble on it yet. It might be an alternative if I can't get the APE/Multi-Airfoil running. Like the others, if I get it, I'll release a plugin for Indigo.

Yeah, I'll be pulling wires and installing speakers either way. I'm not supposed to be able to do so, but I've been befriending the on-site foreman and he's going to 'look the other way' for a couple of days after the electrical inspection and before the drywall goes in. I'll have to loop the wires in the wall/ceiling cavities and not install install boxes until after we close, but I can live with that. I'll be taking copious amounts of photos and measurements for later reference.

There's a Linux app/library (cant remember the name ATM) that allows pushing audio to APEs so I may look into a Linux solution on a separate box that would become the 'audio server' if I can't get Airfoil going like I want. I envision a plug strip or two loaded down with APEs behind the rack - each with an Ethernet connection and a audio connection to a couple of multi-channel amps that feed the zones. If I can get past the multiple-source issue some way, then it should provide a decent whole-house audio solution for less than $2,000. I'm trying to save money here as I'll also have a $4,000-$5,000 Insteon order in the next couple of months (Norm, any discounts/deals to keep this out of Smarthome's cart??? ;-) )

Terry

Posted on
Thu May 03, 2012 11:20 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Using AS to control multiple instances of Airfoil

roussell wrote:
So, I found that by drilling down to the airfoil executable in the app bundle and creating multiple copies of that executable (airfoil1, airfoil2, airfoil3, etc.) ...

You might try copying AirFoil.app (save it as AIrFoil2.app or whatever...) and then edit the info.plist in AirFoil2 to change the bundle name to AirFoil2 as well.

It will startup a separate instance of AirFoil. I didn't test it very thoroughly, but this short script did work as expected...

tell application "Airfoil2"
quit
end tell

Good luck...

BTW I just found a very nice iDevice app... Reemote from http://010dev.de/ It gives you the same control over AirFoil you get with Apple's Remote app for iTunes, even better, since AirFoil can stream iTunes anyway.

Posted on
Thu May 03, 2012 11:28 am
nsheldon offline
Posts: 2469
Joined: Aug 09, 2010
Location: CA

Re: Using AS to control multiple instances of Airfoil

I haven't tested it a lot, but by simply duplicating the Airfoil application bundle in the Applications folder (calling it Airfoil 2), I'm able to use AppleScript to send different instructions to the 2 copies of Airfoil running at the same time by referring to the 2 separate instances by their POSIX path rather than their registered application name. For example, this worked for me...
Code: Select all
tell application "/Applications/Airfoil 2.app"
   set theSource to the first application source whose name is "Play Sound"
   set the current audio source to theSource
end tell

tell application "/Applications/Airfoil.app"
   set anotherSource to the first application source whose name is "QuickTime Player"
   set the current audio source to anotherSource
end tell

Posted on
Thu May 03, 2012 11:32 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Using AS to control multiple instances of Airfoil

@nsheldon... Looks like we were posting at the same time. Take a look at my post, it should help avoid the need for using the path.

Posted on
Thu May 03, 2012 11:39 am
roussell offline
User avatar
Posts: 1108
Joined: Aug 18, 2008
Location: Alabama

Re: Using AS to control multiple instances of Airfoil

tell application "/Applications/Airfoil 2.app"


AHH HAA!!! Now it's a party! Out of all of the various things I tried, nothing as simple as duplicating the entire bundle crossed my mind. I'll give that a try as soon as I get home. I also didn't realize that you could specify a file system path/filename with "Tell Application". Brilliant!

Trry

Posted on
Thu May 03, 2012 12:03 pm
nsheldon offline
Posts: 2469
Joined: Aug 09, 2010
Location: CA

Re: Using AS to control multiple instances of Airfoil

berkinet wrote:
@nsheldon... Looks like we were posting at the same time. Take a look at my post, it should help avoid the need for using the path.

Hehe. Actually, I saw your post and tried it out on my machine with very mixed results. If both Airfoil and Airfoil2 were already launched and running, referring to them by their application file name in the "tell application" statement seemed to work. But if one copy were not currently running and I used
Code: Select all
tell application "Aifroil2"
launch
   set theSource to the first application source whose name is "Play Sound"
   set the current audio source to theSource
end tell

it wouldn't actually launch the copy but just send the instructions to the already open original Airfoil application. By explicitly referring to the different copies of Airfoil by POSIX path in the "tell application" statement, I was able to avoid this problem. However, if this doesn't work for you or others, I'd be interested in learning about it.

@russell: Let me know if this doesn't work for you as well. If not, maybe it's related to OS/AppleScript version or something.

Posted on
Thu May 03, 2012 12:09 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Using AS to control multiple instances of Airfoil

Gotcha... As I noted "I didn't test it very thoroughly," so, you went further, found and fixed problems. Cool. Thanks for the follow-up.

Posted on
Fri May 04, 2012 6:43 am
roussell offline
User avatar
Posts: 1108
Joined: Aug 18, 2008
Location: Alabama

Re: Using AS to control multiple instances of Airfoil

Thanks guys, it works! I did notice some of what nsheldon mentioned if an airfoil instance wasn't already running. Sending an 'activate' to the instance at the beginning seemed to help, but I think in 'production' I'll handle this by having a separate shell script that's responsible for launching, monitoring, and killing the instances. I'll most likely have them just start up on boot since they only seem to consume 12-25MB per instance so the weirdness noticed won't be a problem.

I did some math last night, and it looks like an AE/Airfoil/Pandora/iTunes based system will still run around $2800. A big chunk of that is in multi-channel amps and speakers, but buying 12 AEs is pricey too, even at refurb prices. So that's got me thinking if this is the approach I want to take. I do Home Automation and Home Audio as a side business (hoping to grow into full-time) and am settin gup the new home as a showroom. I've found that no matter how much you spend on glossy handouts and websites, nothing beats putting an iPad in somebody's hand an letting them control light's, music, cameras etc. in real time. In fact, to-date all of my sales have come from that. So, anyway, part of that is presentation - and having a few rack components definitely 'looks' better than a plugstrip full of AEs. I balance that thought with the fact that most of my business has been and will be existing construction and in some cases it isn't possible to run wires to the areas that people want music. In those cases, a wireless solution like Sonos or AEs is a good solution so I see the need to be proficient at both - but I'm not sure which I want in my house... I've thought about the concept of semi-wired for existing construction in that ceiling speakers are still installed, but the wires ran locally to a location on the wall where they could be connected to an out-of-sight AE/Amp.I think a "T-Amp" and an AE could both comfortably fit inside a triple gang box so that might be a cool option - I may have to play with that and see. OOh, I just thought of a cool feature request - gotta post that next.

Terry

Posted on
Fri May 04, 2012 9:40 am
roussell offline
User avatar
Posts: 1108
Joined: Aug 18, 2008
Location: Alabama

Re: Using AS to control multiple instances of Airfoil

These are sweet: http://audioengineusa.com/Store/Audioengine-5#gallery. They're pretty much made for an AE (plugs into the back) and the 'nets full of good reviews for 'em. Of course at $299 (Amazon) + an AE you're in Sonos Play5 territory now...

Image
ImageImage

Terry

Posted on
Fri May 04, 2012 9:58 am
nsheldon offline
Posts: 2469
Joined: Aug 09, 2010
Location: CA

Re: Using AS to control multiple instances of Airfoil

Cool! Glad you got it working.

Those are some nice AE-ready speakers. Too bad they're kind of expensive. Still, very cool design.

Posted on
Sat May 05, 2012 11:44 pm
hamw offline
Posts: 1212
Joined: Mar 31, 2008

Re: Using AS to control multiple instances of Airfoil

For what it's worth, I have home run wiring to a central closet. I bought an HTD 1235 amp new for about $700 and found a Vaux audio matrix switch on ebay for around $300. Total cost of about $1000 not including speakers. The nice thing about the Vaux is it is controlled with a serial port. Very easy to use and Indigo friendly. Much cheaper than 12 Airport expresses and separate amps, and no concerns with signal dropouts.

Posted on
Sun May 06, 2012 7:04 am
roussell offline
User avatar
Posts: 1108
Joined: Aug 18, 2008
Location: Alabama

Re: Using AS to control multiple instances of Airfoil

Funny thing, I was looking for good deals on matrix switches yesterday. I used them years ago in commercial installations but had forgotten about them since. It's definantly a possibility, but it looks like all of my sources will be computer sourced (no cd player or conventional radio) so I'd have to put several AEs on the matrix inputs any way so in my case it may add an unneeded layer of complexity.

BTW, speaking of complexity; take a look at my crazy thread for a DIY hdmi video matrix switcher over on Cocoontech: http://cocoontech.com/forums/topic/21363-diy-hdmi-matrix-switcher-sanity-check/page__pid__174004

I picked up a few AEs from the Apple store yesterday to begin testing, maybe in between mowing the lawn, washing the cars, and the other things that have to get done today before I'm allowed to play...

Terry

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 18 guests