leaf-reverb.h
1 /*==============================================================================
2 
3  leaf-reverb.h
4  Created: 20 Jan 2017 12:02:04pm
5  Author: Michael R Mulshine
6 
7  ==============================================================================*/
8 
9 #ifndef LEAF_REVERB_H_INCLUDED
10 #define LEAF_REVERB_H_INCLUDED
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16  //==============================================================================
17 
18 #include "leaf-global.h"
19 #include "leaf-math.h"
20 #include "leaf-mempool.h"
21 #include "leaf-delay.h"
22 #include "leaf-filters.h"
23 #include "leaf-oscillators.h"
24 
33  //==============================================================================
34 
73  typedef struct _tPRCReverb
74  {
75 
76  tMempool mempool;
77 
78  float mix, t60;
79 
80  float inv_441;
81 
82  tDelay allpassDelays[2];
83  tDelay combDelay;
84  float allpassCoeff;
85  float combCoeff;
86 
87  float lastIn, lastOut;
88  } _tPRCReverb;
89 
90  typedef _tPRCReverb* tPRCReverb;
91 
92  void tPRCReverb_init (tPRCReverb* const, float t60, LEAF* const leaf);
93  void tPRCReverb_initToPool (tPRCReverb* const, float t60, tMempool* const);
94  void tPRCReverb_free (tPRCReverb* const);
95 
96  void tPRCReverb_clear (tPRCReverb* const);
97  float tPRCReverb_tick (tPRCReverb* const, float input);
98  void tPRCReverb_setT60 (tPRCReverb* const, float t60);
99  void tPRCReverb_setMix (tPRCReverb* const, float mix);
100 
101  //==============================================================================
102 
145  typedef struct _tNReverb
146  {
147 
148  tMempool mempool;
149 
150  float mix, t60;
151 
152  float inv_sr, inv_441;
153 
154  tLinearDelay allpassDelays[8];
155  tLinearDelay combDelays[6];
156  float allpassCoeff;
157  float combCoeffs[6];
158  float lowpassState;
159 
160  float lastIn, lastOut;
161  } _tNReverb;
162 
163  typedef _tNReverb* tNReverb;
164 
165  void tNReverb_init (tNReverb* const, float t60, LEAF* const leaf);
166  void tNReverb_initToPool (tNReverb* const, float t60, tMempool* const);
167  void tNReverb_free (tNReverb* const);
168 
169  void tNReverb_clear (tNReverb* const);
170  float tNReverb_tick (tNReverb* const, float input);
171  void tNReverb_tickStereo (tNReverb* const rev, float input, float* output);
172  void tNReverb_setT60 (tNReverb* const, float t60);
173  void tNReverb_setMix (tNReverb* const, float mix);
174 
175  //==============================================================================
176 
243  typedef struct _tDattorroReverb
244  {
245 
246  tMempool mempool;
247 
248  float predelay;
249  float input_filter;
250  float feedback_filter;
251  float feedback_gain;
252  float mix;
253  uint32_t frozen;
254 
255  float size, size_max, t;
256 
257  float f1_delay_2_last,
258  f2_delay_2_last;
259 
260  float f1_last,
261  f2_last;
262 
263  // INPUT
264  tTapeDelay in_delay;
265  tOnePole in_filter;
266  tAllpass in_allpass[4];
267 
268  // FEEDBACK 1
269  tAllpass f1_allpass;
270  tTapeDelay f1_delay_1;
271  tOnePole f1_filter;
272  tTapeDelay f1_delay_2;
273  tTapeDelay f1_delay_3;
274  tHighpass f1_hp;
275 
276  tCycle f1_lfo;
277 
278  // FEEDBACK 2
279  tAllpass f2_allpass;
280  tTapeDelay f2_delay_1;
281  tOnePole f2_filter;
282  tTapeDelay f2_delay_2;
283  tTapeDelay f2_delay_3;
284  tHighpass f2_hp;
285 
286  tCycle f2_lfo;
287  } _tDattorroReverb;
288 
289  typedef _tDattorroReverb* tDattorroReverb;
290 
291  void tDattorroReverb_init (tDattorroReverb* const, LEAF* const leaf);
292  void tDattorroReverb_initToPool (tDattorroReverb* const, tMempool* const);
293  void tDattorroReverb_free (tDattorroReverb* const);
294 
295  void tDattorroReverb_clear (tDattorroReverb* const);
296  float tDattorroReverb_tick (tDattorroReverb* const, float input);
297  void tDattorroReverb_tickStereo (tDattorroReverb* const rev, float input, float* output);
298  void tDattorroReverb_setMix (tDattorroReverb* const, float mix);
299  void tDattorroReverb_setFreeze (tDattorroReverb* const rev, uint32_t freeze);
300  void tDattorroReverb_setHP (tDattorroReverb* const, float freq);
301  void tDattorroReverb_setSize (tDattorroReverb* const, float size);
302  void tDattorroReverb_setInputDelay (tDattorroReverb* const, float preDelay);
303  void tDattorroReverb_setInputFilter (tDattorroReverb* const, float freq);
304  void tDattorroReverb_setFeedbackFilter (tDattorroReverb* const, float freq);
305  void tDattorroReverb_setFeedbackGain (tDattorroReverb* const, float gain);
306 
307 #ifdef __cplusplus
308 }
309 #endif
310 
311 #endif // LEAF_REVERB_H_INCLUDED
312 
313 //==============================================================================
314 
tDattorroReverb_tickStereo
void tDattorroReverb_tickStereo(tDattorroReverb *const rev, float input, float *output)
Definition: leaf-reverb.c:607
tPRCReverb_tick
float tPRCReverb_tick(tPRCReverb *const, float input)
Definition: leaf-reverb.c:104
tDattorroReverb_setMix
void tDattorroReverb_setMix(tDattorroReverb *const, float mix)
Definition: leaf-reverb.c:727
tDattorroReverb_free
void tDattorroReverb_free(tDattorroReverb *const)
Free a tDattorroReverb from its mempool.
Definition: leaf-reverb.c:442
tNReverb_setT60
void tNReverb_setT60(tNReverb *const, float t60)
Set reverb time in seconds.
Definition: leaf-reverb.c:214
tPRCReverb_init
void tPRCReverb_init(tPRCReverb *const, float t60, LEAF *const leaf)
Initialize a tPRCReverb to the default mempool of a LEAF instance.
Definition: leaf-reverb.c:22
tDattorroReverb_setHP
void tDattorroReverb_setHP(tDattorroReverb *const, float freq)
Definition: leaf-reverb.c:763
tPRCReverb_setMix
void tPRCReverb_setMix(tPRCReverb *const, float mix)
Set mix between dry input and wet output signal.
Definition: leaf-reverb.c:98
tNReverb_tickStereo
void tNReverb_tickStereo(tNReverb *const rev, float input, float *output)
Definition: leaf-reverb.c:305
tDattorroReverb_setSize
void tDattorroReverb_setSize(tDattorroReverb *const, float size)
Definition: leaf-reverb.c:772
tDattorroReverb_tick
float tDattorroReverb_tick(tDattorroReverb *const, float input)
Definition: leaf-reverb.c:497
tNReverb_tick
float tNReverb_tick(tNReverb *const, float input)
Definition: leaf-reverb.c:248
tNReverb_init
void tNReverb_init(tNReverb *const, float t60, LEAF *const leaf)
Initialize a tNReverb to the default mempool of a LEAF instance.
Definition: leaf-reverb.c:147
tDattorroReverb_setInputDelay
void tDattorroReverb_setInputDelay(tDattorroReverb *const, float preDelay)
Definition: leaf-reverb.c:805
tNReverb_free
void tNReverb_free(tNReverb *const)
Free a tNReverb from its mempool.
Definition: leaf-reverb.c:197
tDattorroReverb_initToPool
void tDattorroReverb_initToPool(tDattorroReverb *const, tMempool *const)
Initialize a tDattorroReverb to a specified mempool.
Definition: leaf-reverb.c:378
tDattorroReverb_init
void tDattorroReverb_init(tDattorroReverb *const, LEAF *const leaf)
Initialize a tDattorroReverb to the default mempool of a LEAF instance.
Definition: leaf-reverb.c:373
tNReverb_setMix
void tNReverb_setMix(tNReverb *const, float mix)
Set mix between dry input and wet output signal.
Definition: leaf-reverb.c:227
tDattorroReverb_setFeedbackFilter
void tDattorroReverb_setFeedbackFilter(tDattorroReverb *const, float freq)
Definition: leaf-reverb.c:823
tPRCReverb_initToPool
void tPRCReverb_initToPool(tPRCReverb *const, float t60, tMempool *const)
Initialize a tPRCReverb to a specified mempool.
Definition: leaf-reverb.c:27
tPRCReverb_free
void tPRCReverb_free(tPRCReverb *const)
Free a tPRCReverb from its mempool.
Definition: leaf-reverb.c:66
tDattorroReverb_setFreeze
void tDattorroReverb_setFreeze(tDattorroReverb *const rev, uint32_t freeze)
Definition: leaf-reverb.c:733
tPRCReverb_setT60
void tPRCReverb_setT60(tPRCReverb *const, float t60)
Set reverb time in seconds.
Definition: leaf-reverb.c:85
tDattorroReverb_setFeedbackGain
void tDattorroReverb_setFeedbackGain(tDattorroReverb *const, float gain)
Definition: leaf-reverb.c:833
tNReverb_clear
void tNReverb_clear(tNReverb *const)
Definition: leaf-reverb.c:233
LEAF
Struct for an instance of LEAF.
Definition: leaf-global.h:31
tDattorroReverb_clear
void tDattorroReverb_clear(tDattorroReverb *const)
Definition: leaf-reverb.c:484
tPRCReverb_clear
void tPRCReverb_clear(tPRCReverb *const)
tDattorroReverb_setInputFilter
void tDattorroReverb_setInputFilter(tDattorroReverb *const, float freq)
Definition: leaf-reverb.c:814
tNReverb_initToPool
void tNReverb_initToPool(tNReverb *const, float t60, tMempool *const)
Initialize a tNReverb to a specified mempool.
Definition: leaf-reverb.c:152