quantumVERB  1.0.0
A FOSS convolution reverb plugin
MainPipeline.cpp
1 /*
2  ==============================================================================
3 
4  MainPipeline.cpp
5  Created: 20 Jan 2018 4:57:18pm
6  Author: Eric Seguin
7 
8  ==============================================================================
9 */
10 
11 #include "MainPipeline.h"
12 #include "PluginProcessor.h"
13 
14 namespace reverb
15 {
16 
17  //==============================================================================
18  /**
19  * @brief Constructs a MainPipeline object associated with an AudioProcessor
20  *
21  * Creates a MainPipeline and each of its steps.
22  *
23  * @param [in] processor Pointer to main processor
24  */
25  MainPipeline::MainPipeline(juce::AudioProcessor * processor)
26  : Task(processor)
27  {
28  // Initialise pipeline steps
29  convolution = std::make_shared<Convolution>(processor);
30  gain = std::make_shared<Gain>(processor);
31  dryWetMixer = std::make_shared<Mixer>(processor);
32  }
33 
34  /**
35  * @brief Updates parameters from processor parameter tree
36  *
37  * @param [in] params Processor parameter tree
38  * @param [in] blockId ID of block whose paramters should be checked
39  */
40  void MainPipeline::updateParams(const juce::AudioProcessorValueTreeState& params,
41  const juce::String&)
42  {
43  gain->updateParams(params, AudioProcessor::PID_AUDIO_OUT_GAIN);
44  dryWetMixer->updateParams(params, AudioProcessor::PID_WETRATIO);
45  }
46 
47  //==============================================================================
48  /**
49  * @brief Update sample rate for pipeline and child tasks
50  *
51  * Compares new sample rate with previous value. If different, sets mustExec to
52  * true in order to re-run pipeline for new sample rate. Store new sample rate
53  * value in object.
54  *
55  * @param [in] sr Sample rate
56  */
57  void MainPipeline::updateSampleRate(double sr)
58  {
59  if (sr != sampleRate)
60  {
61  sampleRate = sr;
62  mustExec = true;
63 
64  convolution->updateSampleRate(sr);
65  gain->updateSampleRate(sr);
66  dryWetMixer->updateSampleRate(sr);
67  }
68  }
69 
70  //==============================================================================
71  /**
72  * @brief Apply reverb effect to given audio buffer
73  *
74  * Load original audio buffer into dryWetMixer object, then apply reverb pipeline
75  * steps in series (convolution w/ IR, dry/wet mixing and output attenuation). Output
76  * replaces samples in given audio buffer.
77  *
78  * @param [in,out] audio Audio sample buffer
79  */
81  {
82  dryWetMixer->loadDry(audio);
83 
84  convolution->exec(audio);
85  dryWetMixer->exec(audio);
86  gain->exec(audio);
87 
88  return audio;
89  }
90 
91  //==============================================================================
92  /**
93  * @brief Copy reference to IR buffer
94  *
95  * Calls convolution block's loadIR method to pass along the given audio block
96  *
97  * @param [in] irIn Input IR block
98  */
99  void MainPipeline::loadIR(AudioBlock irIn)
100  {
101  ir = irIn;
102  convolution->loadIR(irIn);
103  }
104 
105 }
float getParam(const juce::AudioProcessorValueTreeState &params, const juce::String &blockId) const
Internal method used to get (and check) a parameter&#39;s value.
Definition: Task.h:111
virtual AudioBlock exec(AudioBlock audio) override
Apply reverb effect to given audio buffer.
virtual void updateSampleRate(double sr) override
Update sample rate for pipeline and child tasks.
MainPipeline(juce::AudioProcessor *processor)
Constructs a MainPipeline object associated with an AudioProcessor.
virtual void updateParams(const juce::AudioProcessorValueTreeState &params, const juce::String &="") override
Updates parameters from processor parameter tree.
void loadIR(AudioBlock irIn)
Copy reference to IR buffer.