changing system audio device from max

kon-kon's icon
roger.carruthers's icon

I asked this question recently too, and I'm still
hoping for an answer; it would be useful to be able to
do this when outputting via speech objects,
cheers
Roger

f's icon

if you're on osx you can do this with applescript. but it'll be pretty
slow switching and you'll need to check the 'enable access for
assistive devices' in systemprefs/universal access for it to work.
probably possible to also do this with the terminal command defaults
write com.apple.sound... or something similar but i haven't tried that.
example scripts below.

>> shell object? what command?

--save as outputDeviceInternal.scpt in home dir (make different scripts
for each device and just change the first line)

set outputDevice to "Internal speakers"
tell application "System Preferences"
    activate
    set current pane to pane "com.apple.preference.sound"
    tell application "System Events"
        tell process "System Preferences"
            tell tab group 1 in window "sound"
                click radio button "Output"
                repeat with r in every row of table 1 of scroll area 1
                    if (value of text field 1 of r) is equal to outputDevice then
                        select r
                    end if
                end repeat
            end tell
        end tell
    end tell
end tell

Max Patch
Copy patch and select New From Clipboard in Max.

#|
fredrikolofsson.com klippav.org musicalfieldsforever.com
|#