Is there a way to automatically adjust EQ settings when the audio output changes? I have particular EQ settings I like to use for my speakers at home, however when I'm using my laptop speakers or Bluetooth headphones I prefer to have a flat EQ.  Is there a way to specify different EQ settings for each audio output and automatically switch to the correct setting when the audio output is changed?
Reading the current audio output gives "Built-in Output" for both headphones and internal speakers, however we need to be able to tell between headphones and speakers.  In order to do this, you can use code from this answer to create a program that checks whether headphones are plugged in or another audio output is in use:

#include &lt;CoreAudio/CoreAudio.h&gt;
#include &lt;iostream&gt;

void updateEQ() {
    AudioDeviceID defaultDevice = 0;
    UInt32 defaultSize = sizeof(AudioDeviceID);

    const AudioObjectPropertyAddress defaultAddr = {
        kAudioHardwarePropertyDefaultOutputDevice,
        kAudioObjectPropertyScopeGlobal,
        kAudioObjectPropertyElementMaster
    };

    AudioObjectGetPropertyData(kAudioObjectSystemObject, &amp;defaultAddr, 0, NULL, &amp;defaultSize, &amp;defaultDevice);

    AudioObjectPropertyAddress property;
    property.mSelector = kAudioDevicePropertyDataSource;
    property.mScope = kAudioDevicePropertyScopeOutput;
    property.mElement = kAudioObjectPropertyElementMaster;

    UInt32 dataSourceId = 0;
    UInt32 dataSourceIdSize = sizeof(UInt32);

    AudioObjectGetPropertyData(defaultDevice, &amp;property, 0, NULL, &amp;dataSourceIdSize, &amp;dataSourceId);

    if (dataSourceId == 'hdpn') {
        std::cout &lt;&lt; "Changed to headphones" &lt;&lt; std::endl;
        system("osascript &lt;&lt;path to speaker EQ script&gt;&gt;");
    } else {
        std::cout &lt;&lt; "Changed to not headphones" &lt;&lt; std::endl;
        system("osascript &lt;&lt;path to other EQ script&gt;&gt;");
    }
}


int main(int argc, const char * argv[])
{
    updateEQ();
    return 0;
}


Each EQ script is then a simple AppleScript script that updates iTunes's EQ, for example the speaker EQ script is:

tell application "iTunes"
    set current EQ preset to (get first EQ preset whose name is "Speakers")
    set EQ enabled to true
end tell