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

**URL:** <https://forum.juce.com/t/how-can-i-implement-ceiling-and-threshold-parameter-in-a-limiter/58558>\
**Category:** General JUCE discussion\
**Created:** [October 30, 2023, 12:14am UTC](https://forum.juce.com/t/how-can-i-implement-ceiling-and-threshold-parameter-in-a-limiter/58558 "2023-10-30T00:14:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JoseAlcaraz27](https://avatars.discourse-cdn.com/v4/letter/j/3be4f8/32.png) [@JoseAlcaraz27](https://forum.juce.com/u/JoseAlcaraz27)\
**Post date:** [October 30, 2023, 12:14am UTC](https://forum.juce.com/t/how-can-i-implement-ceiling-and-threshold-parameter-in-a-limiter/58558/1 "2023-10-30T00:14:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Mrugalla](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/mrugalla/32/13092_2.png) [@Mrugalla](https://forum.juce.com/u/Mrugalla)\
**Post date:** [October 30, 2023, 2:17pm UTC](https://forum.juce.com/t/how-can-i-implement-ceiling-and-threshold-parameter-in-a-limiter/58558/2 "2023-10-30T14:17:06Z")

</div>

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.

[![](https://us1.discourse-cdn.com/flex026/uploads/juce/original/3X/4/7/47be0aad669dbb057ff819068e71961744baea25.jpeg "Let's Code A Dynamics Processor (Downwards Expander)") ](https://www.youtube.com/watch?v=yv-1LxhfMuM)

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)
