OpenShot Audio Library | OpenShotAudio  0.6.0
juce_dsp/widgets/juce_Reverb.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  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 
26 namespace juce::dsp
27 {
28 
34 class Reverb
35 {
36 public:
37  //==============================================================================
39  Reverb() = default;
40 
41  //==============================================================================
43 
45  const Parameters& getParameters() const noexcept { return reverb.getParameters(); }
46 
51  void setParameters (const Parameters& newParams) { reverb.setParameters (newParams); }
52 
54  bool isEnabled() const noexcept { return enabled; }
55 
57  void setEnabled (bool newValue) noexcept { enabled = newValue; }
58 
59  //==============================================================================
61  void prepare (const ProcessSpec& spec)
62  {
63  reverb.setSampleRate (spec.sampleRate);
64  }
65 
67  void reset() noexcept
68  {
69  reverb.reset();
70  }
71 
72  //==============================================================================
74  template <typename ProcessContext>
75  void process (const ProcessContext& context) noexcept
76  {
77  const auto& inputBlock = context.getInputBlock();
78  auto& outputBlock = context.getOutputBlock();
79  const auto numInChannels = inputBlock.getNumChannels();
80  const auto numOutChannels = outputBlock.getNumChannels();
81  const auto numSamples = outputBlock.getNumSamples();
82 
83  jassert (inputBlock.getNumSamples() == numSamples);
84 
85  outputBlock.copyFrom (inputBlock);
86 
87  if (! enabled || context.isBypassed)
88  return;
89 
90  if (numInChannels == 1 && numOutChannels == 1)
91  {
92  reverb.processMono (outputBlock.getChannelPointer (0), (int) numSamples);
93  }
94  else if (numInChannels == 2 && numOutChannels == 2)
95  {
96  reverb.processStereo (outputBlock.getChannelPointer (0),
97  outputBlock.getChannelPointer (1),
98  (int) numSamples);
99  }
100  else
101  {
102  jassertfalse; // invalid channel configuration
103  }
104  }
105 
106 private:
107  //==============================================================================
108  juce::Reverb reverb;
109  bool enabled = true;
110 };
111 
112 } // namespace juce::dsp
void processMono(float *const samples, const int numSamples) noexcept
void processStereo(float *const left, float *const right, const int numSamples) noexcept
void setParameters(const Parameters &newParams)
void setSampleRate(const double sampleRate)
const Parameters & getParameters() const noexcept
void process(const ProcessContext &context) noexcept
void prepare(const ProcessSpec &spec)
bool isEnabled() const noexcept
const Parameters & getParameters() const noexcept
void setEnabled(bool newValue) noexcept
void setParameters(const Parameters &newParams)