Hi, I want to allow any number of inputs and outputs, and use what’s available.
Is this the right way or am I supposed to suggest a layout and see if the host can use it?
When do I allocate resources for the number of inputs?
I don’t want to do it in ‘isBusesLayoutSupported’ because it just sets a flag, and it’s called many many times at start up.
Do I just do it all in ‘prepareToPlay’ and check for changes?
OK I’ve got this far, I’ve used a static BusesProperties getDefaultLayout() as mentioned here:
But I still need to allocate buffers for each input channel, where is the best place for that?
I need the user to have a choice between mono, stereo, and quadraphonic.
Is the best strategy to say I need the maximum channels at the instantiation of AudioProcessor and then
use what I need in processing through user choices?
I ask because I just noticed I can have 4 channels on a stereo track in FL Studio. All the memory seems valid, so I guess Juce allocates memory despite what the DAW has available?
The layout passed to the AudioProcessor constructor is just a hint for the default layout. Hosts may or may not take that into account.
Usually, you’d specify the layouts that are valid using isBusesLayoutSupported. In prepareToPlay you can query the current bus layout, and find out how many channels the host intends to provide. At that point, you can allocate whatever resources you need in order to process that many channels.
During processing, you should never read or write past max (getTotalNumInputChannels(), getTotalNumOutputChannels()). If you read past getTotalNumInputChannels(), the results are unspecified, so this is a bad idea. If you write past getTotalNumOutputChannels(), the extra channels will be discarded.
During processing, you should never read or write past max (getTotalNumInputChannels(), getTotalNumOutputChannels()) . If you read past getTotalNumInputChannels() , the results are unspecified, so this is a bad idea. If you write past getTotalNumOutputChannels() , the extra channels will be discarded.
Yes of course, that’s what I’m doing. Here’s what I’m getting back using:
getTotalNumOutputChannels returns 4.
But if I set it to just quadraphonic then I get just 2 back!
This is very confusing. Why would it do that? I guess it’s a quirk of FL Studio as Ableton Live reports 4 for quad.
I’m happy I can work with this just fine. Thanks for the replies.
@DaveH I worked on a plugin years ago where we needed the user to make a selection too, in our case it was just for mono/stereo inputs. Due to the way some DAWs worked we ended up finding that the best way to manage it without fighting against some of the DAWs was to have separate plugins for each choice. In our case it was just a mono/stereo selection but keep in mind that even in that simple case 2 channels does not mean stereo. A source can be mono but presented in stereo, either because the actual source material happens to have the same input on the left / right channels, or because the DAW prefers to work that way (Reaper from memory always works with stereo).
I was afraid I might have to do different versions, the same thing happened back in 2005 with the original vst. I needed a 5.1 version as well as stereo. I don’t want to do that again.
It was odd that FLstudio would return 4 if I set 2 and 4 outputs, but only 2 if I set just 4. But everything is on a stereo channel in FLstudio.
I’m thinking about just leaving it and allowing different instances of the plug-in using InterprocessCommunication to allow parameters to pass between them.
Where each instant represents a new input.