Sonos Sound Systems
Richard Leonard
rnaleonard at icloud.com
Wed Feb 23 11:18:09 EST 2022
Hi Jerry,
Since you are using Airfoil to send the audio, can you just use that for all the volume control. That works here. I send music from iTunes and spoken announcements from XTension that way. In general, I don't target specific speakers for output but I think that could be done. I have different makes of speakers so the "normal" volume is set to accommodate their different sound levels. Airfoil can send "System Audio" so it will include any sounds coming from the Mac.
I use this for "Normal Music"
tell application "Airfoil"
set speakerList to get every speaker
repeat with theitem in speakerList
if the name of theitem contains "Express" or the name of theitem contains "HomePod" then
set (volume of theitem) to 0.5
else
set (volume of theitem) to 0.2
end if
end repeat
end tell
tell application "iTunes" to set sound volume to 80
tell application "Finder" to set volume output volume 80
This is for "Quieter Music" which drops the relative volume by 20%
tell application "Airfoil"
set speakerList to get every speaker
repeat with theitem in speakerList
set x to (volume of theitem)
set (volume of theitem) to x * 0.8
end repeat
end tell
And for "Louder Music" which raises the relative volume by 20%
tell application "Airfoil"
set speakerList to get every speake
repeat with theitem in speakerList
set x to (volume of theitem)
set (volume of theitem) to x * 1.2
end repeat
end tell
When we wake up, the volume of the HomePods is lowered
tell application "Airfoil"
set speakerList to get every speaker
repeat with theitem in speakerList
if the name of theitem contains "Homepod" then
set (volume of theitem) to 0.2
end if
end repeat
set current audio source to system source "System Audio"
end tell
I send spoken announcements from XTension via a stand alone AppleScript which keeps announcements from running over each other, and keeps the volumes lined up. This lowers the music volume if iTunes is playing and then speaks the message:
on Talk(theMsg)
set theMsg to "[[slnc 100]]" & theMsg & "[[slnc 1000]]"
try
tell application "System Events" to set pid to the unix id of process "iTunes"
tell application "iTunes"
set x to sound volume
set sound volume to 30
end tell
say theMsg with waiting until completion
tell application "iTunes" to set sound volume to x
on error
say theMsg
end try
set theMsg to ""
end Talk
Hope this has something useful.
Rich
> On Feb 23, 2022, at 10:50 AM, James Sentman <james at sentman.com> wrote:
>
> Hello Jerry!
>
> There are some python libraries that claim to be able to control the sonos devices, there is some discussion about problems starting streams from various streaming services like Apple Music and such, but if you just want to adjust their volume and start and stop it would almost certainly be able to do that.
>
> I dont’ have any of these things to play with, but if you’re wililng to run some test code for me to see if any of these work I can almost certainly wrap some of this into a plugin in the shorter rather than the longer term.
>
>
>
>> On Feb 22, 2022, at 12:09 PM, Jerry — MacSolutions <jerry at stlmacguy.com <mailto:jerry at stlmacguy.com>> wrote:
>>
>> I’m wondering if anyone would have any interest in controlling their Sonos Sound System via XTension? Perhaps there is already a way to accomplish this however, my goal is to adjust the speakers in the house that I use for speaking alerts and then, adjusting the volume according to the sound level of the Sonos amplifiers.
>>
>> That... and also adjusting the sound on the Sonos speakers/amps so that when we turn on a TV the following morning, the sound level doesn’t blow us out the back door. :)
>>
>> Thanks!
>>
>> —Jerry
>>
>> _______________________________________________
>> XTensionList mailing list
>> XTensionList at machomeautomation.com <mailto:XTensionList at machomeautomation.com>
>> http://mail.machomeautomation.com/mailman/listinfo/xtensionlist
>
> Thanks,
> James
>
>
> James Sentman http://www.PlanetaryGear.org <http://www.planetarygear.org/> http://MacHomeAutomation.com <http://machomeautomation.com/>
>
>
>
>
> _______________________________________________
> XTensionList mailing list
> XTensionList at machomeautomation.com
> http://mail.machomeautomation.com/mailman/listinfo/xtensionlist
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.machomeautomation.com/pipermail/xtensionlist/attachments/20220223/93b56850/attachment.html>
More information about the XTensionList
mailing list