Handle infinite and NaN values in Safety Limiter
This commit is contained in:
parent
6e37353c67
commit
aa60d616fe
|
@ -3,7 +3,8 @@
|
||||||
This plugin is a simple tool to prevent ear damage. As soon as there is a peak
|
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
|
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
|
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!
|
sessions, but maybe you'll find it useful too!
|
||||||
|
|
||||||
**Why not use a regular brickwall peak limiter?**
|
**Why not use a regular brickwall peak limiter?**
|
||||||
|
|
|
@ -209,7 +209,14 @@ impl Plugin for SafetyLimiter {
|
||||||
for mut channel_samples in buffer.iter_samples() {
|
for mut channel_samples in buffer.iter_samples() {
|
||||||
let mut is_peaking = false;
|
let mut is_peaking = false;
|
||||||
for sample in channel_samples.iter_mut() {
|
for sample in channel_samples.iter_mut() {
|
||||||
|
if sample.is_finite() {
|
||||||
is_peaking |= sample.abs() > self.params.threshold_gain.value;
|
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 {
|
if is_peaking {
|
||||||
|
|
Loading…
Reference in a new issue