1
0
Fork 0

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

@ -3,7 +3,8 @@
This plugin is a simple tool to prevent ear damage. As soon as there is a peak
above 0 dBFS or the specified threshold, the plugin will cut over to playing SOS
in Morse code, gradually fading out again when the input returns back to safe
levels. Made for personal use during plugin development and intense sound design
levels. The same thing happens if the input contains infinite or NaN values.
Made for personal use during plugin development and intense sound design
sessions, but maybe you'll find it useful too!
**Why not use a regular brickwall peak limiter?**

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 {