Controlling audio output's sample/bit rate on OSX from command prompt Is there a way to limit the output format of a soundcard on OSX, apart from Audio MIDI Setup? I have noticed that OSX has a bad habit of resampling audio while it is not needed at all (say the output from Spotify or Tidal). I would like to systematically prevent such a thing from happenning, while still having a choice on the output format. The solution can use shell or Apple script, so that I can run it with a shortcut.
Here is an AppleScript that fixes the default audio format of the default output card before launching Spotify (tested on El Capitan only), but I prefer very much a solution that does not depend on GUI:

set desiredRate to "44100.0 Hz"
set desiredDepth to "2ch-16bit Integer"

tell application "Audio MIDI Setup" to activate
tell application "System Events"
    tell application process "Audio MIDI Setup"
        if not (window "Audio Devices" exists) then
            click menu item "Show Audio Devices" of menu "Window" of menu bar item "Window" of menu bar 1
        end if
        tell group 1 of tab group 1 of group 1 of splitter group 1 of window "Audio Devices"
            click button 1 of combo box 1
            select (text field 1 of list 1 of scroll area 1 of combo box 1 whose value is desiredRate)
            keystroke return
            click pop up button 2
            click menu item desiredDepth of menu 1 of pop up button 2
        end tell
    end tell
end tell
tell application "Audio MIDI Setup" to quit
tell application "Spotify" to activate