diff --git a/modules/juce_dsp/filter_design/juce_FilterDesign.cpp b/modules/juce_dsp/filter_design/juce_FilterDesign.cpp index 691c921df0..98bd143d9d 100644 --- a/modules/juce_dsp/filter_design/juce_FilterDesign.cpp +++ b/modules/juce_dsp/filter_design/juce_FilterDesign.cpp @@ -337,7 +337,7 @@ Array FilterDesign::getPartialImpulseResponseHn (int n, doubl } template -Array> +ReferenceCountedArray> FilterDesign::designIIRLowpassHighOrderButterworthMethod (FloatType frequency, double sampleRate, FloatType normalizedTransitionWidth, FloatType passbandAttenuationdB, @@ -348,7 +348,7 @@ Array> } template -Array> +ReferenceCountedArray> FilterDesign::designIIRLowpassHighOrderChebyshev1Method (FloatType frequency, double sampleRate, FloatType normalizedTransitionWidth, FloatType passbandAttenuationdB, @@ -359,7 +359,7 @@ Array> } template -Array> +ReferenceCountedArray> FilterDesign::designIIRLowpassHighOrderChebyshev2Method (FloatType frequency, double sampleRate, FloatType normalizedTransitionWidth, FloatType passbandAttenuationdB, @@ -370,7 +370,7 @@ Array> } template -Array> +ReferenceCountedArray> FilterDesign::designIIRLowpassHighOrderEllipticMethod (FloatType frequency, double sampleRate, FloatType normalizedTransitionWidth, FloatType passbandAttenuationdB, @@ -381,7 +381,7 @@ Array> } template -Array> +ReferenceCountedArray> FilterDesign::designIIRLowpassHighOrderGeneralMethod (int type, FloatType frequency, double sampleRate, FloatType normalizedTransitionWidth, FloatType passbandAttenuationdB, @@ -510,7 +510,7 @@ Array> g.add ((1.0 - p[i + r]) / (1.0 - z[i])); } - Array> cascadedCoefficients; + ReferenceCountedArray> cascadedCoefficients; if (r == 1) { @@ -518,7 +518,7 @@ Array> auto b1 = b0; auto a1 = static_cast (-std::real (p[0])); - cascadedCoefficients.add ({ b0, b1, 1.0f, a1 }); + cascadedCoefficients.add (new IIR::Coefficients (b0, b1, 1.0f, a1)); } for (int i = 0; i < L; ++i) @@ -532,14 +532,14 @@ Array> auto a1 = static_cast (std::real (-p[i+r] - std::conj (p[i + r]))); auto a2 = static_cast (std::real ( p[i+r] * std::conj (p[i + r]))); - cascadedCoefficients.add ({ b0, b1, b2, 1, a1, a2 }); + cascadedCoefficients.add (new IIR::Coefficients (b0, b1, b2, 1, a1, a2)); } return cascadedCoefficients; } template -Array> +ReferenceCountedArray> FilterDesign::designIIRLowpassHighOrderButterworthMethod (FloatType frequency, double sampleRate, int order) { @@ -547,7 +547,7 @@ Array> jassert (frequency > 0 && frequency <= sampleRate * 0.5); jassert (order > 0); - Array> arrayFilters; + ReferenceCountedArray> arrayFilters; if (order % 2 == 1) { @@ -574,7 +574,7 @@ Array> } template -Array> +ReferenceCountedArray> FilterDesign::designIIRHighpassHighOrderButterworthMethod (FloatType frequency, double sampleRate, int order) { @@ -582,7 +582,7 @@ Array> jassert (frequency > 0 && frequency <= sampleRate * 0.5); jassert (order > 0); - Array> arrayFilters; + ReferenceCountedArray> arrayFilters; if (order % 2 == 1) { @@ -678,14 +678,14 @@ typename FilterDesign::IIRPolyphaseAllpassStructure IIRPolyphaseAllpassStructure structure; for (int i = 0; i < N; i += 2) - structure.directPath.add (IIR::Coefficients (static_cast (ai[i]), - 0, 1, 1, 0, static_cast (ai[i]))); + structure.directPath.add (new IIR::Coefficients (static_cast (ai[i]), + 0, 1, 1, 0, static_cast (ai[i]))); - structure.delayedPath.add (IIR::Coefficients (0, 1, 1, 0)); + structure.delayedPath.add (new IIR::Coefficients (0, 1, 1, 0)); for (int i = 1; i < N; i += 2) - structure.delayedPath.add (IIR::Coefficients (static_cast (ai[i]), - 0, 1, 1, 0, static_cast (ai[i]))); + structure.delayedPath.add (new IIR::Coefficients (static_cast (ai[i]), + 0, 1, 1, 0, static_cast (ai[i]))); return structure; } diff --git a/modules/juce_dsp/filter_design/juce_FilterDesign.h b/modules/juce_dsp/filter_design/juce_FilterDesign.h index 8a055a3637..501737f6fa 100755 --- a/modules/juce_dsp/filter_design/juce_FilterDesign.h +++ b/modules/juce_dsp/filter_design/juce_FilterDesign.h @@ -158,10 +158,10 @@ struct FilterDesign @param stopbandAttenuationdB the attenuation in dB expected in the stop band */ - static Array designIIRLowpassHighOrderButterworthMethod (FloatType frequency, double sampleRate, - FloatType normalizedTransitionWidth, - FloatType passbandAttenuationdB, - FloatType stopbandAttenuationdB); + static ReferenceCountedArray designIIRLowpassHighOrderButterworthMethod (FloatType frequency, double sampleRate, + FloatType normalizedTransitionWidth, + FloatType passbandAttenuationdB, + FloatType stopbandAttenuationdB); //============================================================================== /** This method returns an array of IIR::Coefficients, made to be used in @@ -174,8 +174,8 @@ struct FilterDesign an attenuation of -6 dB times order / octave */ - static Array designIIRLowpassHighOrderButterworthMethod (FloatType frequency, double sampleRate, - int order); + static ReferenceCountedArray designIIRLowpassHighOrderButterworthMethod (FloatType frequency, double sampleRate, + int order); /** This method returns an array of IIR::Coefficients, made to be used in cascaded IIRFilters, providing a minimum phase high-pass filter without any @@ -187,8 +187,8 @@ struct FilterDesign an attenuation of -6 dB times order / octave */ - static Array designIIRHighpassHighOrderButterworthMethod (FloatType frequency, double sampleRate, - int order); + static ReferenceCountedArray designIIRHighpassHighOrderButterworthMethod (FloatType frequency, double sampleRate, + int order); /** This method returns an array of IIR::Coefficients, made to be used in cascaded IIRFilters, providing a minimum phase low-pass filter without any @@ -204,10 +204,10 @@ struct FilterDesign @param passbandAttenuationdB the lowest attenuation in dB expected in the pass band @param stopbandAttenuationdB the attenuation in dB expected in the stop band */ - static Array designIIRLowpassHighOrderChebyshev1Method (FloatType frequency, double sampleRate, - FloatType normalizedTransitionWidth, - FloatType passbandAttenuationdB, - FloatType stopbandAttenuationdB); + static ReferenceCountedArray designIIRLowpassHighOrderChebyshev1Method (FloatType frequency, double sampleRate, + FloatType normalizedTransitionWidth, + FloatType passbandAttenuationdB, + FloatType stopbandAttenuationdB); /** This method returns an array of IIR::Coefficients, made to be used in cascaded IIRFilters, providing a minimum phase low-pass filter without any @@ -223,10 +223,10 @@ struct FilterDesign @param passbandAttenuationdB the lowest attenuation in dB expected in the pass band @param stopbandAttenuationdB the attenuation in dB expected in the stop band */ - static Array designIIRLowpassHighOrderChebyshev2Method (FloatType frequency, double sampleRate, - FloatType normalizedTransitionWidth, - FloatType passbandAttenuationdB, - FloatType stopbandAttenuationdB); + static ReferenceCountedArray designIIRLowpassHighOrderChebyshev2Method (FloatType frequency, double sampleRate, + FloatType normalizedTransitionWidth, + FloatType passbandAttenuationdB, + FloatType stopbandAttenuationdB); /** This method returns an array of IIR::Coefficients, made to be used in cascaded IIR::Filters, providing a minimum phase low-pass filter with ripples @@ -242,10 +242,10 @@ struct FilterDesign @param passbandAttenuationdB the lowest attenuation in dB expected in the pass band @param stopbandAttenuationdB the attenuation in dB expected in the stop band */ - static Array designIIRLowpassHighOrderEllipticMethod (FloatType frequency, double sampleRate, - FloatType normalizedTransitionWidth, - FloatType passbandAttenuationdB, - FloatType stopbandAttenuationdB); + static ReferenceCountedArray designIIRLowpassHighOrderEllipticMethod (FloatType frequency, double sampleRate, + FloatType normalizedTransitionWidth, + FloatType passbandAttenuationdB, + FloatType stopbandAttenuationdB); /** The structure returned by the function designIIRLowpassHalfBandPolyphaseAllpassMethod. @@ -255,7 +255,7 @@ struct FilterDesign parallel paths, which must be summed at the end to get the high order efficient low-pass filtering. */ - struct IIRPolyphaseAllpassStructure { Array directPath, delayedPath; }; + struct IIRPolyphaseAllpassStructure { ReferenceCountedArray directPath, delayedPath; }; /** This method generates arrays of IIR::Coefficients for a low-pass filter, with a cutoff frequency at half band, using an algorithm described in the article @@ -284,10 +284,10 @@ private: //============================================================================== static Array getPartialImpulseResponseHn (int n, double kp); - static Array designIIRLowpassHighOrderGeneralMethod (int type, FloatType frequency, double sampleRate, - FloatType normalizedTransitionWidth, - FloatType passbandAttenuationdB, - FloatType stopbandAttenuationdB); + static ReferenceCountedArray designIIRLowpassHighOrderGeneralMethod (int type, FloatType frequency, double sampleRate, + FloatType normalizedTransitionWidth, + FloatType passbandAttenuationdB, + FloatType stopbandAttenuationdB); FilterDesign() = delete; }; diff --git a/modules/juce_dsp/processors/juce_Oversampling.cpp b/modules/juce_dsp/processors/juce_Oversampling.cpp index 7f3be92c6d..8a71c1ecd6 100644 --- a/modules/juce_dsp/processors/juce_Oversampling.cpp +++ b/modules/juce_dsp/processors/juce_Oversampling.cpp @@ -290,17 +290,17 @@ public: dsp::IIR::Coefficients coeffsDown = getCoefficients (structureDown); latency += static_cast (-(coeffsDown.getPhaseForFrequency (0.0001, 1.0)) / (0.0001 * MathConstants::twoPi)); - for (auto& i : structureUp.directPath) - coefficientsUp.add (i.coefficients[0]); + for (auto i = 0; i < structureUp.directPath.size(); ++i) + coefficientsUp.add (structureUp.delayedPath.getObjectPointer (i)->coefficients[0]); for (auto i = 1; i < structureUp.delayedPath.size(); ++i) - coefficientsUp.add (structureUp.delayedPath[i].coefficients[0]); + coefficientsUp.add (structureUp.delayedPath.getObjectPointer (i)->coefficients[0]); - for (auto& i : structureDown.directPath) - coefficientsDown.add (i.coefficients[0]); + for (auto i = 0; i < structureDown.directPath.size(); ++i) + coefficientsDown.add (structureUp.delayedPath.getObjectPointer (i)->coefficients[0]); for (auto i = 1; i < structureDown.delayedPath.size(); ++i) - coefficientsDown.add (structureDown.delayedPath[i].coefficients[0]); + coefficientsDown.add (structureUp.delayedPath.getObjectPointer (i)->coefficients[0]); v1Up.setSize (static_cast (this->numChannels), coefficientsUp.size()); v1Down.setSize (static_cast (this->numChannels), coefficientsDown.size()); @@ -478,9 +478,9 @@ private: for (auto n = 0; n < structure.directPath.size(); ++n) { - auto* coeffs = structure.directPath.getReference (n).getRawCoefficients(); + auto* coeffs = structure.directPath.getObjectPointer (n)->getRawCoefficients(); - if (structure.directPath[n].getFilterOrder() == 1) + if (structure.directPath.getObjectPointer (n)->getFilterOrder() == 1) { numerator1 = numerator1.getProductWith (dsp::Polynomial ({ coeffs[0], coeffs[1] })); denominator1 = denominator1.getProductWith (dsp::Polynomial ({ one, coeffs[2] })); @@ -494,9 +494,9 @@ private: for (auto n = 0; n < structure.delayedPath.size(); ++n) { - auto* coeffs = structure.delayedPath.getReference (n).getRawCoefficients(); + auto* coeffs = structure.delayedPath.getObjectPointer (n)->getRawCoefficients(); - if (structure.delayedPath[n].getFilterOrder() == 1) + if (structure.delayedPath.getObjectPointer (n)->getFilterOrder() == 1) { numerator2 = numerator2.getProductWith (dsp::Polynomial ({ coeffs[0], coeffs[1] })); denominator2 = denominator2.getProductWith (dsp::Polynomial ({ one, coeffs[2] }));