OpenShot Library | OpenShotAudio 0.2.2
juce_dsp/processors/juce_Reverb.h
1
2/** @weakgroup juce_dsp-processors
3 * @{
4 */
5/*
6 ==============================================================================
7
8 This file is part of the JUCE library.
9 Copyright (c) 2017 - ROLI Ltd.
10
11 JUCE is an open source library subject to commercial or open-source
12 licensing.
13
14 By using JUCE, you agree to the terms of both the JUCE 5 End-User License
15 Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
16 27th April 2017).
17
18 End User License Agreement: www.juce.com/juce-5-licence
19 Privacy Policy: www.juce.com/juce-5-privacy-policy
20
21 Or: You may also use this code under the terms of the GPL v3 (see
22 www.gnu.org/licenses).
23
24 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
25 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
26 DISCLAIMED.
27
28 ==============================================================================
29*/
30
31namespace juce
32{
33namespace dsp
34{
35
36/**
37 Processor wrapper around juce::Reverb for easy integration into ProcessorChain.
38
39 @tags{DSP}
40*/
41class Reverb
42{
43public:
44 //==============================================================================
45 /** Creates an uninitialised Reverb processor. Call prepare() before first use. */
46 Reverb() = default;
47
48 //==============================================================================
50
51 /** Returns the reverb's current parameters. */
52 const Parameters& getParameters() const noexcept { return reverb.getParameters(); }
53
54 /** Applies a new set of parameters to the reverb.
55 Note that this doesn't attempt to lock the reverb, so if you call this in parallel with
56 the process method, you may get artifacts.
57 */
58 void setParameters (const Parameters& newParams) { reverb.setParameters (newParams); }
59
60 /** Returns true if the reverb is enabled. */
61 bool isEnabled() const noexcept { return enabled; }
62
63 /** Enables/disables the reverb. */
64 void setEnabled (bool newValue) noexcept { enabled = newValue; }
65
66 //==============================================================================
67 /** Initialises the reverb. */
69 {
70 reverb.setSampleRate (spec.sampleRate);
71 }
72
73 /** Resets the reverb's internal state. */
74 void reset() noexcept
75 {
76 reverb.reset();
77 }
78
79 //==============================================================================
80 /** Applies the reverb to a mono or stereo buffer. */
81 template <typename ProcessContext>
82 void process (const ProcessContext& context) noexcept
83 {
84 const auto& inputBlock = context.getInputBlock();
85 auto& outputBlock = context.getOutputBlock();
86 const auto numInChannels = inputBlock.getNumChannels();
87 const auto numOutChannels = outputBlock.getNumChannels();
88 const auto numSamples = outputBlock.getNumSamples();
89
90 jassert (inputBlock.getNumSamples() == numSamples);
91
92 outputBlock.copyFrom (inputBlock);
93
94 if (! enabled || context.isBypassed)
95 return;
96
97 if (numInChannels == 1 && numOutChannels == 1)
98 {
99 reverb.processMono (outputBlock.getChannelPointer (0), (int) numSamples);
100 }
101 else if (numInChannels == 2 && numOutChannels == 2)
102 {
103 reverb.processStereo (outputBlock.getChannelPointer (0),
104 outputBlock.getChannelPointer (1),
105 (int) numSamples);
106 }
107 else
108 {
109 jassertfalse; // invalid channel configuration
110 }
111 }
112
113private:
114 //==============================================================================
115 juce::Reverb reverb;
116 bool enabled = true;
117};
118
119} // namespace dsp
120} // namespace juce
121
122/** @}*/
Performs a simple reverb effect on a stream of audio data.
void processMono(float *const samples, const int numSamples) noexcept
Applies the reverb to a single mono channel of audio data.
void reset()
Clears the reverb's buffers.
void processStereo(float *const left, float *const right, const int numSamples) noexcept
Applies the reverb to two stereo channels of audio data.
void setParameters(const Parameters &newParams)
Applies a new set of parameters to the reverb.
const Parameters & getParameters() const noexcept
Returns the reverb's current parameters.
void setSampleRate(const double sampleRate)
Sets the sample rate that will be used for the reverb.
Processor wrapper around juce::Reverb for easy integration into ProcessorChain.
const Parameters & getParameters() const noexcept
Returns the reverb's current parameters.
void process(const ProcessContext &context) noexcept
Applies the reverb to a mono or stereo buffer.
bool isEnabled() const noexcept
Returns true if the reverb is enabled.
Reverb()=default
Creates an uninitialised Reverb processor.
void setEnabled(bool newValue) noexcept
Enables/disables the reverb.
void setParameters(const Parameters &newParams)
Applies a new set of parameters to the reverb.
void reset() noexcept
Resets the reverb's internal state.
void prepare(const juce::dsp::ProcessSpec &spec)
Initialises the reverb.
Holds the parameters being used by a Reverb object.
double sampleRate
The sample rate that will be used for the data that is sent to the processor.
This structure is passed into a DSP algorithm's prepare() method, and contains information about vari...