From a5149126c07430c2f03bd86507a82a8e7611b18a Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Tue, 30 Dec 2025 21:14:08 +0100 Subject: [PATCH] set target to -100 to disable it --- filter/bs412.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/filter/bs412.c b/filter/bs412.c index 1196631..b59f18c 100644 --- a/filter/bs412.c +++ b/filter/bs412.c @@ -41,12 +41,6 @@ float bs412_compress(BS412Compressor* mpx, float sample) { float avg_deviation = sqrtf(avg_power) * sqrtf(2); float modulation_power = deviation_to_dbr(avg_deviation); - #ifdef BS412_DEBUG - if(mpx->average_counter % mpx->sample_rate == 0) { - debug_printf("MPX power: %.2f dBr with gain %.2fx (%.2f dBr)\n", modulation_power, mpx->gain, deviation_to_dbr(avg_deviation * mpx->gain)); - } - #endif - if (mpx->average_counter >= mpx->sample_rate * 60) { #ifdef BS412_DEBUG debug_printf("Resetting MPX power measurement\n"); @@ -55,6 +49,21 @@ float bs412_compress(BS412Compressor* mpx, float sample) { mpx->average_counter = 1; } + if(mpx->target <= -100.0f) { + #ifdef BS412_DEBUG + if(mpx->average_counter % mpx->sample_rate == 0) { + debug_printf("MPX power: %.2f dBr (%.1f Hz)\n", modulation_power, avg_deviation); + } + #endif + return sample; + } + + #ifdef BS412_DEBUG + if(mpx->average_counter % mpx->sample_rate == 0) { + debug_printf("MPX power: %.2f dBr with gain %.2fx (%.2f dBr)\n", modulation_power, mpx->gain, deviation_to_dbr(avg_deviation * mpx->gain)); + } + #endif + float target_gain = powf(10.0f, (mpx->target - modulation_power) / 10.0f); if (modulation_power > mpx->target) { mpx->gain = mpx->attack * mpx->gain + (1.0f - mpx->attack) * target_gain;