Browse Source

Made the dsp::Filter copy constructor reset the state. Also added a couple of missing move constructors to that class

tags/2021-05-28
jules 7 years ago
parent
commit
82073da570
2 changed files with 20 additions and 6 deletions
  1. +13
    -0
      modules/juce_dsp/processors/juce_IIRFilter.cpp
  2. +7
    -6
      modules/juce_dsp/processors/juce_IIRFilter.h

+ 13
- 0
modules/juce_dsp/processors/juce_IIRFilter.cpp View File

@@ -45,6 +45,12 @@ IIR::Coefficients<NumericType>::Coefficients (const Coefficients& other)
{
}
template <typename NumericType>
IIR::Coefficients<NumericType>::Coefficients (Coefficients&& other)
: coefficients (static_cast<Array<NumericType>&&> (other.coefficients))
{
}
template <typename NumericType>
IIR::Coefficients<NumericType>& IIR::Coefficients<NumericType>::operator= (const Coefficients& other)
{
@@ -52,6 +58,13 @@ IIR::Coefficients<NumericType>& IIR::Coefficients<NumericType>::operator= (const
return *this;
}
template <typename NumericType>
IIR::Coefficients<NumericType>& IIR::Coefficients<NumericType>::operator= (Coefficients&& other)
{
coefficients = static_cast<Array<NumericType>&&> (other.coefficients);
return *this;
}
template <typename NumericType>
IIR::Coefficients<NumericType>::Coefficients (NumericType b0, NumericType b1,
NumericType a0, NumericType a1)


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

@@ -69,7 +69,10 @@ namespace IIR
Filter (Coefficients<NumericType>* coefficientsToUse);
/** Creates a copy of another filter. */
Filter (const Filter&) = default;
Filter (const Filter& other) : coefficients (other.coefficients) { reset(); }
/** Creates a copy of another filter. */
Filter& operator= (const Filter& other) { coefficients = other.coefficients; reset(); }
/** Move constructor. */
Filter (Filter&&) = default;
@@ -89,10 +92,9 @@ namespace IIR
Note that this clears the processing state, but the type of filter and
its coefficients aren't changed.
*/
void reset() { reset (SampleType {0}); }
void reset() { reset ({}); }
/** Resets the filter's processing pipeline to a specific value.
@see reset
*/
void reset (SampleType resetToValue);
@@ -156,11 +158,10 @@ namespace IIR
Coefficients (NumericType b0, NumericType, NumericType b2, NumericType b3,
NumericType a0, NumericType a1, NumericType a2, NumericType a3);
/** Creates a copy of another filter. */
Coefficients (const Coefficients&);
/** Creates a copy of another filter. */
Coefficients (Coefficients&&);
Coefficients& operator= (const Coefficients&);
Coefficients& operator= (Coefficients&&);
/** The Coefficients structure is ref-counted, so this is a handy type that can be used
as a pointer to one.


Loading…
Cancel
Save