Fix the high frequency rolloff
This commit is contained in:
parent
eda842c6a9
commit
8fbdc43ce3
|
@ -557,7 +557,7 @@ impl CompressorBank {
|
|||
// If the high-frequency rolloff is enabled then higher frequency bins will have their
|
||||
// ratios reduced to reduce harshness. This follows the octave scale.
|
||||
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);
|
||||
} else {
|
||||
for (log2_freq, ratio) in self
|
||||
|
@ -565,11 +565,11 @@ impl CompressorBank {
|
|||
.iter()
|
||||
.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;
|
||||
// Division because we're dealing with the reciprocal here
|
||||
*ratio =
|
||||
target_ratio_recip / (1.0 - (octave_fraction * high_freq_ratio_rolloff));
|
||||
let rolloff_t = octave_fraction * high_freq_ratio_rolloff;
|
||||
// If the octave fraction times the rolloff amount is high, then this should get
|
||||
// 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()
|
||||
{
|
||||
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);
|
||||
} else {
|
||||
for (log2_freq, ratio) in self
|
||||
|
@ -589,8 +589,8 @@ impl CompressorBank {
|
|||
.zip(self.upwards_ratio_recips.iter_mut())
|
||||
{
|
||||
let octave_fraction = log2_freq / log2_nyquist_freq;
|
||||
*ratio =
|
||||
target_ratio_recip / (1.0 - (octave_fraction * high_freq_ratio_rolloff));
|
||||
let rolloff_t = octave_fraction * high_freq_ratio_rolloff;
|
||||
*ratio = (target_ratio_recip * (1.0 - rolloff_t)) + rolloff_t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue