Browse Source

DSP: snapToZero is now a public method of the IIR and StateVariable filters so that they can be called manually after sample by sample processing

tags/2021-05-28
hogliux 7 years ago
parent
commit
74c7633aab
2 changed files with 13 additions and 4 deletions
  1. +6
    -1
      modules/juce_dsp/processors/juce_IIRFilter.h
  2. +7
    -3
      modules/juce_dsp/processors/juce_StateVariableFilter.h

+ 6
- 1
modules/juce_dsp/processors/juce_IIRFilter.h View File

@@ -114,9 +114,14 @@ namespace IIR
*/
SampleType JUCE_VECTOR_CALLTYPE processSample (SampleType sample) noexcept;
/** Ensure that the state variables are rounded to zero if the state
variables are denormals. This is only needed if you are doing
sample by sample processing.
*/
void snapToZero() noexcept;
private:
//==============================================================================
void snapToZero() noexcept;
void check();
//==============================================================================


+ 7
- 3
modules/juce_dsp/processors/juce_StateVariableFilter.h View File

@@ -74,6 +74,12 @@ namespace StateVariableFilter
/** Resets the filter's processing pipeline. */
void reset() noexcept { s1 = s2 = SampleType {0}; }
/** Ensure that the state variables are rounded to zero if the state
variables are denormals. This is only needed if you are doing
sample by sample processing.
*/
void snapToZero() noexcept { util::snapToZero (s1); util::snapToZero (s2); }
//==============================================================================
/** The parameters of the state variable filter. It's up to the called to ensure
that these parameters are modified in a thread-safe way. */
@@ -145,9 +151,7 @@ namespace StateVariableFilter
for (size_t i = 0 ; i < n; ++i)
output[i] = processLoop<type> (input[i], state);
util::snapToZero (s1);
util::snapToZero (s2);
snapToZero();
*parameters = state;
}


Loading…
Cancel
Save