quantumVERB  1.0.0
A FOSS convolution reverb plugin
Mixer.cpp
1 /*
2  ==============================================================================
3 
4  Mixer.cpp
5  Created: 20 Jan 2018 5:00:24pm
6  Author: Eric Seguin
7 
8  ==============================================================================
9 */
10 
11 #include "Mixer.h"
12 
13 #include "Logger.h"
14 
15 namespace reverb
16 {
17 
18  //==============================================================================
19  /**
20  * @brief Constructor. Creates a Mixer object.
21  *
22  * Creates a Mixer object associated to an AudioProcessor.
23  *
24  * @param [in] processor Pointer to main processor
25  */
26  Mixer::Mixer(juce::AudioProcessor * processor)
27  : Task(processor)
28  {
29  }
30 
31  /**
32  * @brief Updates parameters from processor parameter tree
33  *
34  * @param [in] params Processor parameter tree
35  * @param [in] blockId ID of block whose paramters should be checked
36  */
37  void Mixer::updateParams(const juce::AudioProcessorValueTreeState& params,
38  const juce::String& blockId)
39  {
40  float _wetRatio = getParam(params, blockId);
41 
42  if (wetRatio != _wetRatio)
43  {
44  wetRatio = _wetRatio;
45  mustExec = true;
46  }
47  }
48 
49  //==============================================================================
50  /**
51  * @brief Mix the wet and dry sound according to a proportionality parameter
52  *
53  * Mixing the wet sound passed as an argument with the dry sound content in the
54  dryAudio buffer.
55  *
56  * @param [in,out] wetAudio Buffer containing the wet audio signal
57  */
59  {
60  wetAudio.multiply(wetRatio);
61  wetAudio.addWithMultiply(dryAudioCopy, 1 - wetRatio);
62 
63  // Reset mustExec flag
64  mustExec = false;
65 
66  return wetAudio;
67  }
68 
69  //==============================================================================
70  /**
71  * @brief loads the dry signal into the dryAudio variable
72  *
73  * @param [in,out] dryAudio Buffer containing the dry signal
74  */
75  void Mixer::loadDry(AudioBlock dryAudio)
76  {
77  dryAudioCopy.clear();
78  dryAudioCopy.setSize(1, (int)dryAudio.getNumSamples());
79 
80  dryAudioCopy.copyFrom(0, 0,
81  dryAudio.getChannelPointer(0),
82  (int)dryAudio.getNumSamples());
83  }
84 
85 }
Mixer(juce::AudioProcessor *processor)
Constructor. Creates a Mixer object.
Definition: Mixer.cpp:26
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
void loadDry(AudioBlock audio)
loads the dry signal into the dryAudio variable
Definition: Mixer.cpp:75
virtual AudioBlock exec(AudioBlock wetAudio) override
Mix the wet and dry sound according to a proportionality parameter.
Definition: Mixer.cpp:58
virtual void updateParams(const juce::AudioProcessorValueTreeState &params, const juce::String &blockId) override
Updates parameters from processor parameter tree.
Definition: Mixer.cpp:37