ofxPDSP
Delay.h
1 
2 // Delay.h
3 // ofxPDSP
4 // Nicola Pisanti, MIT License, 2016 - 2018
5 
6 
7 #ifndef PDSP_DELAYS_DAMPEDDELAY_H_INCLUDED
8 #define PDSP_DELAYS_DAMPEDDELAY_H_INCLUDED
9 
10 
11 #include "../pdspCore.h"
12 
13 
14 namespace pdsp{
15 
21 class Delay : public Unit {
22 public:
23 
24  Delay();
25 
26  Delay( float timeMs);
27 
28 
35  Patchable& set( float timeMs, float feedback=0.0f, float damping=0.0f);
36 
41 
45  Patchable& in_time();
46 
51 
56 
61 
66  void setMaxTime(float timeMs);
67 
68 
72  float meter_time() const;
73 
74 
75 private:
76  void process(int bufferSize) noexcept override;
77 
78  void prepareUnit( int expectedBufferSize, double sampleRate ) override;
79  void releaseResources() override;
80  void initDelayBuffer();
81 
82  InputNode input;
83  InputNode in_time_ms;
84  InputNode input_damping;
85  InputNode input_feedback;
86 
87  OutputNode output;
88 
89  float msToSamplesMultiplier;
90  float* delayBuffer;
91  float maxDelayTimeMs;
92  float sampleRate;
93  int maxDelayTimeSamples;
94  float maxDelayTimeSamples_f;
95 
96  float feedback;
97 
98 
99  void setFeedback(float feedback);
100  void setDamping(float hiDamp);
101 
102  template<bool timeChange, bool fbChange, bool dampChange>
103  void process_once(const float* timeBuffer, const float* fbBuffer, const float* dampBuffer )noexcept;
104 
105  template<bool inputAR, bool timeAR, bool fbAR, bool dampAR>
106  void process_audio(const float* inputBuffer, const float* timeBuffer, const float* fbBuffer, const float* dampBuffer, int bufferSize )noexcept;
107 
108  void updateBoundaries();
109 
110  int writeIndex;
111  float readIndex;
112 
113  bool boundaries;
114 
115  float g;
116  float gLPF;
117  float z1;
118 
119  std::atomic<float> timeMeter;
120 };
121 
122 } // pdsp namespace ned
123 
124 
125 #endif // PDSP_DELAYS_DAMPEDDELAY_H_INCLUDED
Patchable & in_signal()
Sets "signal" as selected input and returns this Unit ready to be patched. This is the default input...
Definition: Delay.cpp:51
Patchable & in_time()
Sets "time" as selected input and returns this Unit ready to be patched. This is the delay time and o...
Definition: Delay.cpp:59
Digital Delay with a low pass filter in the feedback path.
Definition: Delay.h:21
Patchable & in_feedback()
Sets "feedback" as selected output and returns this Unit ready to be patched. This input is the feedb...
Definition: Delay.cpp:63
Patchable & out_signal()
Sets "signal" as selected output and returns this Unit ready to be patched. This is the default outpu...
Definition: Delay.cpp:55
Abstract class for implementing Units.
Definition: BasicNodes.h:223
float meter_time() const
returns the time value at the start of the last processed buffer. This method is thread-safe.
Definition: Delay.cpp:47
Patchable & in_damping()
Sets "damping" as selected output and returns this Unit ready to be patched. This input control how m...
Definition: Delay.cpp:67
Abstract class for implementing Units and Modules.
Definition: BasicNodes.h:82
Input of a Unit, process all the connected Outputs and sum them. Has an internal variable state...
Definition: BasicNodes.h:536
Thread-safe value control with smoothing.
Definition: SequencerBridge.h:11
Output of a Unit, contains a buffer of rendered floats and has a variable state flag.
Definition: BasicNodes.h:354
void setMaxTime(float timeMs)
sets maximum delay time of this delay, The old delay buffer will be deleted and a new will be created...
Definition: Delay.cpp:92