Aifroil Volume Variables

This forum is where we've moved the discussions of the original Airfoil plugin that shipped with Indigo 5/6 (and is now open source). You may continue to ask questions in this subforum, just make sure that it's not about the new Airfoil Pro plugin that shipped with Indigo 7 (ask those questions below).
dz1rfj
Posts: 139
Joined: Sun Mar 13, 2016 7:10 pm

Aifroil Volume Variables

Post by dz1rfj »

Jay from support, and others , posted some code that helped me write this:
(please keep in mind I am with Indigo about 25 days, and am not even a scripting novice, I would say :cry: )

This works great....but How do I revert volume after an incoming message where I raise all speakers to volume 70, then switch back to music. It gets LOUD after the announcement. I thought save speaker state would have saved the volume, but that does not seem to be the case.


Code: Select all

tell application "Airfoil"
	set VolMac to volume of speaker "Computer"
	
	set VolPool to volume of speaker "Airplay-Pool"
	set VolAppleTV to volume of speaker "Apple TV"
	set VolGarage to volume of speaker "DCH-M225"
	set VolMaster1 to volume of speaker "Denon AVR-X1000"
	set VolKitchHall to volume of speaker "Kitchen / Upstairs Hall Speakers"
	set VolMaster2 to volume of speaker "Master Speakers"
end tell

# then you multiply that by 100, convert to an integer, and insert it into the Indigo variable

set value of variable "VolumeMac" to (VolMac * 100) as integer
set value of variable "VolumePool" to (VolPool * 100) as integer
set value of variable "VolumeAppleTV" to (VolAppleTV * 100) as integer
set value of variable "VolumeGarage" to (VolGarage * 100) as integer
set value of variable "VolumeMaster1" to (VolMaster1 * 100) as integer
set value of variable "VolumeKitchHall" to (VolKitchHall * 100) as integer
set value of variable "VolumeMaster2" to (VolMaster2 * 100) as integer
So......I have searched and searched, as to how I can return the speakers back to each individual variable, but have not seen anything. Any examples would be great!.

Thanks for any help!
Thanks
-Brian
User avatar
jay (support)
Site Admin
Posts: 19232
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: Aifroil Volume Variables

Post by jay (support) »

Just reverse it:

Code: Select all

set VolMac to (value of variable "VolumeMac" as integer) / 100

tell application "Airfoil"
	set (volume of speaker "Computer") to VolMac
end tell

Jay (Indigo Support)
Twitter | Facebook | LinkedIn
dz1rfj
Posts: 139
Joined: Sun Mar 13, 2016 7:10 pm

Re: Aifroil Volume Variables

Post by dz1rfj »

Jay - thanks!

:D I am having a blast learning all this stuff! Works great, except....what if... a device is unreachable (powered off, like the apple TV box) , the script fails. Is there a way to account for that?
Thanks
-Brian
User avatar
jay (support)
Site Admin
Posts: 19232
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: Aifroil Volume Variables

Post by jay (support) »

Just wrap each volume set in a try:

Code: Select all

tell application "Airfoil"
	try
		set (volume of speaker "Computer") to VolMac
	end try
	try
		set (volume of speaker "Some Other Speaker") to VolMac
	end try
end tell
This will basically ignore any failures. You could do it all in one try, but then nothing after the failure would get done. Doing each in it's own try block will avoid that.
Jay (Indigo Support)
Twitter | Facebook | LinkedIn
dz1rfj
Posts: 139
Joined: Sun Mar 13, 2016 7:10 pm

Re: Aifroil Volume Variables

Post by dz1rfj »

Great, thanks Jay
Thanks
-Brian
Post Reply

Return to “Old Airfoil Discussions”