Wednesday, August 23, 2017

#1 2008-05-17 06:01:20 am

ged3000
Member
Registered: 2008-05-17
Posts: 2

Setting Sound Balance with AppleScript

Hi,

One of the speakers that I use with my computer is a bit temperamental, so I want to make an applescript to quickly adjust my balance from middle, to left, to right, and back to middle automatically, to see if it's packed in again. However, i can't seem to find any way of doing it easily, and wondered if anyone could help!

It seems that there's no easy setting to change to alter the balance (that I could find) - the only solutions I could see seem to use the Applescript UI scripting, which I can't seem to work out how to use.

Can anyone help me?

Model: Powerbook G4
AppleScript: 1.10.7
Browser: Safari 525.13
Operating System: Mac OS X (10.4)


Filed under: applescript, sound, balance

Offline

 

#2 2008-05-17 06:12:41 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11473
Website

Re: Setting Sound Balance with AppleScript

Hi,

something like this

Applescript:


tell application "System Preferences"
   activate
   reveal anchor "output" of pane id "com.apple.preference.sound"
end tell
tell application "System Events"
   tell slider 1 of group 1 of tab group 1 of window 1 of process "System Preferences"
       set value to 1.0
       delay 1
       set value to -1.0
       delay 1
       set value to 0
   end tell
end tell


regards

Stefan


Filed under: System

Offline

 

#3 2008-05-17 06:52:38 am

ged3000
Member
Registered: 2008-05-17
Posts: 2

Re: Setting Sound Balance with AppleScript

That's brilliant, thankyou! Just what I was looking for!

And I was so close, it was just the "set value to..." command that I couldn't figure out for myself...

Thanks!

Offline

 

#4 2011-12-24 02:21:41 am

olli
Member
Registered: 2008-11-01
Posts: 24

Re: Setting Sound Balance with AppleScript

I have tried the above mentioned script and in Lion at least the slider's range is different.
It is not from -1 to 1 but from 0 to 1, with

0 = only left output
0.5 = centered output
1 = only right output

Hope this helps.


Filed under: preferences, sound, lion

Offline

 

#5 2017-05-05 03:16:44 am

dadi
Member
Registered: 2017-05-03
Posts: 2

Re: Setting Sound Balance with AppleScript

I am trying to use your script but with a different configuration! I need a script that change my audio balance to the right automatically when I plug my headphones and when I unplug it backs to "centrum". it is possible?

StefanK wrote:

Hi,

something like this

Applescript:


tell application "System Preferences"
   activate
   reveal anchor "output" of pane id "com.apple.preference.sound"
end tell
tell application "System Events"
   tell slider 1 of group 1 of tab group 1 of window 1 of process "System Preferences"
       set value to 1.0
       delay 1
       set value to -1.0
       delay 1
       set value to 0
   end tell
end tell

Offline

 

#6 2017-05-05 06:14:13 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4353

Re: Setting Sound Balance with AppleScript

dadi wrote:

I need a script that change my audio balance to the right automatically when I plug my headphones and when I unplug it backs to "centrum".


Hi.

You may not need a script for that. On my machine at least, there are separate settings for headphone and speaker output, although only the currently active one is shown in System Preferences.

Open the Sound pane in System Preferences and click the Output button. If your headphones are plugged in, you should see the settings for them. If not, you should see the settings for the speakers. Set the balance as appropriate, unplug (or plug in) the headphones, wait for the display to change, and set the balance again. You should now have separate balances for headphones and speakers. I haven't tested to see if they survive a restart, but I've no reason to suppose that they won't.

Last edited by Nigel Garvey (2017-05-05 06:16:02 am)


NG

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)