Recommended way to set up a multichannel plugin


#1

I’m in the process of porting an audio app that supports up to 4 inputs and outputs to a VST plugin.

Setting JucePlugin_PreferredChannelConfigurations to {4,4} works in the Plugin Host, but not Ableton. So I think I need to set the extra inputs/outputs as sidechain/aux channels.

I’m currently dealing with a crash when loading the plugin in Ableton but would like to know if the following set up is a good workaround to allow a user to route multiple audio channels into the plugin:

    static BusesProperties getBusesProperties()
    {
        BusesProperties buses;
        buses.addBus (false, "Stereo Output", AudioChannelSet::stereo());
        buses.addBus (false, "Mono Output", AudioChannelSet::mono());
        buses.addBus (false, "Output 1", AudioChannelSet::mono(), false);
        buses.addBus (false, "Output 2", AudioChannelSet::mono(), false);
        buses.addBus (false, "Output 3", AudioChannelSet::mono(), false);
        buses.addBus (false, "Output 4", AudioChannelSet::mono(), false);

        buses.addBus (true, "Stereo Input", AudioChannelSet::stereo());
        buses.addBus (true, "Mono Input", AudioChannelSet::mono());
        buses.addBus (true, "Input 1", AudioChannelSet::mono(), false);
        buses.addBus (true, "Input 2", AudioChannelSet::mono(), false);
        buses.addBus (true, "Input 3", AudioChannelSet::mono(), false);
        buses.addBus (true, "Input 4", AudioChannelSet::mono(), false);

        return buses;
    }

Any recommendations for how to set this up? The most important host to support is Ableton Live at the moment.


#2

The above code would add a total number of 7 (=2+1+1+1+1+1) input and 7 output channels. Is this really what you want?


#3

No, I just want 4 channels, but I want to be able to route more than 2 channels in and out of the plugin in Ableton.


#4

In the above code you are creating 6 buses each with a certain amount of channels. All those channels add up. What you really want is just one input and one output bus with 4 channels each. You would only add more than one bus when you need a sidechain or an aux bus.

In your case, the following would work:

class MyAudioProcessor : public AudioProcessor
{
public:
     MyAudioProcessor () 
         : AudioProcessor (BusesProperties().withInput  ("Input",  AudioChannelSet::discreteChannels (4), true)
                                            .withOutput ("Output", AudioChannelSet::discrete (4), true))
     {}

     .
     .
     .
     bool isBusesLayoutSupported (const BusesLayout& layouts) const override
     {
           auto numIns  = layouts.getMainInputChannels();
           auto numOuts = layouts.getMainOutputChannels();

           // allow any configuration where there are at least 2 channels
           // and the number of inputs equals the number of outputs
           return (numIns >= 2 && numIns == numOuts);
     }
};

The above code assumes that you always want the same number of input and output channels and that the number of channels is between 2 and 4.

You should probably also read through this tutorial:

https://docs.juce.com/master/tutorial_audio_bus_layouts.html


#5

Thanks Fabian I wasn’t aware of that tutorial, I was looking in the forum for info.


#6

OK so this is kind of working, however when attempting to route audio in from another track, the channels are only available in stereo pairs. I guess this is because Ableton does not support mono audio tracks, so any audio routed from a given channel will always be in stereo. So I guess (at least in Ableton) I’ll need to expect 8 input channels and then reduce them to 4 mono channels within the plugin.

UPDATE: That worked :sunglasses:

The AU plugin fails to load with this configuration:


#7

For future reference and for anyone else who might be looking, I figured out what I needed for a 4 mono channel in/out setup:

        : AudioProcessor (BusesProperties().withInput  ("Mono In 1",  AudioChannelSet::mono(), true)
                                           .withInput  ("Mono In 2",  AudioChannelSet::mono(), true)
                                           .withInput  ("Mono In 3",  AudioChannelSet::mono(), true)
                                           .withInput  ("Mono In 4",  AudioChannelSet::mono(), true)
                                           .withOutput ("Mono Out 1", AudioChannelSet::mono(), true)
                                           .withOutput ("Mono Out 2", AudioChannelSet::mono(), true)
                                           .withOutput ("Mono Out 3", AudioChannelSet::mono(), true)
                                           .withOutput ("Mono Out 4", AudioChannelSet::mono(), true))

This also works for the AudioUnit version!