OpenShot Audio Library | OpenShotAudio 0.3.2
Loading...
Searching...
No Matches
juce_audio_basics/utilities/juce_IIRFilter.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2017 - ROLI Ltd.
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26class IIRFilter;
27
28//==============================================================================
36class JUCE_API IIRCoefficients
37{
38public:
39 //==============================================================================
41 IIRCoefficients() noexcept;
42
48 IIRCoefficients (double c1, double c2, double c3,
49 double c4, double c5, double c6) noexcept;
50
52 IIRCoefficients (const IIRCoefficients&) noexcept;
56 ~IIRCoefficients() noexcept;
57
58 //==============================================================================
60 static IIRCoefficients makeLowPass (double sampleRate,
61 double frequency) noexcept;
62
64 static IIRCoefficients makeLowPass (double sampleRate,
65 double frequency,
66 double Q) noexcept;
67
68 //==============================================================================
70 static IIRCoefficients makeHighPass (double sampleRate,
71 double frequency) noexcept;
72
74 static IIRCoefficients makeHighPass (double sampleRate,
75 double frequency,
76 double Q) noexcept;
77
78 //==============================================================================
80 static IIRCoefficients makeBandPass (double sampleRate, double frequency) noexcept;
81
83 static IIRCoefficients makeBandPass (double sampleRate,
84 double frequency,
85 double Q) noexcept;
86
87 //==============================================================================
89 static IIRCoefficients makeNotchFilter (double sampleRate, double frequency) noexcept;
90
92 static IIRCoefficients makeNotchFilter (double sampleRate,
93 double frequency,
94 double Q) noexcept;
95
96 //==============================================================================
98 static IIRCoefficients makeAllPass (double sampleRate, double frequency) noexcept;
99
101 static IIRCoefficients makeAllPass (double sampleRate,
102 double frequency,
103 double Q) noexcept;
104
105 //==============================================================================
112 static IIRCoefficients makeLowShelf (double sampleRate,
113 double cutOffFrequency,
114 double Q,
115 float gainFactor) noexcept;
116
123 static IIRCoefficients makeHighShelf (double sampleRate,
124 double cutOffFrequency,
125 double Q,
126 float gainFactor) noexcept;
127
135 static IIRCoefficients makePeakFilter (double sampleRate,
136 double centreFrequency,
137 double Q,
138 float gainFactor) noexcept;
139
140 //==============================================================================
144 float coefficients[5];
145};
146
147//==============================================================================
156class JUCE_API IIRFilter
157{
158public:
159 //==============================================================================
166 IIRFilter() noexcept;
167
169 IIRFilter (const IIRFilter&) noexcept;
170
172 ~IIRFilter() noexcept;
173
174 //==============================================================================
176 void makeInactive() noexcept;
177
179 void setCoefficients (const IIRCoefficients& newCoefficients) noexcept;
180
183
184 //==============================================================================
191 void reset() noexcept;
192
194 void processSamples (float* samples, int numSamples) noexcept;
195
201 float processSingleSampleRaw (float sample) noexcept;
202
204 //==============================================================================
205 SpinLock processLock;
206 IIRCoefficients coefficients;
207 float v1 = 0, v2 = 0;
208 bool active = false;
209
210 // The exact meaning of an assignment operator would be ambiguous since the filters are
211 // stateful. If you want to copy the coefficients, then just use setCoefficients().
213
214 JUCE_LEAK_DETECTOR (IIRFilter)
215};
216
217} // namespace juce
IIRCoefficients getCoefficients() const noexcept