OpenShot Audio Library | OpenShotAudio  0.6.0
juce_FilterDesign.h
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2022 - Raw Material Software Limited
6 
7  JUCE is an open source library subject to commercial or open-source
8  licensing.
9 
10  By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11  Agreement and JUCE Privacy Policy.
12 
13  End User License Agreement: www.juce.com/juce-7-licence
14  Privacy Policy: www.juce.com/juce-privacy-policy
15 
16  Or: You may also use this code under the terms of the GPL v3 (see
17  www.gnu.org/licenses).
18 
19  JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20  EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21  DISCLAIMED.
22 
23  ==============================================================================
24 */
25 
26 namespace juce::dsp
27 {
28 
38 template <typename FloatType>
40 {
41  using FIRCoefficientsPtr = typename FIR::Coefficients<FloatType>::Ptr;
42  using IIRCoefficients = typename IIR::Coefficients<FloatType>;
43 
44  using WindowingMethod = typename WindowingFunction<FloatType>::WindowingMethod;
45 
46  //==============================================================================
66  static FIRCoefficientsPtr designFIRLowpassWindowMethod (FloatType frequency, double sampleRate,
67  size_t order, WindowingMethod type,
68  FloatType beta = static_cast<FloatType> (2));
69 
84  static FIRCoefficientsPtr designFIRLowpassKaiserMethod (FloatType frequency, double sampleRate,
85  FloatType normalisedTransitionWidth,
86  FloatType amplitudedB);
87 
88 
103  static FIRCoefficientsPtr designFIRLowpassTransitionMethod (FloatType frequency, double sampleRate,
104  size_t order,
105  FloatType normalisedTransitionWidth,
106  FloatType spline);
107 
123  static FIRCoefficientsPtr designFIRLowpassLeastSquaresMethod (FloatType frequency, double sampleRate, size_t order,
124  FloatType normalisedTransitionWidth,
125  FloatType stopBandWeight);
126 
139  static FIRCoefficientsPtr designFIRLowpassHalfBandEquirippleMethod (FloatType normalisedTransitionWidth,
140  FloatType amplitudedB);
141 
142  //==============================================================================
158  static ReferenceCountedArray<IIRCoefficients> designIIRLowpassHighOrderButterworthMethod (FloatType frequency, double sampleRate,
159  FloatType normalisedTransitionWidth,
160  FloatType passbandAmplitudedB,
161  FloatType stopbandAmplitudedB);
162 
163  //==============================================================================
174  static ReferenceCountedArray<IIRCoefficients> designIIRLowpassHighOrderButterworthMethod (FloatType frequency, double sampleRate,
175  int order);
176 
187  static ReferenceCountedArray<IIRCoefficients> designIIRHighpassHighOrderButterworthMethod (FloatType frequency, double sampleRate,
188  int order);
189 
204  static ReferenceCountedArray<IIRCoefficients> designIIRLowpassHighOrderChebyshev1Method (FloatType frequency, double sampleRate,
205  FloatType normalisedTransitionWidth,
206  FloatType passbandAmplitudedB,
207  FloatType stopbandAmplitudedB);
208 
223  static ReferenceCountedArray<IIRCoefficients> designIIRLowpassHighOrderChebyshev2Method (FloatType frequency, double sampleRate,
224  FloatType normalisedTransitionWidth,
225  FloatType passbandAmplitudedB,
226  FloatType stopbandAmplitudedB);
227 
242  static ReferenceCountedArray<IIRCoefficients> designIIRLowpassHighOrderEllipticMethod (FloatType frequency, double sampleRate,
243  FloatType normalisedTransitionWidth,
244  FloatType passbandAmplitudedB,
245  FloatType stopbandAmplitudedB);
246 
257  {
258  ReferenceCountedArray<IIRCoefficients> directPath, delayedPath;
259  Array<double> alpha;
260  };
261 
282  static IIRPolyphaseAllpassStructure designIIRLowpassHalfBandPolyphaseAllpassMethod (FloatType normalisedTransitionWidth,
283  FloatType stopbandAmplitudedB);
284 
285 private:
286  //==============================================================================
287  static Array<double> getPartialImpulseResponseHn (int n, double kp);
288 
289  static ReferenceCountedArray<IIRCoefficients> designIIRLowpassHighOrderGeneralMethod (int type, FloatType frequency, double sampleRate,
290  FloatType normalisedTransitionWidth,
291  FloatType passbandAmplitudedB,
292  FloatType stopbandAmplitudedB);
293  FilterDesign() = delete;
294 };
295 
296 } // namespace juce::dsp
static ReferenceCountedArray< IIRCoefficients > designIIRLowpassHighOrderButterworthMethod(FloatType frequency, double sampleRate, FloatType normalisedTransitionWidth, FloatType passbandAmplitudedB, FloatType stopbandAmplitudedB)
static FIRCoefficientsPtr designFIRLowpassLeastSquaresMethod(FloatType frequency, double sampleRate, size_t order, FloatType normalisedTransitionWidth, FloatType stopBandWeight)
static FIRCoefficientsPtr designFIRLowpassKaiserMethod(FloatType frequency, double sampleRate, FloatType normalisedTransitionWidth, FloatType amplitudedB)
static IIRPolyphaseAllpassStructure designIIRLowpassHalfBandPolyphaseAllpassMethod(FloatType normalisedTransitionWidth, FloatType stopbandAmplitudedB)
static ReferenceCountedArray< IIRCoefficients > designIIRLowpassHighOrderChebyshev1Method(FloatType frequency, double sampleRate, FloatType normalisedTransitionWidth, FloatType passbandAmplitudedB, FloatType stopbandAmplitudedB)
static ReferenceCountedArray< IIRCoefficients > designIIRHighpassHighOrderButterworthMethod(FloatType frequency, double sampleRate, int order)
static FIRCoefficientsPtr designFIRLowpassTransitionMethod(FloatType frequency, double sampleRate, size_t order, FloatType normalisedTransitionWidth, FloatType spline)
static ReferenceCountedArray< IIRCoefficients > designIIRLowpassHighOrderChebyshev2Method(FloatType frequency, double sampleRate, FloatType normalisedTransitionWidth, FloatType passbandAmplitudedB, FloatType stopbandAmplitudedB)
static ReferenceCountedArray< IIRCoefficients > designIIRLowpassHighOrderEllipticMethod(FloatType frequency, double sampleRate, FloatType normalisedTransitionWidth, FloatType passbandAmplitudedB, FloatType stopbandAmplitudedB)
static FIRCoefficientsPtr designFIRLowpassHalfBandEquirippleMethod(FloatType normalisedTransitionWidth, FloatType amplitudedB)
static FIRCoefficientsPtr designFIRLowpassWindowMethod(FloatType frequency, double sampleRate, size_t order, WindowingMethod type, FloatType beta=static_cast< FloatType >(2))