From c820fbc591eb69e8e429a12f9ed33f21db761f56 Mon Sep 17 00:00:00 2001 From: Paul Fd Date: Tue, 7 Apr 2020 22:01:37 +0200 Subject: [PATCH] Added sanity checks in Voice (disabled) and Synth --- src/sfizz/Synth.cpp | 5 +++++ src/sfizz/Voice.cpp | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/sfizz/Synth.cpp b/src/sfizz/Synth.cpp index 52dfba4c..814f5e5e 100644 --- a/src/sfizz/Synth.cpp +++ b/src/sfizz/Synth.cpp @@ -645,6 +645,11 @@ void sfz::Synth::renderBlock(AudioSpan buffer) noexcept // Reset the dispatch counter dispatchDuration = Duration(0); + + ASSERT(!hasNanInf(buffer.getConstSpan(0))); + ASSERT(!hasNanInf(buffer.getConstSpan(1))); + ASSERT(isValidAudio(buffer.getConstSpan(0))); + ASSERT(isValidAudio(buffer.getConstSpan(1))); } void sfz::Synth::noteOn(int delay, int noteNumber, uint8_t velocity) noexcept diff --git a/src/sfizz/Voice.cpp b/src/sfizz/Voice.cpp index 251a1167..fcb1d9fd 100644 --- a/src/sfizz/Voice.cpp +++ b/src/sfizz/Voice.cpp @@ -241,6 +241,12 @@ void sfz::Voice::renderBlock(AudioSpan buffer) noexcept powerHistory.push(buffer.meanSquared()); this->triggerDelay = absl::nullopt; +#if 0 + ASSERT(!hasNanInf(buffer.getConstSpan(0))); + ASSERT(!hasNanInf(buffer.getConstSpan(1))); + ASSERT(isValidAudio(buffer.getConstSpan(0))); + ASSERT(isValidAudio(buffer.getConstSpan(1))); +#endif } void sfz::Voice::amplitudeEnvelope(absl::Span modulationSpan) noexcept @@ -515,6 +521,13 @@ void sfz::Voice::fillWithData(AudioSpan buffer) noexcept sourcePosition = indices->back(); floatPositionOffset = rightCoeffs->back(); + +#if 0 + ASSERT(!hasNanInf(buffer.getConstSpan(0))); + ASSERT(!hasNanInf(buffer.getConstSpan(1))); + ASSERT(isValidAudio(buffer.getConstSpan(0))); + ASSERT(isValidAudio(buffer.getConstSpan(1))); +#endif } void sfz::Voice::fillWithGenerator(AudioSpan buffer) noexcept @@ -573,6 +586,13 @@ void sfz::Voice::fillWithGenerator(AudioSpan buffer) noexcept } } } + +#if 0 + ASSERT(!hasNanInf(buffer.getConstSpan(0))); + ASSERT(!hasNanInf(buffer.getConstSpan(1))); + ASSERT(isValidAudio(buffer.getConstSpan(0))); + ASSERT(isValidAudio(buffer.getConstSpan(1))); +#endif } bool sfz::Voice::checkOffGroup(int delay, uint32_t group) noexcept