LMMS
Loading...
Searching...
No Matches
juce_NoiseGate.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
37template <typename SampleType>
39{
40public:
41 //==============================================================================
43 NoiseGate();
44
45 //==============================================================================
47 void setThreshold (SampleType newThreshold);
48
50 void setRatio (SampleType newRatio);
51
53 void setAttack (SampleType newAttack);
54
56 void setRelease (SampleType newRelease);
57
58 //==============================================================================
60 void prepare (const ProcessSpec& spec);
61
63 void reset();
64
65 //==============================================================================
67 template <typename ProcessContext>
68 void process (const ProcessContext& context) noexcept
69 {
70 const auto& inputBlock = context.getInputBlock();
71 auto& outputBlock = context.getOutputBlock();
72 const auto numChannels = outputBlock.getNumChannels();
73 const auto numSamples = outputBlock.getNumSamples();
74
75 jassert (inputBlock.getNumChannels() == numChannels);
76 jassert (inputBlock.getNumSamples() == numSamples);
77
78 if (context.isBypassed)
79 {
80 outputBlock.copyFrom (inputBlock);
81 return;
82 }
83
84 for (size_t channel = 0; channel < numChannels; ++channel)
85 {
86 auto* inputSamples = inputBlock .getChannelPointer (channel);
87 auto* outputSamples = outputBlock.getChannelPointer (channel);
88
89 for (size_t i = 0; i < numSamples; ++i)
90 outputSamples[i] = processSample ((int) channel, inputSamples[i]);
91 }
92 }
93
95 SampleType processSample (int channel, SampleType inputValue);
96
97private:
98 //==============================================================================
99 void update();
100
101 //==============================================================================
104
105 double sampleRate = 44100.0;
106 SampleType thresholddB = -100, ratio = 10.0, attackTime = 1.0, releaseTime = 100.0;
107};
108
109} // namespace dsp
110} // namespace juce
Definition juce_BallisticsFilter.h:46
void prepare(const ProcessSpec &spec)
Definition juce_NoiseGate.cpp:74
SampleType thresholddB
Definition juce_NoiseGate.h:106
SampleType processSample(int channel, SampleType inputValue)
Definition juce_NoiseGate.cpp:97
void setRelease(SampleType newRelease)
Definition juce_NoiseGate.cpp:66
BallisticsFilter< SampleType > RMSFilter
Definition juce_NoiseGate.h:103
SampleType releaseTime
Definition juce_NoiseGate.h:106
void setRatio(SampleType newRatio)
Definition juce_NoiseGate.cpp:50
SampleType thresholdInverse
Definition juce_NoiseGate.h:102
SampleType ratio
Definition juce_NoiseGate.h:106
SampleType attackTime
Definition juce_NoiseGate.h:106
void process(const ProcessContext &context) noexcept
Definition juce_NoiseGate.h:68
BallisticsFilter< SampleType > envelopeFilter
Definition juce_NoiseGate.h:103
double sampleRate
Definition juce_NoiseGate.h:105
SampleType currentRatio
Definition juce_NoiseGate.h:102
SampleType threshold
Definition juce_NoiseGate.h:102
void setAttack(SampleType newAttack)
Definition juce_NoiseGate.cpp:59
void setThreshold(SampleType newThreshold)
Definition juce_NoiseGate.cpp:43
NoiseGate()
Definition juce_NoiseGate.cpp:33
void reset()
Definition juce_NoiseGate.cpp:89
register unsigned i
Definition inflate.c:1575
#define jassert(expression)
Definition juce_AudioBlock.h:29
Definition carla_juce.cpp:31
Definition juce_ProcessContext.h:38