Setting iTunes EQ and Volume with AppleScript
A correspodent sent us some scripts to control iTunes' EQ and volume settings on the fly. As I was getting them ready to post I thought it might be even better to explain how easy it is to script your own EQ and volume setting effects. [dec 17 '01]
EQ on the fly
One of the scripts sent by our correspondent is called "Bass Boost". It simply changes the EQ setting of the iTunes player to the EQ preset called "Bass Booster":
tell application "iTunes" set the current EQ preset to EQ preset "Bass Booster" end tell [upm] click to open in Script Editor
This does not change the EQ setting of the actual track, just the current EQ preset, like it says. It's the same as changing the EQ preset yourself from the EQ window—except 1) you didn't have to open the EQ window, 2) you didn't have to click on the EQ presets pop-up, 3) click on a preset, and 4) close the EQ window. Compile and save that in your iTunes's Scripts Folder as "Bass Boost" and you have instant boom.
Next, instead of "Bass Booster" as the EQ preset, use "Treble Booster". Do you see where I'm going with this? Create a few of these things using your most preferred EQ presets. Just make sure you use an EQ preset <name> that really exists.
Here's how you can use the preset named "Flat" to "normalize" the current EQ:
tell application "iTunes" set the current EQ preset to EQ preset "Flat" end tell [upm] click to open in Script Editor
You can also return to your last set of EQ tweaks with EQ preset "Manual".
How about setting the EQ according to the current track's genre?
tell application "iTunes" if the current track's genre is "Rock" then set the current EQ preset to EQ preset "Rock" end if end tell [upm] click to open in Script Editor
has had a similar script in their collection called "Set Genre to Specific EQ".) You could also look at the current track's album or artist or any other track property as a deciding factor.
Pump up (or down) the volume
The current volume can be changed with the sound volume property, which emulates iTunes' main volume slider. (There are two other volume-related properties, too. One is "volume adjustment", a track property, and the other is "preamp", which is a property of EQ window. We are not concerned with either of those two properties here, however.)
The sound volume property accepts a value between 0 (no volume) and 100 (all the volume there is).
tell application "iTunes" set the sound volume to 40 end tell [upm] click to open in Script Editor
When you change the sound volume, first of all you'll hear the difference, and you'll also see the change reflected in iTunes' main volume slider.
Since the value of sound volume is a number, you can perform math operations with it. Here's a quick script that drops the volume a little:
tell application "iTunes" if the sound volume is greater than 25 then set sound volume to (sound volume - 25) else set sound volume to 0 end if end tell [upm] click to open in Script Editor
Note that if you want to shut off the sound completely, you can also just set mute to false. This has no effect on the sound volume setting.
Thanks to Wally Rodriguez for the Good Ideas.