1
0
Fork 0

Fix the high frequency rolloff

This commit is contained in:
Robbert van der Helm 2022-07-22 23:22:39 +02:00
parent eda842c6a9
commit 8fbdc43ce3

View file

@ -557,7 +557,7 @@ impl CompressorBank {
// If the high-frequency rolloff is enabled then higher frequency bins will have their // If the high-frequency rolloff is enabled then higher frequency bins will have their
// ratios reduced to reduce harshness. This follows the octave scale. // ratios reduced to reduce harshness. This follows the octave scale.
let target_ratio_recip = compressor.downwards_ratio.value.recip(); let target_ratio_recip = compressor.downwards_ratio.value.recip();
if high_freq_ratio_rolloff == 1.0 { if high_freq_ratio_rolloff == 0.0 {
self.downwards_ratio_recips.fill(target_ratio_recip); self.downwards_ratio_recips.fill(target_ratio_recip);
} else { } else {
for (log2_freq, ratio) in self for (log2_freq, ratio) in self
@ -565,11 +565,11 @@ impl CompressorBank {
.iter() .iter()
.zip(self.downwards_ratio_recips.iter_mut()) .zip(self.downwards_ratio_recips.iter_mut())
{ {
// This is scaled by octaves since we're calculating this in log space
let octave_fraction = log2_freq / log2_nyquist_freq; let octave_fraction = log2_freq / log2_nyquist_freq;
// Division because we're dealing with the reciprocal here let rolloff_t = octave_fraction * high_freq_ratio_rolloff;
*ratio = // If the octave fraction times the rolloff amount is high, then this should get
target_ratio_recip / (1.0 - (octave_fraction * high_freq_ratio_rolloff)); // closer to `high_freq_ratio_rolloff` (which is in [0, 1]).
*ratio = (target_ratio_recip * (1.0 - rolloff_t)) + rolloff_t;
} }
} }
} }
@ -580,7 +580,7 @@ impl CompressorBank {
.is_ok() .is_ok()
{ {
let target_ratio_recip = compressor.upwards_ratio.value.recip(); let target_ratio_recip = compressor.upwards_ratio.value.recip();
if high_freq_ratio_rolloff == 1.0 { if high_freq_ratio_rolloff == 0.0 {
self.upwards_ratio_recips.fill(target_ratio_recip); self.upwards_ratio_recips.fill(target_ratio_recip);
} else { } else {
for (log2_freq, ratio) in self for (log2_freq, ratio) in self
@ -589,8 +589,8 @@ impl CompressorBank {
.zip(self.upwards_ratio_recips.iter_mut()) .zip(self.upwards_ratio_recips.iter_mut())
{ {
let octave_fraction = log2_freq / log2_nyquist_freq; let octave_fraction = log2_freq / log2_nyquist_freq;
*ratio = let rolloff_t = octave_fraction * high_freq_ratio_rolloff;
target_ratio_recip / (1.0 - (octave_fraction * high_freq_ratio_rolloff)); *ratio = (target_ratio_recip * (1.0 - rolloff_t)) + rolloff_t;
} }
} }
} }