I’m sure this is probably simple but I can’t figure out the the correct use of canAddBus()
, canRemoveBus()
, isBusesLayoutSupported()
etc etc.
Ideally, I want my synth to be either 1xStereo, or 8xStereo and that’s all. Of course all hosts will support my 1xStereo layout but not necessarily the 8xStereo. Logic seems to insist on 16xStereo as the next layout above 1xStereo. I’m fine with that as long as I have at least 8, I can just silence the unused ones (or otherwise only offer 1xStereo).
Thus far I’ve been playing with the MultiOutSynth example and so far I’ve got this:
...
MultiOutSynth()
: AudioProcessor (BusesProperties()
.withOutput ("Output #1", AudioChannelSet::stereo(), true)
.withOutput ("Output #2", AudioChannelSet::stereo(), false)
.withOutput ("Output #3", AudioChannelSet::stereo(), false)
.withOutput ("Output #4", AudioChannelSet::stereo(), false)
.withOutput ("Output #5", AudioChannelSet::stereo(), false)
.withOutput ("Output #6", AudioChannelSet::stereo(), false)
.withOutput ("Output #7", AudioChannelSet::stereo(), false)
.withOutput ("Output #8", AudioChannelSet::stereo(), false)
.withOutput ("Output #9", AudioChannelSet::stereo(), false)
.withOutput ("Output #10", AudioChannelSet::stereo(), false)
.withOutput ("Output #11", AudioChannelSet::stereo(), false)
.withOutput ("Output #12", AudioChannelSet::stereo(), false)
.withOutput ("Output #13", AudioChannelSet::stereo(), false)
.withOutput ("Output #14", AudioChannelSet::stereo(), false)
.withOutput ("Output #15", AudioChannelSet::stereo(), false)
.withOutput ("Output #16", AudioChannelSet::stereo(), false))
{
// initialize other stuff (not related to buses)
...
}
~MultiOutSynth() {}
//==============================================================================
bool canAddBus (bool isInput) const override { return (! isInput && getBusCount (false) < 16); }
bool canRemoveBus (bool isInput) const override { return (! isInput && getBusCount (false) > 1); }
bool isBusesLayoutSupported (const BusesLayout& layouts) const override
{
if (layouts.inputBuses.size() > 0)
return false;
int numStereoBuses = 0;
for (auto channelSet : layouts.outputBuses)
{
if (channelSet != AudioChannelSet::stereo())
return false;
else
++numStereoBuses;
}
return (numStereoBuses == 1) || (numStereoBuses >= 8);
}
...
I wonder if I’m going down the right path here?
Or for this specifc requirement do I need to override canApplyBusCountChange()
? Especially if I start with a deafult layout of < 16 (as I hit this case an inder-out-of-bounds assertion in Array::getReference()
when the AU wrapper is calling syncAudioUnitWithChannelSet()
).