LMMS
Loading...
Searching...
No Matches
juce_LinkwitzRileyFilter.h
Go to the documentation of this file.
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
26namespace juce
27{
28namespace dsp
29{
30
37
49template <typename SampleType>
51{
52public:
53 //==============================================================================
55
56 //==============================================================================
59
60 //==============================================================================
62 void setType (Type newType);
63
65 void setCutoffFrequency (SampleType newCutoffFrequencyHz);
66
67 //==============================================================================
70
73
74 //==============================================================================
76 void prepare (const ProcessSpec& spec);
77
79 void reset();
80
81 //==============================================================================
83 template <typename ProcessContext>
84 void process (const ProcessContext& context) noexcept
85 {
86 const auto& inputBlock = context.getInputBlock();
87 auto& outputBlock = context.getOutputBlock();
88 const auto numChannels = outputBlock.getNumChannels();
89 const auto numSamples = outputBlock.getNumSamples();
90
91 jassert (inputBlock.getNumChannels() <= s1.size());
92 jassert (inputBlock.getNumChannels() == numChannels);
93 jassert (inputBlock.getNumSamples() == numSamples);
94
95 if (context.isBypassed)
96 {
97 outputBlock.copyFrom (inputBlock);
98 return;
99 }
100
101 for (size_t channel = 0; channel < numChannels; ++channel)
102 {
103 auto* inputSamples = inputBlock.getChannelPointer (channel);
104 auto* outputSamples = outputBlock.getChannelPointer (channel);
105
106 for (size_t i = 0; i < numSamples; ++i)
107 outputSamples[i] = processSample ((int) channel, inputSamples[i]);
108 }
109
110 #if JUCE_DSP_ENABLE_SNAP_TO_ZERO
111 snapToZero();
112 #endif
113 }
114
116 SampleType processSample (int channel, SampleType inputValue);
117
121 void processSample (int channel, SampleType inputValue, SampleType &outputLow, SampleType &outputHigh);
122
127 void snapToZero() noexcept;
128
129private:
130 //==============================================================================
131 void update();
132
133 //==============================================================================
134 SampleType g, R2, h;
135 std::vector<SampleType> s1, s2, s3, s4;
136
137 double sampleRate = 44100.0;
138 SampleType cutoffFrequency = 2000.0;
139 Type filterType = Type::lowpass;
140};
141
142} // namespace dsp
143} // namespace juce
#define noexcept
Definition DistrhoDefines.h:72
Definition allpass.h:12
void setType(Type newType)
Definition juce_LinkwitzRileyFilter.cpp:40
std::vector< SampleType > s2
Definition juce_LinkwitzRileyFilter.h:135
void process(const ProcessContext &context) noexcept
Definition juce_LinkwitzRileyFilter.h:84
SampleType h
Definition juce_LinkwitzRileyFilter.h:134
SampleType R2
Definition juce_LinkwitzRileyFilter.h:134
LinkwitzRileyFilter()
Definition juce_LinkwitzRileyFilter.cpp:33
SampleType getCutoffFrequency() const noexcept
Definition juce_LinkwitzRileyFilter.h:72
SampleType processSample(int channel, SampleType inputValue)
Definition juce_LinkwitzRileyFilter.cpp:89
std::vector< SampleType > s3
Definition juce_LinkwitzRileyFilter.h:135
std::vector< SampleType > s1
Definition juce_LinkwitzRileyFilter.h:135
SampleType cutoffFrequency
Definition juce_LinkwitzRileyFilter.h:138
Type filterType
Definition juce_LinkwitzRileyFilter.h:139
std::vector< SampleType > s4
Definition juce_LinkwitzRileyFilter.h:135
void setCutoffFrequency(SampleType newCutoffFrequencyHz)
Definition juce_LinkwitzRileyFilter.cpp:46
SampleType g
Definition juce_LinkwitzRileyFilter.h:134
Type getType() const noexcept
Definition juce_LinkwitzRileyFilter.h:69
void snapToZero() noexcept
Definition juce_LinkwitzRileyFilter.cpp:80
double sampleRate
Definition juce_LinkwitzRileyFilter.h:137
LinkwitzRileyFilterType Type
Definition juce_LinkwitzRileyFilter.h:54
register unsigned i
Definition inflate.c:1575
#define jassert(expression)
Definition juce_AudioBlock.h:29
@ highpass
Definition juce_FirstOrderTPTFilter.h:34
@ lowpass
Definition juce_FirstOrderTPTFilter.h:33
LinkwitzRileyFilterType
Definition juce_LinkwitzRileyFilter.h:32
Definition carla_juce.cpp:31
Definition juce_Uuid.h:141
Definition juce_ProcessContext.h:38
#define const
Definition zconf.h:137