Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I programmatically create a multi-output device in OS X?

How can I programmatically create a Multi-Output Device in Mac OS X?

The Audio Midi Setup program provides a GUI interface for creating one, but I would like to be able to create one in code.

I've found some resources already for creating aggregate devices, but multi-output devices function differently and I can't find anything on creating them. Here's what I've got so far:

  • How to combine multiple audio interfaces by creating an aggregate device
  • Using Aggregate Devices
  • Creating Core Audio aggregate devices programmatically
  • What is the difference between an “aggregate” and a “multi-output” device?
like image 528
Justin Poliey Avatar asked Feb 17 '16 23:02

Justin Poliey


1 Answers

I had the same need to create a Multi Output Device programmatically. This example: http://daveaddey.com/?p=51 covers the needs.

I managed to do it by studying /Library/Preferences/Audio/com.apple.audio.SystemSettings.plist. This is the place where the Audio MIDI Setup saves the configuration (on my box, El Capitan).

Create a Multi-Output Device and an Aggregate Device and study the plist. They're pretty much the same, except the fact that the Aggregate Device has a master device, while the MOD does not.

Considering the example from Dave Addey: I for one, managed to create the MOD by removing the master device and adding my own devices as outputs. (in my case, Soundflower and the Default Output)

Besides this, add the "stacked" boolean key to the CF Dictionary. According to the CoreAudio sources, this key ensures that the same output is sent to all output channels, as opposed to the Aggregate Device which is not stacked, and combines multiple devices to make itself 'look' as a single device with a lot of channels.

Hope this helps.

like image 192
Andrei B. Avatar answered Sep 27 '22 22:09

Andrei B.