# How can I implement ceiling and threshold parameter in a limiter?

ive been working in a Compressor/Limiter vst, but in the limiter state i cant make it works properly, i want it to work like de Ozone Maximizer, as low the threshold is as higher the gain increase, it does not matter if its compressing the signal or not (for sure if the input signal reach the Threshold level is gonna be compressed), and the ceiling like the limiter value, but i cant figure out how to make it works.

xn = abs(Sample);
if (CompLim) {
xn *= juce::Decibels::decibelsToGain(Ceiling) / juce::Decibels::decibelsToGain(Treshold);
xg = 0;
if (xn < 0.001) {
xg = -120;
}
else {
xg = 20 * log10(xn);
}
yg = 0;
if (xg > Treshold) {
yg = Treshold;
}
else {
yg = xg;
}
xl = xg - yg;

``````    yl = 0;
if (xl > yn_1) {
yl = (Alpha_Attack * yn_1) + ((1 - Alpha_Attack) * xl);
}
else {
yl = (Alpha_Release * yn_1) + ((1 - Alpha_Release) * xl);
}
``````

this is the actual code

i’d like to point you to this video i made in which i made a downwards expander but also discussed dynamics processing in general.

that being said what you probably need is something between a downwards compressor (making loud things quiet) and an upwards compressor (making quiet things loud)