OpenShot Audio Library | OpenShotAudio  0.3.1
juce_dsp/processors/juce_Reverb.h
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2017 - ROLI Ltd.
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 5 End-User License
11  Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
12  27th April 2017).
13 
14  End User License Agreement: www.juce.com/juce-5-licence
15  Privacy Policy: www.juce.com/juce-5-privacy-policy
16 
17  Or: You may also use this code under the terms of the GPL v3 (see
18  www.gnu.org/licenses).
19 
20  JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
21  EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
22  DISCLAIMED.
23 
24  ==============================================================================
25 */
26 
27 namespace juce
28 {
29 namespace dsp
30 {
31 
37 class Reverb
38 {
39 public:
40  //==============================================================================
42  Reverb() = default;
43 
44  //==============================================================================
46 
48  const Parameters& getParameters() const noexcept { return reverb.getParameters(); }
49 
54  void setParameters (const Parameters& newParams) { reverb.setParameters (newParams); }
55 
57  bool isEnabled() const noexcept { return enabled; }
58 
60  void setEnabled (bool newValue) noexcept { enabled = newValue; }
61 
62  //==============================================================================
64  void prepare (const juce::dsp::ProcessSpec& spec)
65  {
66  reverb.setSampleRate (spec.sampleRate);
67  }
68 
70  void reset() noexcept
71  {
72  reverb.reset();
73  }
74 
75  //==============================================================================
77  template <typename ProcessContext>
78  void process (const ProcessContext& context) noexcept
79  {
80  const auto& inputBlock = context.getInputBlock();
81  auto& outputBlock = context.getOutputBlock();
82  const auto numInChannels = inputBlock.getNumChannels();
83  const auto numOutChannels = outputBlock.getNumChannels();
84  const auto numSamples = outputBlock.getNumSamples();
85 
86  jassert (inputBlock.getNumSamples() == numSamples);
87 
88  outputBlock.copyFrom (inputBlock);
89 
90  if (! enabled || context.isBypassed)
91  return;
92 
93  if (numInChannels == 1 && numOutChannels == 1)
94  {
95  reverb.processMono (outputBlock.getChannelPointer (0), (int) numSamples);
96  }
97  else if (numInChannels == 2 && numOutChannels == 2)
98  {
99  reverb.processStereo (outputBlock.getChannelPointer (0),
100  outputBlock.getChannelPointer (1),
101  (int) numSamples);
102  }
103  else
104  {
105  jassertfalse; // invalid channel configuration
106  }
107  }
108 
109 private:
110  //==============================================================================
111  juce::Reverb reverb;
112  bool enabled = true;
113 };
114 
115 } // namespace dsp
116 } // namespace juce
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
bool isEnabled() const noexcept
const Parameters & getParameters() const noexcept
void setEnabled(bool newValue) noexcept
void setParameters(const Parameters &newParams)
void prepare(const juce::dsp::ProcessSpec &spec)