From 43f86bcc8582bcf20d125868cc367c2589ce91ef Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Fri, 22 Jul 2022 23:36:04 +0200 Subject: [PATCH] Prevent threshold from reaching zero --- plugins/spectral_compressor/src/compressor_bank.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/spectral_compressor/src/compressor_bank.rs b/plugins/spectral_compressor/src/compressor_bank.rs index e3a92d79..582c502c 100644 --- a/plugins/spectral_compressor/src/compressor_bank.rs +++ b/plugins/spectral_compressor/src/compressor_bank.rs @@ -528,7 +528,9 @@ impl CompressorBank { { let offset = log2_center_freq - log2_freq; let threshold_db = intercept + (slope * offset) + (curve * offset * offset); - *threshold = util::db_to_gain(threshold_db) + // This threshold may never reach zero as it's used in divisions to get a gain ratio + // above the threshold + *threshold = util::db_to_gain(threshold_db).max(f32::EPSILON); } } @@ -545,7 +547,7 @@ impl CompressorBank { { let offset = log2_center_freq - log2_freq; let threshold_db = intercept + (slope * offset) + (curve * offset * offset); - *threshold = util::db_to_gain(threshold_db) + *threshold = util::db_to_gain(threshold_db).max(f32::EPSILON); } }