quantumVERB  1.0.0
A FOSS convolution reverb plugin
TimeStretch.h
1 /*
2  ==============================================================================
3 
4  TimeStretch.h
5 
6  ==============================================================================
7 */
8 
9 #pragma once
10 
11 #include "SoundTouch.h"
12 
13 #include "Task.h"
14 
15 namespace reverb
16 {
17 
18  //==============================================================================
19  /**
20  * Implements a time stretching algorithm to manage IR buffer length and sample rate.
21  */
22  class TimeStretch : public Task
23  {
24  public:
25  //==============================================================================
26  TimeStretch(juce::AudioProcessor * processor);
27  ~TimeStretch() = default;
28 
29  //==============================================================================
30  using Ptr = std::shared_ptr<TimeStretch>;
31 
32  //==============================================================================
33  virtual void updateParams(const juce::AudioProcessorValueTreeState& params,
34  const juce::String& blockID) override;
35 
36  virtual AudioBlock exec(AudioBlock ir) override;
37 
38  //==============================================================================
39  void prepareIR(juce::AudioSampleBuffer& ir);
40  int getOutputNumSamples();
41 
42  protected:
43  //==============================================================================
44  static constexpr double MAX_IR_LENGTH_S = 5.0f;
45 
46  float irLengthS = 3.0f;
47 
48  //==============================================================================
49  juce::AudioSampleBuffer irOrig;
50 
51  //==============================================================================
52  std::unique_ptr<soundtouch::SoundTouch> soundtouch;
53  };
54 
55 }
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
void prepareIR(juce::AudioSampleBuffer &ir)
Copies given IR to internal representation and resizes it before processing.
TimeStretch(juce::AudioProcessor *processor)
Constructs a TimeStretch object associated with an AudioProcessor.
Definition: TimeStretch.cpp:28
int getOutputNumSamples()
Returns expected number of samples after processing.
virtual AudioBlock exec(AudioBlock ir) override
Apply time stretching algorithm to input IR buffer to change sample rate.
Definition: TimeStretch.cpp:70
virtual void updateParams(const juce::AudioProcessorValueTreeState &params, const juce::String &blockID) override
Updates parameters from processor parameter tree.
Definition: TimeStretch.cpp:45