From 3d338bda385493ba70721086fc7e8b18ed6b3a8a Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Tue, 15 Jul 2025 21:06:40 +0200 Subject: [PATCH] get rid of the lookahead --- filter/bs412.c | 6 +----- filter/bs412.h | 5 ----- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/filter/bs412.c b/filter/bs412.c index deaccdc..856e21a 100644 --- a/filter/bs412.c +++ b/filter/bs412.c @@ -29,11 +29,7 @@ void init_bs412(BS412Compressor* mpx, float mpx_deviation, float target_power, f } float bs412_compress(BS412Compressor* mpx, float sample) { - if(mpx->lookahead_counter >= BS412_LOOKAHEAD) mpx->lookahead_counter = 0; - float process_sample = mpx->lookahead_samples[mpx->lookahead_counter]; - mpx->lookahead_samples[mpx->lookahead_counter++] = sample; - - mpx->average += process_sample * process_sample * mpx->mpx_deviation * mpx->mpx_deviation; + mpx->average += sample * sample * mpx->mpx_deviation * mpx->mpx_deviation; mpx->average_counter++; float avg_power = mpx->average / mpx->average_counter; diff --git a/filter/bs412.h b/filter/bs412.h index 7d7437a..07bf132 100644 --- a/filter/bs412.h +++ b/filter/bs412.h @@ -10,8 +10,6 @@ #include "../lib/debug.h" #endif -#define BS412_LOOKAHEAD 2048 // samples - typedef struct { int mpx_deviation; @@ -23,9 +21,6 @@ typedef struct float max; float gain; double average; - - float lookahead_samples[BS412_LOOKAHEAD + 1]; - int lookahead_counter; } BS412Compressor; float dbr_to_deviation(float dbr);