Handle infinite and NaN values in Safety Limiter

This commit is contained in:
Robbert van der Helm
2022-06-13 18:47:48 +02:00
parent 6e37353c67
commit aa60d616fe
2 changed files with 10 additions and 2 deletions

View File

@@ -209,7 +209,14 @@ impl Plugin for SafetyLimiter {
for mut channel_samples in buffer.iter_samples() {
let mut is_peaking = false;
for sample in channel_samples.iter_mut() {
is_peaking |= sample.abs() > self.params.threshold_gain.value;
if sample.is_finite() {
is_peaking |= sample.abs() > self.params.threshold_gain.value;
} else {
// Infinity or NaN values need to be completely filtered out, because otherwise
// we'll try to mix them back into the signal later
*sample = 0.0;
is_peaking = true;
}
}
if is_peaking {