quantumVERB  1.0.0
A FOSS convolution reverb plugin
Gain.cpp
1 /*
2  ==============================================================================
3 
4  Gain.cpp
5 
6  ==============================================================================
7 */
8 
9 #include "Gain.h"
10 
11 #include "Logger.h"
12 
13 namespace reverb
14 {
15 
16  //==============================================================================
17  /**
18  * @brief Constructor. Creates a Gain object
19  *
20  * Creates a Gain object associated to an AudioProcessor.
21  *
22  * @param [in] processor Pointer to main processor
23  */
24  Gain::Gain(juce::AudioProcessor * processor)
25  : Task(processor)
26  {
27  }
28 
29  /**
30  * @brief Updates parameters from processor parameter tree
31  *
32  * @param [in] params Processor parameter tree
33  * @param [in] blockId ID of block whose paramters should be checked
34  */
35  void Gain::updateParams(const juce::AudioProcessorValueTreeState& params,
36  const juce::String& blockId)
37  {
38  float _gainFactor = getParam(params, blockId);
39 
40  if (gainFactor != _gainFactor)
41  {
42  gainFactor = _gainFactor;
43  mustExec = true;
44  }
45  }
46 
47  //==============================================================================
48  /**
49  * @brief Apply Gain to input buffer to change volume of signal audio
50  *
51  * Gain to apply to audio buffer is stocked in gainFactor
52  *
53  * @param [in,out] buffer Audio sample buffer to process
54  */
56  {
57  buffer.multiply(gainFactor);
58 
59  // Reset mustExec flag
60  mustExec = false;
61 
62  return buffer;
63  }
64 
65 }
float getParam(const juce::AudioProcessorValueTreeState &params, const juce::String &blockId) const
Internal method used to get (and check) a parameter's value.
Definition: Task.h:111
Gain(juce::AudioProcessor *processor)
Constructor. Creates a Gain object.
Definition: Gain.cpp:24
virtual AudioBlock exec(AudioBlock buffer) override
Apply Gain to input buffer to change volume of signal audio.
Definition: Gain.cpp:55
virtual void updateParams(const juce::AudioProcessorValueTreeState &params, const juce::String &blockId) override
Updates parameters from processor parameter tree.
Definition: Gain.cpp:35