Aifroil Volume Variables

Posted on
Sat Apr 09, 2016 9:18 am
dz1rfj offline
Posts: 135
Joined: Mar 13, 2016

Aifroil Volume Variables

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

Posted on
Mon Apr 11, 2016 11:59 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Aifroil Volume Variables

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

Posted on
Tue Apr 12, 2016 12:34 pm
dz1rfj offline
Posts: 135
Joined: Mar 13, 2016

Re: Aifroil Volume Variables

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

Posted on
Wed Apr 13, 2016 11:31 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Aifroil Volume Variables

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

Posted on
Wed Apr 13, 2016 4:48 pm
dz1rfj offline
Posts: 135
Joined: Mar 13, 2016

Re: Aifroil Volume Variables

Great, thanks Jay

Thanks
-Brian

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest