From 668dfea9f28a38b1de3a09113b5749add6de7033 Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Thu, 10 Jul 2025 20:11:52 +0200 Subject: [PATCH] make bs412 a dynamic compressor (boosts, and attunuates instead of just attenuating dynamically) --- filter/bs412.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/filter/bs412.c b/filter/bs412.c index 5e44faf..4ecbe73 100644 --- a/filter/bs412.c +++ b/filter/bs412.c @@ -48,12 +48,11 @@ float bs412_compress(BS412Compressor* mpx, float sample) { mpx->average_counter = 1; } + float target_gain = mpx->target / modulation_power; if (modulation_power > mpx->target) { - float target_gain = mpx->target / modulation_power; - 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; + mpx->gain = mpx->release * mpx->gain + (1.0f - mpx->release) * target_gain; } mpx->gain = fminf(mpx->max, mpx->gain);