From 5b021da373078b6051ea42219d358562d2817052 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sat, 20 Aug 2022 16:53:33 +0200 Subject: [PATCH] Don't apply output gain to unfiltered DC bins --- plugins/spectral_compressor/src/lib.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/spectral_compressor/src/lib.rs b/plugins/spectral_compressor/src/lib.rs index 4f2d2009..4fe17b4b 100644 --- a/plugins/spectral_compressor/src/lib.rs +++ b/plugins/spectral_compressor/src/lib.rs @@ -110,7 +110,9 @@ pub struct GlobalParams { #[id = "dry_wet"] pub dry_wet_ratio: FloatParam, /// Sets the 0-20 Hz bin to 0 since this won't have a lot of semantic meaning anymore after this - /// plugin and it will thus just eat up headroom. + /// plugin and it will thus just eat up headroom. If this option is disabled then the DC bins + /// will be gained by the reverse of the output gain to prevent them from getting louder as you + /// crank the output gain as makeup gain. #[id = "dc_filter"] pub dc_filter: BoolParam, @@ -526,10 +528,15 @@ fn process_stft_main( first_non_dc_bin_idx, ); - // The DC and other low frequency bins doesn't contain much semantic meaning anymore - // after all of this, so it only ends up consuming headroom. + // The DC and other low frequency bins doesn't contain much semantic meaning anymore after all + // of this, so it only ends up consuming headroom. Otherwise they're gained down by the output + // gain to prevent makeup gain from making these bins too loud. if params.global.dc_filter.value { complex_fft_buffer[..first_non_dc_bin_idx].fill(Complex32::default()); + } else { + for bin in complex_fft_buffer[..first_non_dc_bin_idx].iter_mut() { + *bin *= -output_gain; + } } // Inverse FFT back into the scratch buffer. This will be added to a ring buffer