diff --git a/filter/bs412.c b/filter/bs412.c index 23e33d1..6a699a8 100644 --- a/filter/bs412.c +++ b/filter/bs412.c @@ -48,11 +48,11 @@ float bs412_compress(BS412Compressor* mpx, float sample) { mpx->average_counter = 1; } - float target_gain = mpx->target / modulation_power; + float target_gain = mpx->target / (modulation_power + 1e-9f); if (modulation_power > mpx->target) { mpx->gain = mpx->attack * mpx->gain + (1.0f - mpx->attack) * target_gain; } else { - mpx->gain = mpx->release * mpx->gain + (1.0f - mpx->release) * (1.0f/target_gain); + mpx->gain = mpx->release * mpx->gain + (1.0f - mpx->release) * target_gain; } mpx->gain = fminf(mpx->max, mpx->gain);