diff --git a/src/juce_appframework/audio/dsp/juce_IIRFilter.cpp b/src/juce_appframework/audio/dsp/juce_IIRFilter.cpp index dc4440cc68..a20c685fd1 100644 --- a/src/juce_appframework/audio/dsp/juce_IIRFilter.cpp +++ b/src/juce_appframework/audio/dsp/juce_IIRFilter.cpp @@ -67,6 +67,27 @@ void IIRFilter::reset() throw() y2 = 0; } +float IIRFilter::processSingleSampleRaw (const float in) throw() +{ + float out = coefficients[0] * in + + coefficients[1] * x1 + + coefficients[2] * x2 + - coefficients[4] * y1 + - coefficients[5] * y2; + +#if JUCE_INTEL + if (! (out < -1.0e-8 || out > 1.0e-8)) + out = 0; +#endif + + x2 = x1; + x1 = in; + y2 = y1; + y1 = out; + + return out; +} + void IIRFilter::processSamples (float* const samples, const int numSamples) throw() { diff --git a/src/juce_appframework/audio/dsp/juce_IIRFilter.h b/src/juce_appframework/audio/dsp/juce_IIRFilter.h index 4bad83484c..39d1133f57 100644 --- a/src/juce_appframework/audio/dsp/juce_IIRFilter.h +++ b/src/juce_appframework/audio/dsp/juce_IIRFilter.h @@ -74,6 +74,13 @@ public: void processSamples (float* const samples, const int numSamples) throw(); + /** Processes a single sample, without any locking or checking. + + Use this if you need fast processing of a single value, but be aware that + this isn't thread-safe in the way that processSamples() is. + */ + float processSingleSampleRaw (const float sample) throw(); + //============================================================================== /** Sets the filter up to act as a low-pass filter. */