1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

FilterDesign: Add assertions to catch misuse of design functions

This commit is contained in:
reuk 2021-08-23 16:45:44 +01:00
parent e02a09da0c
commit c41f64111f
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -386,16 +386,19 @@ ReferenceCountedArray<IIR::Coefficients<FloatType>>
FloatType passbandAmplitudedB,
FloatType stopbandAmplitudedB)
{
jassert (sampleRate > 0);
jassert (frequency > 0 && frequency <= sampleRate * 0.5);
jassert (normalisedTransitionWidth > 0 && normalisedTransitionWidth <= 0.5);
jassert (passbandAmplitudedB > -20 && passbandAmplitudedB < 0);
jassert (stopbandAmplitudedB > -300 && stopbandAmplitudedB < -20);
jassert (0 < sampleRate);
jassert (0 < frequency && frequency <= sampleRate * 0.5);
jassert (0 < normalisedTransitionWidth && normalisedTransitionWidth <= 0.5);
jassert (-20 < passbandAmplitudedB && passbandAmplitudedB < 0);
jassert (-300 < stopbandAmplitudedB && stopbandAmplitudedB < -20);
auto normalisedFrequency = frequency / sampleRate;
auto fp = normalisedFrequency - normalisedTransitionWidth / 2;
jassert (0.0 < fp && fp < 0.5);
auto fs = normalisedFrequency + normalisedTransitionWidth / 2;
jassert (0.0 < fs && fs < 0.5);
double Ap = passbandAmplitudedB;
double As = stopbandAmplitudedB;