Multichannel Audiounits


Hi, I am building a multichannel instrument plugin that requires 0 inputs and 16 outputs. On OS X the plugin needs to be an Audiounit. Some hosts like Logic do not see the multiple output configuration and the plugin shows up in the list only when I assign 1 or 2 outputs {0,1} and/or {0,2}. Auval emits a warning about missing the channel layout for the multiple outputs configuration.

I searched the forum for previous similar problems, there are others also that had the similar problem in the past. The demo plugin also does not show up on Logic's list when I change it's configuration to use multiple outputs. Has anyone any working Audiounit instrument or generator that work with multiple outputs? Are mupltiple output Audiounits supposed to work and I am missing something? I use xcode 5 and the latest coreaudio files from aple. (The company I work for is on commercial support, if that makes any difference.)


I am not near a computer with JUCE so I am not sure what it supports, but in AU syntax I THINK 0,16 should be 'zero-in-16-out' and 0,-16 'should be zero-in-up-to-16-out'.  Not sure if that will help or not, but I checked and apple's sampler AU is similar, so you can see what it is doing with 'auval -64 -v aumu samp appl' in the terminal and it is an 'aumu' instrument with 0,-16 channel listing.



Thank you for your reply. I have tried your suggestion with the plugin I write here, as well as with a new audio plugin using the latest JUCE tip, and when I set {0,-16} the plugin crashes the host. Besides, I need a fixed number of 16 channels. From my limited understanding of CoreAudio I need to fill an AudioChannelLayout structure with the values that say to Logic and similar hosts; "here, these 16 outputs are 16 mono outputs".. But what to exactly to fill and how to call I have no idea.

The plugin works fine with hosts such as Reaper, the auval tests are run with no errors and this warning.

WARNING: Source AU supports multi-channel output but does not provide a channel layout.

It was the same error someone else stumbled upon which leads to here but the code example are for very old JUCE version and the example is about multiple buses, which are not needed for my case.


Gotcha.  It doesn't seem to be workable without modifying some JUCE files, which seems to be what was done in the threads you linked.
As for the AudioChannelInfo structure, this has worked for me is this (this example is for mono-mono that I pulled from a working project, it is an Effect, not a generator, but just to show working code):

#include "CAAudioChannelLayout.h"

//In the'public:' section of the effectbase class:
virtual UInt32 SupportedNumChannels(const AUChannelInfo** outInfo);

// In the source
MyProjectAU::MyProjectAU(AudioUnit component) : AUEffectBase(component)
    CreateElements ();
    CAStreamBasicDescription streamDesc;
    streamDesc.SetCanonical(1, false); // sets to one channel only
    streamDesc.mSampleRate = GetSampleRate();

UInt32 MyProjectAU::SupportedNumChannels (const AUChannelInfo** outInfo)
    static const AUChannelInfo sChannels[1] = {{1,1}}; // array for explicit mono-mono
    if (outInfo) *outInfo = sChannels;
    return sizeof (sChannels) / sizeof (AUChannelInfo);

But that is an effect, not a generator and that doesn't really help, so to check I also hacked one of the Apple example generator AUs into working using similar code to see if it would work.  For you in the case of a multi-channel NxM 16-ch audiounit,  change that to something like this:

YourProjectAU::YourProjectAU(AudioUnit component) : AUEffectBase(component)
    CreateElements ();
    CAStreamBasicDescription streamOut;
    streamOut.SetCanonical(16, false);    // number of output channels
    streamOut.mSampleRate = 44100; // I explicitly set the samplerate, but you could fetch it

UInt32 YourProjectAU::SupportedNumChannels (const AUChannelInfo** outInfo)
    static const AUChannelInfo numChannels[1] = {{0, 16}}; // zero-in, exactly 16-out
    if (outInfo) *outInfo = numChannels;
    return sizeof (numChannels) / sizeof (AUChannelInfo);

It DID work just fine, but I also had to override the initialize(); function to define the number of outputs by fetching the output and return no error on 16 channels get it to behave in  (something like 'SInt16 auNumOfOutputs = (SInt16) GetOutput(0)->GetStreamFormat().mChannelsPerFrame;'), and then cycled through the outputBufList with a loop in the render function, so I am hopeful it would work in JUCE if the library files were modified a bit, like in the second thread you linked.

As for the error "WARNING: Source AU supports multi-channel output but does not provide a channel layout", I got that too, but it did not seem to have any effect on the plugin loading and functioning.  Apple only had layouts defined up to 8 channels under kAudioChannelLayout, so (i THINK) you can ignore it since the plugin I rolled loaded up in JUCE's host app just fine and presented all 16 outputs, but I suppost if the host does a check for the kAudioChannelLayout specifically, it can choosse to not load the plugin, but I have absolutely no idea if that is a common thing to do OR if you can define a custom layout tag as a workaround if it is an issue.   (I did find one layout that is 16-channel "kAudioChannelLayoutTag_TMH_10_2_std" but I have no idea what that is for.)

Hope that helps.