OpenShot Audio Library | OpenShotAudio
0.4.0
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) 2022 - Raw Material Software Limited
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
23
namespace
juce
24
{
25
26
class
IIRFilter;
27
28
//==============================================================================
36
class
JUCE_API
IIRCoefficients
37
{
38
public
:
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
;
54
IIRCoefficients
& operator= (
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
//==============================================================================
156
template
<
typename
Mutex>
157
class
JUCE_API
IIRFilterBase
158
{
159
public
:
160
//==============================================================================
167
IIRFilterBase
() noexcept;
168
170
IIRFilterBase
(const
IIRFilterBase
&) noexcept;
171
172
//==============================================================================
174
void
makeInactive() noexcept;
175
177
void
setCoefficients (const
IIRCoefficients
& newCoefficients) noexcept;
178
180
IIRCoefficients
getCoefficients() const noexcept {
return
coefficients; }
181
182
//==============================================================================
189
void
reset() noexcept;
190
192
void
processSamples (
float
* samples,
int
numSamples) noexcept;
193
199
float
processSingleSampleRaw (
float
sample) noexcept;
200
201
protected:
202
//==============================================================================
203
Mutex processLock;
204
IIRCoefficients
coefficients;
205
float
v1 = 0, v2 = 0;
206
bool
active = false;
207
208
// The exact meaning of an assignment operator would be ambiguous since the filters are
209
// stateful. If you want to copy the coefficients, then just use setCoefficients().
210
IIRFilter
& operator= (const
IIRFilter
&) = delete;
211
212
JUCE_LEAK_DETECTOR (
IIRFilter
)
213
};
214
231
class
IIRFilter
: public
IIRFilterBase
<
SpinLock
>
232
{
233
public
:
234
using
IIRFilterBase::IIRFilterBase;
235
};
236
248
class
SingleThreadedIIRFilter
:
public
IIRFilterBase
<DummyCriticalSection>
249
{
250
public
:
251
using
IIRFilterBase::IIRFilterBase;
252
};
253
254
}
// namespace juce
juce::IIRCoefficients
Definition
juce_audio_basics/utilities/juce_IIRFilter.h:37
juce::IIRFilterBase
Definition
juce_audio_basics/utilities/juce_IIRFilter.h:158
juce::IIRFilterBase::IIRFilterBase
IIRFilterBase() noexcept
juce::IIRFilter
Definition
juce_audio_basics/utilities/juce_IIRFilter.h:232
juce::SingleThreadedIIRFilter
Definition
juce_audio_basics/utilities/juce_IIRFilter.h:249
juce::SpinLock
Definition
juce_SpinLock.h:42
JuceLibraryCode
modules
juce_audio_basics
utilities
juce_IIRFilter.h
Generated by
1.12.0