quantumVERB  1.0.0
A FOSS convolution reverb plugin
IRPipeline.h
1 /*
2  ==============================================================================
3 
4  IRPipeline.h
5 
6  ==============================================================================
7 */
8 
9 #pragma once
10 
11 #include "Task.h"
12 
13 #include "Equalizer.h"
14 #include "Gain.h"
15 #include "IRBank.h"
16 #include "PreDelay.h"
17 #include "TimeStretch.h"
18 
19 #include <array>
20 #include <mutex>
21 #include <string>
22 
23 namespace reverb
24 {
25 
26  //==============================================================================
27  /**
28  * A pipeline implementing various transformation steps that are applied to impulse responses.
29  * This pipeline is executed only as needed (i.e. when a new IR is requested or when one of
30  * its parameters is changed). Therefore, it is not part of the critical path (its speed
31  * does not have a huge impact on plugin performance).
32  */
33  class IRPipeline : public Task
34  {
35  public:
36  //==============================================================================
37  IRPipeline(juce::AudioProcessor * processor, int channelIdx);
38 
39  //==============================================================================
40  using Ptr = std::shared_ptr<IRPipeline>;
41 
42  //==============================================================================
43  virtual void updateParams(const juce::AudioProcessorValueTreeState& params,
44  const juce::String& = "") override;
45 
46  virtual AudioBlock exec(AudioBlock = AudioBlock()) override;
47 
48  //==============================================================================
49  virtual bool needsToRun() const override;
50 
51  //==============================================================================
52  virtual void updateSampleRate(double sr) override;
53 
54  //==============================================================================
56 
57  static constexpr float MAX_IR_INTENSITY = 0.5f;
58 
59  protected:
60  //==============================================================================
61  Equalizer::Ptr equalizer;
62  TimeStretch::Ptr timeStretch;
63  Gain::Ptr gain;
64  PreDelay::Ptr preDelay;
65 
66  //==============================================================================
67  double lastSampleRate = 0;
68 
69  //==============================================================================
70  int channelIdx;
71 
72  //==============================================================================
73  std::string irNameOrFilePath = "";
74 
75  juce::AudioSampleBuffer ir;
76 
77  void loadIRFromBank(const std::string& irBuffer);
78  void loadIRFromDisk(const std::string& irFilePath);
79  };
80 
81 }
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 void updateSampleRate(double sr) override
Update sample rate for pipeline and child tasks.
Definition: IRPipeline.cpp:89
IRPipeline(juce::AudioProcessor *processor, int channelIdx)
Constructs an IRPipeline object associated with an AudioProcessor.
Definition: IRPipeline.cpp:29
AudioBlock reloadIR()
Loads an impulse response from disk or IR bank.
Definition: IRPipeline.cpp:194
void loadIRFromDisk(const std::string &irFilePath)
Loads an impulse response from a file (.WAV or .AIFF) to internal representation. ...
Definition: IRPipeline.cpp:261
void loadIRFromBank(const std::string &irBuffer)
Loads an impulse response from provided IR bank.
Definition: IRPipeline.cpp:227
virtual void updateParams(const juce::AudioProcessorValueTreeState &params, const juce::String &="") override
Updates parameters from processor parameter tree.
Definition: IRPipeline.cpp:46
virtual bool needsToRun() const override
Check if this or any subtasks needs to be executed.
Definition: IRPipeline.cpp:112
virtual AudioBlock exec(AudioBlock=AudioBlock()) override
Manipulate the input IR file and place it in the given buffer.
Definition: IRPipeline.cpp:154