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


Loading…
Cancel
Save