Select Live audio output device through Max for live API

Frans-Jan Wind's icon

Dear list,

I've made a standalone max application for Mac which runs with Ableton Live in the background. When a user plugs in Headphone I want to change the selected audio output device to the headphone. If any of you kno how to change this through the max for live API I love to know. My current solution is using Blackhole virtual audio device to port the main audio Live audio to the standalone application where I can change output device through [adstatus option]. But when the lid of the macbook is closed, lives forgets the Blackhole virtual audio device and Live will give the "audio engine is off" message, which renders this solution worthless. Any thoughts are more than welcome to change the selected audio device within Ableton live from Max for Live.

Best, Frans-Jan