Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Set incredibly precise volume levels using AppleScript System
Mac OS X's default volume control hot keys change the volume in huge steps, but you can use Shift-Option and the Volume Up or Down keys for quarter-step changes (see this hint).

Still not fine enough for you? AppleScript to the rescue, once again. Though it has some oddities, AppleScript can be used to set the volume based on an entered number.

Here's the first quirk: the number of squares filled in on the HUD will be twice the number you typed in. So, typing set volume 1 sets the volume to level two. (There are 16 squares total, so you can enter a number from 1 to 8). You can use decimals to set the volume by individual square, too: set volume .5 fills in one square. You can, amazingly, extend this functionality to even greater levels of precision.

Want to set the volume to three and one-fifth squares (i.e. 3.2)? Type set volume 1.6 and click Run. The number is doubled, and the volume is set. Two and one one-hundredth squares (2.01)? Type set volume 1.005. You can get as precise as you want, as you can see.

I wrote a script to first cut the entered number in half, then set the volume based on that value. Here it is:
display dialog 
  "Enter number." with title 
  "Number Of Squares?" buttons {"Set"} 
  default button 1 default answer ""
set numberSquares to text returned of result
set numberHalved to numberSquares / 2
set volume numberHalved
[robg adds: This worked as described in 10.5 and 10.6.]
    •    
  • Currently 2.71 / 5
  You rated: 2 / 5 (17 votes cast)
 
[16,500 views]  

Set incredibly precise volume levels using AppleScript | 9 comments | Create New Account
Click here to return to the 'Set incredibly precise volume levels using AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Set incredibly precise volume levels using AppleScript
Authored by: Andrew J Freyer on Mar 02, '10 08:09:02AM
I believe that this hint is ignoring the fact that applescript ultimately recasts the float to an integer from 1-100.

It is misleading to say that "you can set the volume as precise as you want" because there are only 100 volume levels. A quick verification shows this:


display dialog 
	"Enter number." with title 
	"Number Of Squares?" buttons {"Set"} 
	default button 1 default answer ""
set numberSquares to text returned of result
set numberHalved to numberSquares / 2
set volume numberHalved

output volume of (get volume settings)

The output of the above "output volume" line shows that no matter how "precise" you think you're setting the volume, the computer is rounding to the nearest step of 100 (i.e. the maximum precision of the 0-8 volume setting method above is 0.08.)

The best way to set volume to the highest precision level is:


set volume output volume 7.5

output volume of (get volume settings)

Notice that the output volume here is rounded to 8.

Edited on Mar 02, '10 08:13:09AM by Andrew J Freyer


[ Reply to This | # ]
Set incredibly precise volume levels using AppleScript
Authored by: Andrew J Freyer on Mar 02, '10 08:15:20AM

I might also note that holding COMMAND + SHIFT while adjusting the volume will allow more delicate volume control.



[ Reply to This | # ]
Not Command - Shift
Authored by: DCJ001 on Mar 02, '10 10:36:54AM

Actually, depressing Option - Shift while increasing or decreasing the volume makes changes in 1/3 increments.



[ Reply to This | # ]
Not Command - Shift
Authored by: jiclark on Mar 02, '10 10:42:36AM

Which is mentioned in the hint!



[ Reply to This | # ]
Not Command - Shift
Authored by: mkhaw on Mar 02, '10 11:00:04AM

On my Snow Leopard MBP, I get 1/4 steps with option+shift for a total of 64 steps across the entire scale.

shift (with or w/o cmd) instead changes the volume silently (i.e., without audio feeback).

option alone brings up the Sound prefpane.



[ Reply to This | # ]
Not Command - Shift
Authored by: Andrew J Freyer on Mar 02, '10 12:56:09PM

oops - haha, typing too quickly is always a risk these days.



[ Reply to This | # ]
1/4 not 1/3
Authored by: DCJ001 on Mar 02, '10 02:21:38PM

I forgot that Option-Shift gives 1/4 increment changes in volume, not 1/3 as I said in my previous post.



[ Reply to This | # ]
Set incredibly precise volume levels using AppleScript
Authored by: david-bo on Mar 03, '10 07:02:50AM

A quick test on the command line since I am not at home.

To get the volume in iTunes (which support 100 levels)

% osascript -e 'tell application "iTunes" to set A to sound volume'

57

To set the volume in iTunes

% osascript -e 'tell application "iTunes" to set sound volume to 1'


I would be surprised if you couldn't call System Events or similar to set the volume level with the same accuracy but I can't test that right now. Someone else?



[ Reply to This | # ]
Set incredibly precise volume levels using AppleScript
Authored by: pendragon on Mar 05, '10 06:06:07AM

The Option+Shift technique also works with Brightness (at least in 10.6.2, 24" C2D Intel iMac)



[ Reply to This | # ]