Multiband compressor parameters

Hi, i’m creating a multiband compressor but i’m not sure about how should i handle the parameters.

This simple multiband comp works like this: i split the input signal in 3 bands and for each one i apply compression.

// splitSignal() splits signal into 3 bands.
// firstBandBuffer will contain the first band data and so on
bandSplitter.splitSignal(mainBuffer, firstBandBuffer, secondBandBuffer, thirdBandBuffer);

// instances of the same compressor class process the 3 bands separately
b1Comp.processBlock(firstBandBuffer, scBuffer);
b2Comp.processBlock(secondBandBuffer, scBuffer);
b3Comp.processBlock(thirdBandBuffer, scBuffer);

I have a PluginParameters.h where i add all my parameters to the layout.
Every compressor instance i use has his own attack time, release time, threshold, ratio, etc.

How should i manage this with the parameters?
Should i explicitly add the parameters like this?

static AudioProcessorValueTreeState::ParameterLayout createParameterLayout()
	{
		std::vector<std::unique_ptr<RangedAudioParameter>> params;

		// band 1 compressor
		params.push_back(std::make_unique<AudioParameterFloat>(nameAttackTime_band1, "Band 1 Attack Time (ms)", NormalisableRange<float>(0.05f, 250.0f, 0.01f, 0.35f), 0.05f));
                params.push_back(std::make_unique<AudioParameterFloat>(nameAttackTime_band2, "Band 2 Attack Time (ms)", NormalisableRange<float>(0.05f, 250.0f, 0.01f, 0.35f), 0.05f));
                params.push_back(std::make_unique<AudioParameterFloat>(nameAttackTime_band3, "Band 3 Attack Time (ms)", NormalisableRange<float>(0.05f, 250.0f, 0.01f, 0.35f), 0.05f));

		return { params.begin(), params.end() };
	}

and so on with all the parameters?
I mean, sure i can do a for loop to clean up the code but still idk if it’s really the right way to do it.
My multiband compressor has 3 bands but what if i wanna make something like the FabFilter Pro-MB where i can add bands dynamically? (I think it’s up to 6 bands but the point is making that number dynamic)
Hope you understood what i mean :slight_smile:
Thank you for the attention!

First thing, the right way to add parameters to APVTS is like this:

APVTS::ParameterLayout createParameterLayout()
{
    APVTS::ParameterLayout layout;
    
    layout.add(std::make_unique<AudioParameterFloat>(nameAttackTime_band1, "Band 1 Attack Time (ms)", NormalisableRange<float>(0.05f, 250.0f, 0.01f, 0.35f), 0.05f));

	...
	
	return layout;	
}

Second, you can’t dynamically add parameters after this method is called. The number of parameters and their IDs that your plugin is using must be known to the host when the plugin is loaded. Setting up a loop to clean the code is fine, but also keeping it explicit as in your case is also perfectly acceptable, since when the time comes to connect these parameters to GUI components you might want to deal with the parameter’s name and not its index.

1 Like

Thank you! Now it’s all clear in my mind! I also didn’t know about that .add() method, so thank you! I was taught this way of adding parameters to the layout, so I’ve always used this, but it’s clearly not the right way…