Clamp the cutoff values to avoid filters blowing up
This commit is contained in:
parent
4e13493ab4
commit
54d2b7342c
2 changed files with 8 additions and 0 deletions
|
|
@ -75,6 +75,7 @@ void sfz::FilterHolder::process(const float** inputs, float** outputs, unsigned
|
|||
for (size_t i = 0; i < numFrames; ++i)
|
||||
(*cutoffSpan)[i] *= centsFactor(mod[i]);
|
||||
}
|
||||
sfz::clampAll(*cutoffSpan, Default::filterCutoffRange);
|
||||
|
||||
fill<float>(*resonanceSpan, baseResonance);
|
||||
if (float* mod = mm.getModulation(resonanceTarget))
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#pragma once
|
||||
#include "Config.h"
|
||||
#include "Debug.h"
|
||||
#include "Range.h"
|
||||
#include "MathHelpers.h"
|
||||
#include "simd/HelpersScalar.h"
|
||||
#include <absl/types/span.h>
|
||||
|
|
@ -720,6 +721,12 @@ void clampAll(absl::Span<T> input, T low, T high) noexcept
|
|||
clampAll<T>(input.data(), low, high, input.size());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void clampAll(absl::Span<T> input, sfz::Range<T> range) noexcept
|
||||
{
|
||||
clampAll<T>(input.data(), range.getStart(), range.getEnd(), input.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check that all values are within bounds (inclusive)
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue