JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_Limiter.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::dsp
27{
28
35template <typename SampleType>
37{
38public:
39 //==============================================================================
41 Limiter() = default;
42
43 //==============================================================================
45 void setThreshold (SampleType newThreshold);
46
48 void setRelease (SampleType newRelease);
49
50 //==============================================================================
52 void prepare (const ProcessSpec& spec);
53
55 void reset();
56
57 //==============================================================================
59 template <typename ProcessContext>
60 void process (const ProcessContext& context) noexcept
61 {
62 const auto& inputBlock = context.getInputBlock();
63 auto& outputBlock = context.getOutputBlock();
64 const auto numChannels = outputBlock.getNumChannels();
65 const auto numSamples = outputBlock.getNumSamples();
66
67 jassert (inputBlock.getNumChannels() == numChannels);
68 jassert (inputBlock.getNumSamples() == numSamples);
69
70 if (context.isBypassed)
71 {
72 outputBlock.copyFrom (inputBlock);
73 return;
74 }
75
76 firstStageCompressor.process (context);
77
79 secondStageCompressor.process (secondContext);
80
81 outputBlock.multiplyBy (outputVolume);
82
83 for (size_t channel = 0; channel < numChannels; ++channel)
84 {
85 FloatVectorOperations::clip (outputBlock.getChannelPointer (channel), outputBlock.getChannelPointer (channel),
86 (SampleType) -1.0, (SampleType) 1.0, (int) numSamples);
87 }
88 }
89
90private:
91 //==============================================================================
92 void update();
93
94 //==============================================================================
95 Compressor<SampleType> firstStageCompressor, secondStageCompressor;
97
98 double sampleRate = 44100.0;
99 SampleType thresholddB = -10.0, releaseTime = 100.0;
100};
101
102} // namespace juce::dsp
A utility class for values that need smoothing to avoid audio glitches.
A simple compressor with standard threshold, ratio, attack time and release time controls.
A simple limiter with standard threshold and release time controls, featuring two compressors and a h...
void process(const ProcessContext &context) noexcept
Processes the input and output samples supplied in the processing context.
void setThreshold(SampleType newThreshold)
Sets the threshold in dB of the limiter.
void prepare(const ProcessSpec &spec)
Initialises the processor.
void setRelease(SampleType newRelease)
Sets the release time in milliseconds of the limiter.
Limiter()=default
Constructor.
void reset()
Resets the internal state variables of the processor.
#define jassert(expression)
Platform-independent assertion macro.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
This structure is passed into a DSP algorithm's prepare() method, and contains information about vari...