Log on NaN and inf in Safety Limiter
This commit is contained in:
parent
cf52d60a61
commit
886f3a78ef
16
plugins/safety_limiter/CHANGELOG.md
Normal file
16
plugins/safety_limiter/CHANGELOG.md
Normal file
|
@ -0,0 +1,16 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic
|
||||
Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- Safety Limiter now logs occurrences of NaN and infinite values so they're
|
||||
easier to spot. These values already caused Safety Limiter to engage, but this
|
||||
makes it very easy to notice that something fishy is going on during
|
||||
development.
|
|
@ -15,6 +15,7 @@
|
|||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use nih_plug::prelude::*;
|
||||
use nih_plug::util::permit_alloc;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// After reaching the threshold, it will take this many milliseconds under that threshold to start
|
||||
|
@ -206,6 +207,11 @@ impl Plugin for SafetyLimiter {
|
|||
return ProcessStatus::Normal;
|
||||
}
|
||||
|
||||
// We'll print this once per buffer to make it obvious something very fishy is going on
|
||||
// without tanking performance too much
|
||||
let mut buffer_contains_nan = false;
|
||||
let mut buffer_contains_inf = false;
|
||||
|
||||
let &(morse_seq_len, _) = self.morse_seq_edges_samples.last().unwrap();
|
||||
for mut channel_samples in buffer.iter_samples() {
|
||||
let mut is_peaking = false;
|
||||
|
@ -217,6 +223,14 @@ impl Plugin for SafetyLimiter {
|
|||
// we'll try to mix them back into the signal later
|
||||
*sample = 0.0;
|
||||
is_peaking = true;
|
||||
|
||||
if sample.is_nan() {
|
||||
buffer_contains_nan = true;
|
||||
} else if sample.is_infinite() {
|
||||
buffer_contains_inf = true;
|
||||
} else {
|
||||
unreachable!();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -290,6 +304,13 @@ impl Plugin for SafetyLimiter {
|
|||
}
|
||||
}
|
||||
|
||||
if buffer_contains_nan {
|
||||
permit_alloc(|| nih_log!("The buffer contains NaN values"));
|
||||
}
|
||||
if buffer_contains_inf {
|
||||
permit_alloc(|| nih_log!("The buffer contains infinite values"));
|
||||
}
|
||||
|
||||
ProcessStatus::Normal
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue