Audacity 3.2.0
Classes | Macros | Functions | Variables
Reverb_libSoX.h File Reference
#include <cstring>
#include <cstdlib>
#include <algorithm>
Include dependency graph for Reverb_libSoX.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  fifo_t
 
struct  filter_t
 
struct  one_pole_t
 
struct  filter_array_t
 
struct  reverb_t
 

Macros

#define M_LN10   2.30258509299404568402 /* log_e 10 */
 
#define array_length(a)   (sizeof(a)/sizeof(a[0]))
 
#define dB_to_linear(x)   exp((x) * M_LN10 * 0.05)
 
#define midi_to_freq(n)   (440 * pow(2,((n)-69)/12.))
 
#define FIFO_SIZE_T   size_t
 
#define FIFO_MIN   0x4000
 
#define fifo_read_ptr(f)   fifo_read(f, (FIFO_SIZE_T)0, NULL)
 
#define lsx_zalloc(var, n)   var = (float *)calloc(n, sizeof(*var))
 
#define filter_advance(p)   if (--(p)->ptr < (p)->buffer) (p)->ptr += (p)->size
 
#define filter_delete(p)   free((p)->buffer)
 

Functions

static void fifo_clear (fifo_t *f)
 
static void fifo_clear_and_zero (fifo_t *f)
 
static void * fifo_reserve (fifo_t *f, FIFO_SIZE_T n)
 
static void * fifo_write (fifo_t *f, FIFO_SIZE_T n, void const *data)
 
static void * fifo_read (fifo_t *f, FIFO_SIZE_T n, void *data)
 
static void fifo_delete (fifo_t *f)
 
static void fifo_create (fifo_t *f, FIFO_SIZE_T item_size)
 
static float comb_process (filter_t *p, float const *input, float const *feedback, float const *hf_damping)
 
static float allpass_process (filter_t *p, float const *input)
 
static float one_pole_process (one_pole_t *p, float i0)
 
static void one_pole_init (filter_array_t *p, double rate, double fc_highpass, double fc_lowpass)
 
static void filter_array_allocate (filter_array_t *p, double rate, double scale, double offset)
 
static void filter_t_resize (filter_t *p, size_t newSize)
 
static void filter_array_init (filter_array_t *p, double rate, double scale, double offset)
 
static void filter_array_create (filter_array_t *p, double rate, double scale, double offset)
 
static void filter_array_process (filter_array_t *p, size_t length, float const *input, float *output, float const *feedback, float const *hf_damping, float const *gain)
 
static void filter_array_delete (filter_array_t *p)
 
static void filter_t_resize_resetting (filter_t *p, size_t newSize)
 
static void filter_t_resize_preserving (filter_t *p, size_t newSize)
 
static void reverb_allocate (reverb_t *p, double sample_rate_Hz, size_t buffer_size, float **out)
 
static void reverb_set_simple_params (reverb_t *p, double sample_rate_Hz, double wet_gain_dB, double reverberance, double hf_damping, double tone_low, double tone_high)
 
static void reverb_init (reverb_t *p, double sample_rate_Hz, double wet_gain_dB, double room_scale, double reverberance, double hf_damping, double pre_delay_ms, double stereo_depth, double tone_low, double tone_high)
 
static void reverb_create (reverb_t *p, double sample_rate_Hz, double wet_gain_dB, double room_scale, double reverberance, double hf_damping, double pre_delay_ms, double stereo_depth, double tone_low, double tone_high, size_t buffer_size, float **out)
 
static void reverb_process (reverb_t *p, size_t length)
 
static void reverb_delete (reverb_t *p)
 
static void reverb_clear (reverb_t *p)
 

Variables

static const size_t comb_lengths [] = {1116, 1188, 1277, 1356, 1422, 1491, 1557, 1617}
 
static const size_t allpass_lengths [] = {225, 341, 441, 556}
 
static const size_t stereo_adjust = 12
 

Macro Definition Documentation

◆ array_length

#define array_length (   a)    (sizeof(a)/sizeof(a[0]))

Definition at line 26 of file Reverb_libSoX.h.

◆ dB_to_linear

#define dB_to_linear (   x)    exp((x) * M_LN10 * 0.05)

Definition at line 27 of file Reverb_libSoX.h.

◆ FIFO_MIN

#define FIFO_MIN   0x4000

Definition at line 30 of file Reverb_libSoX.h.

◆ fifo_read_ptr

#define fifo_read_ptr (   f)    fifo_read(f, (FIFO_SIZE_T)0, NULL)

Definition at line 31 of file Reverb_libSoX.h.

◆ FIFO_SIZE_T

#define FIFO_SIZE_T   size_t

Definition at line 29 of file Reverb_libSoX.h.

◆ filter_advance

#define filter_advance (   p)    if (--(p)->ptr < (p)->buffer) (p)->ptr += (p)->size

Definition at line 33 of file Reverb_libSoX.h.

◆ filter_delete

#define filter_delete (   p)    free((p)->buffer)

Definition at line 34 of file Reverb_libSoX.h.

◆ lsx_zalloc

#define lsx_zalloc (   var,
 
)    var = (float *)calloc(n, sizeof(*var))

Definition at line 32 of file Reverb_libSoX.h.

◆ M_LN10

#define M_LN10   2.30258509299404568402 /* log_e 10 */

Definition at line 18 of file Reverb_libSoX.h.

◆ midi_to_freq

#define midi_to_freq (   n)    (440 * pow(2,((n)-69)/12.))

Definition at line 28 of file Reverb_libSoX.h.

Function Documentation

◆ allpass_process()

static float allpass_process ( filter_t p,
float const *  input 
)
static

Definition at line 130 of file Reverb_libSoX.h.

132{
133 float output = *p->ptr;
134 *p->ptr = *input + output * .5;
136 return output - *input;
137}
#define filter_advance(p)
Definition: Reverb_libSoX.h:33
float * ptr

References filter_advance, and filter_t::ptr.

Referenced by filter_array_process().

Here is the caller graph for this function:

◆ comb_process()

static float comb_process ( filter_t p,
float const *  input,
float const *  feedback,
float const *  hf_damping 
)
static

Definition at line 120 of file Reverb_libSoX.h.

122{
123 float output = *p->ptr;
124 p->store = output + (p->store - output) * *hf_damping;
125 *p->ptr = *input + p->store * *feedback;
127 return output;
128}
float store

References filter_advance, filter_t::ptr, and filter_t::store.

Referenced by filter_array_process().

Here is the caller graph for this function:

◆ fifo_clear()

static void fifo_clear ( fifo_t f)
static

Definition at line 44 of file Reverb_libSoX.h.

45{
46 f->end = f->begin = 0;
47}
size_t begin
Definition: Reverb_libSoX.h:40
size_t end
Definition: Reverb_libSoX.h:41

References fifo_t::begin, and fifo_t::end.

Referenced by fifo_create(), fifo_reserve(), and reverb_clear().

Here is the caller graph for this function:

◆ fifo_clear_and_zero()

static void fifo_clear_and_zero ( fifo_t f)
static

Definition at line 49 of file Reverb_libSoX.h.

50{
51 f->end = f->begin = 0;
52 memset(f->data, 0, f->allocation);
53}
char * data
Definition: Reverb_libSoX.h:37
size_t allocation
Definition: Reverb_libSoX.h:38

References fifo_t::allocation, fifo_t::begin, fifo_t::data, and fifo_t::end.

Referenced by reverb_init().

Here is the caller graph for this function:

◆ fifo_create()

static void fifo_create ( fifo_t f,
FIFO_SIZE_T  item_size 
)
static

Definition at line 106 of file Reverb_libSoX.h.

107{
108 f->item_size = item_size;
109 f->allocation = FIFO_MIN;
110 f->data = (char *)malloc(f->allocation);
111 fifo_clear(f);
112}
#define FIFO_MIN
Definition: Reverb_libSoX.h:30
static void fifo_clear(fifo_t *f)
Definition: Reverb_libSoX.h:44
size_t item_size
Definition: Reverb_libSoX.h:39

References fifo_t::allocation, fifo_t::data, fifo_clear(), FIFO_MIN, and fifo_t::item_size.

Referenced by reverb_allocate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fifo_delete()

static void fifo_delete ( fifo_t f)
static

Definition at line 101 of file Reverb_libSoX.h.

102{
103 free(f->data);
104}
void free(void *ptr)
Definition: VectorOps.h:34

References fifo_t::data, and staffpad::vo::free().

Referenced by reverb_delete().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fifo_read()

static void * fifo_read ( fifo_t f,
FIFO_SIZE_T  n,
void *  data 
)
static

Definition at line 89 of file Reverb_libSoX.h.

90{
91 char * ret = f->data + f->begin;
92 n *= f->item_size;
93 if (n > (FIFO_SIZE_T)(f->end - f->begin))
94 return NULL;
95 if (data)
96 memcpy(data, ret, (size_t)n);
97 f->begin += n;
98 return ret;
99}
#define FIFO_SIZE_T
Definition: Reverb_libSoX.h:29

References fifo_t::begin, fifo_t::data, fifo_t::end, FIFO_SIZE_T, and fifo_t::item_size.

Referenced by reverb_process().

Here is the caller graph for this function:

◆ fifo_reserve()

static void * fifo_reserve ( fifo_t f,
FIFO_SIZE_T  n 
)
static

Definition at line 56 of file Reverb_libSoX.h.

57{
58 n *= f->item_size;
59
60 if (f->begin == f->end)
61 fifo_clear(f);
62
63 while (1) {
64 if (f->end + n <= f->allocation) {
65 void *p = f->data + f->end;
66
67 f->end += n;
68 return p;
69 }
70 if (f->begin > FIFO_MIN) {
71 memmove(f->data, f->data + f->begin, f->end - f->begin);
72 f->end -= f->begin;
73 f->begin = 0;
74 continue;
75 }
76 f->allocation += n;
77 f->data = (char *)realloc(f->data, f->allocation);
78 }
79}

References fifo_t::allocation, fifo_t::begin, fifo_t::data, fifo_t::end, fifo_clear(), FIFO_MIN, and fifo_t::item_size.

Referenced by fifo_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fifo_write()

static void * fifo_write ( fifo_t f,
FIFO_SIZE_T  n,
void const *  data 
)
static

Definition at line 81 of file Reverb_libSoX.h.

82{
83 void * s = fifo_reserve(f, n);
84 if (data)
85 memcpy(s, data, n * f->item_size);
86 return s;
87}
static void * fifo_reserve(fifo_t *f, FIFO_SIZE_T n)
Definition: Reverb_libSoX.h:56

References fifo_reserve(), and fifo_t::item_size.

Referenced by EffectReverb::Instance::InstanceProcess(), and reverb_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filter_array_allocate()

static void filter_array_allocate ( filter_array_t p,
double  rate,
double  scale,
double  offset 
)
static

Definition at line 174 of file Reverb_libSoX.h.

176{
177 size_t i;
178 double r = rate * (1 / 44100.); /* Compensate for actual sample-rate */
179
180 for (i = 0; i < array_length(comb_lengths); ++i)
181 {
182 filter_t* pcomb = &p->comb[i];
183 pcomb->size = (size_t)(scale * r * (comb_lengths[i] + stereo_adjust * offset) + .5);
184 pcomb->ptr = lsx_zalloc(pcomb->buffer, pcomb->size);
185 }
186 for (i = 0; i < array_length(allpass_lengths); ++i)
187 {
188 filter_t* pallpass = &p->allpass[i];
189 pallpass->size = (size_t)(r * (allpass_lengths[i] + stereo_adjust * offset) + .5);
190 pallpass->ptr = lsx_zalloc(pallpass->buffer, pallpass->size);
191 }
192}
static const size_t comb_lengths[]
static const size_t stereo_adjust
#define array_length(a)
Definition: Reverb_libSoX.h:26
static const size_t allpass_lengths[]
#define lsx_zalloc(var, n)
Definition: Reverb_libSoX.h:32
filter_t comb[array_length(comb_lengths)]
filter_t allpass[array_length(allpass_lengths)]
size_t size
float * buffer

References filter_array_t::allpass, allpass_lengths, array_length, filter_t::buffer, filter_array_t::comb, comb_lengths, lsx_zalloc, filter_t::ptr, filter_t::size, and stereo_adjust.

Referenced by reverb_allocate().

Here is the caller graph for this function:

◆ filter_array_create()

static void filter_array_create ( filter_array_t p,
double  rate,
double  scale,
double  offset 
)
static

Definition at line 218 of file Reverb_libSoX.h.

220{
221 size_t i;
222 double r = rate * (1 / 44100.); /* Compensate for actual sample-rate */
223
224 for (i = 0; i < array_length(comb_lengths); ++i, offset = -offset)
225 {
226 filter_t * pcomb = &p->comb[i];
227 pcomb->size = (size_t)(scale * r * (comb_lengths[i] + stereo_adjust * offset) + .5);
228 pcomb->ptr = lsx_zalloc(pcomb->buffer, pcomb->size);
229 }
230 for (i = 0; i < array_length(allpass_lengths); ++i, offset = -offset)
231 {
232 filter_t * pallpass = &p->allpass[i];
233 pallpass->size = (size_t)(r * (allpass_lengths[i] + stereo_adjust * offset) + .5);
234 pallpass->ptr = lsx_zalloc(pallpass->buffer, pallpass->size);
235 }
236}

References filter_array_t::allpass, allpass_lengths, array_length, filter_t::buffer, filter_array_t::comb, comb_lengths, lsx_zalloc, filter_t::ptr, filter_t::size, and stereo_adjust.

◆ filter_array_delete()

static void filter_array_delete ( filter_array_t p)
static

Definition at line 259 of file Reverb_libSoX.h.

260{
261 size_t i;
262
263 for (i = 0; i < array_length(allpass_lengths); ++i)
264 filter_delete(&p->allpass[i]);
265 for (i = 0; i < array_length(comb_lengths); ++i)
266 filter_delete(&p->comb[i]);
267}
#define filter_delete(p)
Definition: Reverb_libSoX.h:34

References filter_array_t::allpass, allpass_lengths, array_length, filter_array_t::comb, comb_lengths, and filter_delete.

Referenced by reverb_delete().

Here is the caller graph for this function:

◆ filter_array_init()

static void filter_array_init ( filter_array_t p,
double  rate,
double  scale,
double  offset 
)
static

Definition at line 196 of file Reverb_libSoX.h.

198{
199 size_t i;
200 double r = rate * (1 / 44100.); /* Compensate for actual sample-rate */
201
202 for (i = 0; i < array_length(comb_lengths); ++i, offset = -offset)
203 {
204 filter_t* pcomb = &p->comb[i];
205 size_t newSize = (size_t)(scale * r * (comb_lengths[i] + stereo_adjust * offset) + .5);
206 filter_t_resize(pcomb, newSize);
207 }
208 for (i = 0; i < array_length(allpass_lengths); ++i, offset = -offset)
209 {
210 filter_t* pallpass = &p->allpass[i];
211 size_t newSize = (size_t)(r * (allpass_lengths[i] + stereo_adjust * offset) + .5);
212 filter_t_resize(pallpass, newSize);
213 }
214}
static void filter_t_resize(filter_t *p, size_t newSize)

References filter_array_t::allpass, allpass_lengths, array_length, filter_array_t::comb, comb_lengths, filter_t_resize(), and stereo_adjust.

Referenced by reverb_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filter_array_process()

static void filter_array_process ( filter_array_t p,
size_t  length,
float const *  input,
float *  output,
float const *  feedback,
float const *  hf_damping,
float const *  gain 
)
static

Definition at line 238 of file Reverb_libSoX.h.

241{
242 while (length--) {
243 float out = 0, in = *input++;
244
245 size_t i = array_length(comb_lengths) - 1;
246 do out += comb_process(p->comb + i, &in, feedback, hf_damping);
247 while (i--);
248
250 do out = allpass_process(p->allpass + i, &out);
251 while (i--);
252
253 out = one_pole_process(&p->one_pole[0], out);
254 out = one_pole_process(&p->one_pole[1], out);
255 *output++ = out * *gain;
256 }
257}
static float one_pole_process(one_pole_t *p, float i0)
static float allpass_process(filter_t *p, float const *input)
static float comb_process(filter_t *p, float const *input, float const *feedback, float const *hf_damping)
one_pole_t one_pole[2]

References filter_array_t::allpass, allpass_lengths, allpass_process(), array_length, filter_array_t::comb, comb_lengths, comb_process(), filter_array_t::one_pole, and one_pole_process().

Referenced by reverb_process().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filter_t_resize()

static void filter_t_resize ( filter_t p,
size_t  newSize 
)
static

Definition at line 367 of file Reverb_libSoX.h.

368{
369 // Choose your resize method.
370 //
371 // When moving the Room Size slider:
372 //
373 // - using resize_resetting, you will not hear previous reverberations,
374 // but at the same time you will not hear sound artifacts
375 //
376 // - using resize_preserving, you will hear previous reverberations,
377 // but sometimes you might hear sound artifacts
378
379#if 1
380 filter_t_resize_resetting(p, newSize);
381#else
382 filter_t_resize_preserving(p, newSize);
383#endif
384
385}
static void filter_t_resize_preserving(filter_t *p, size_t newSize)
static void filter_t_resize_resetting(filter_t *p, size_t newSize)

References filter_t_resize_preserving(), and filter_t_resize_resetting().

Referenced by filter_array_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filter_t_resize_preserving()

static void filter_t_resize_preserving ( filter_t p,
size_t  newSize 
)
static

Definition at line 291 of file Reverb_libSoX.h.

292{
293 // Imagine we have this filter_t as input:
294 //
295 // ptr goes from right to left and when falling off the left side, it wraps back to the right;
296 // <--ptr-- it reads the most distant sample in the past, and after reading it will write a new sample.
297 // | Imagine someone just recorded "A B C D E", and now we are going to read "A", but a resize request comes.
298 // v
299 // | C B A E D |
300 //
301
302 // Depending on the new requested size and where ptr is, we can have these cases:
303 //
304 // v
305 // | C B A 0 E D | bigger size: right-shift what is right of ptr,
306 // and fill the resulting gap with zeros.
307 //
308 // (with variant: ptr is already at the old right edge - then shift nothing, just append zeros)
309 // v
310 // | C B A D | smaller size, and ptr is within it (but not at the edge): left-shift what is to the right of ptr,
311 // discarding samples.
312 //
313 // V
314 // | C B A | smaller size, and ptr would be at the new right edge; do nothing.
315 //
316 // v
317 // | B A | smaller size, and ptr would be beyond the new right edge: left-shift what is ahead of ptr,
318 // AND move ptr to size-1
319
320 assert(newSize > 0);
321
322 const int sizeDiff = ((ssize_t)newSize - (ssize_t)p->size);
323 const size_t ptrPos = (p->ptr - p->buffer);
324
325 const size_t numSamplesBehindPtr = (p->size - 1) - ptrPos;
326
327 if (sizeDiff > 0)
328 {
329 // case: bigger size
330
331 if (numSamplesBehindPtr > 0)
332 {
333 // right-shift what is right of ptr
334 memcpy(p->ptr + 1 + sizeDiff, p->ptr + 1, numSamplesBehindPtr * sizeof(float));
335 }
336
337 // fill the created gap with zeros
338 memset(p->ptr + 1, 0, sizeDiff * sizeof(float));
339 }
340 else if (sizeDiff < 0)
341 {
342 // case: smaller size
343
344 if (ptrPos < newSize-1)
345 {
346 size_t lenOfBlockToShift = newSize - 1 - ptrPos;
347 float* ptrToBlockToShift = p->buffer + p->size - lenOfBlockToShift;
348 memcpy(p->ptr + 1, ptrToBlockToShift, lenOfBlockToShift * sizeof(float));
349 }
350 else if (ptrPos == newSize - 1)
351 {
352 // sub-case: ptr is at the new edge - no shifting to do, and ptr can stay where it is
353 }
354 else
355 {
356 // sub-case: ptr would be beyond the new edge
357 // left-shift what is ahead of ptr and make ptr point to the new edge
358 memcpy(p->buffer, p->ptr - newSize + 1, newSize * sizeof(float));
359 p->ptr = p->buffer + newSize - 1;
360 }
361 }
362
363 p->size = newSize;
364}

References filter_t::buffer, filter_t::ptr, and filter_t::size.

Referenced by filter_t_resize().

Here is the caller graph for this function:

◆ filter_t_resize_resetting()

static void filter_t_resize_resetting ( filter_t p,
size_t  newSize 
)
static

Definition at line 281 of file Reverb_libSoX.h.

282{
283 memset(p->buffer, 0, newSize * sizeof(float));
284 p->ptr = p->buffer;
285 p->store = 0;
286 p->size = newSize;
287}

References filter_t::buffer, filter_t::ptr, filter_t::size, and filter_t::store.

Referenced by filter_t_resize().

Here is the caller graph for this function:

◆ one_pole_init()

static void one_pole_init ( filter_array_t p,
double  rate,
double  fc_highpass,
double  fc_lowpass 
)
static

Definition at line 158 of file Reverb_libSoX.h.

160{
161 { /* EQ: highpass */
162 one_pole_t* q = &p->one_pole[0];
163 q->a1 = -exp(-2 * M_PI * fc_highpass / rate);
164 q->b0 = (1 - q->a1) / 2, q->b1 = -q->b0;
165 }
166 { /* EQ: lowpass */
167 one_pole_t* q = &p->one_pole[1];
168 q->a1 = -exp(-2 * M_PI * fc_lowpass / rate);
169 q->b0 = 1 + q->a1, q->b1 = 0;
170 }
171}
#define M_PI
Definition: Distortion.cpp:30

References one_pole_t::a1, one_pole_t::b0, one_pole_t::b1, M_PI, and filter_array_t::one_pole.

Referenced by reverb_set_simple_params().

Here is the caller graph for this function:

◆ one_pole_process()

static float one_pole_process ( one_pole_t p,
float  i0 
)
static

Definition at line 141 of file Reverb_libSoX.h.

142{
143 float o0 = i0*p->b0 + p->i1*p->b1 - p->o1*p->a1;
144 p->i1 = i0;
145 return p->o1 = o0;
146}

References one_pole_t::a1, one_pole_t::b0, one_pole_t::b1, one_pole_t::i1, and one_pole_t::o1.

Referenced by filter_array_process().

Here is the caller graph for this function:

◆ reverb_allocate()

static void reverb_allocate ( reverb_t p,
double  sample_rate_Hz,
size_t  buffer_size,
float **  out 
)
static

Definition at line 388 of file Reverb_libSoX.h.

389{
390 memset(p, 0, sizeof(*p));
391
392 // Input queue
393 fifo_create(&p->input_fifo, sizeof(float));
394
395 // Outputs
396 out[0] = lsx_zalloc(p->out[0], buffer_size);
397 out[1] = lsx_zalloc(p->out[1], buffer_size);
398
399 // Allpass & Comb filters
400 // pass the numbers that will cause the maximum possible allocation of the
401 // buffer just once, even if it is in excess of what is required by the
402 // settings passed in initialization after the allocation
403 filter_array_allocate(p->chan + 0, sample_rate_Hz, 1.0, 0.0);
404 filter_array_allocate(p->chan + 1, sample_rate_Hz, 1.0, 1.0);
405}
static void fifo_create(fifo_t *f, FIFO_SIZE_T item_size)
static void filter_array_allocate(filter_array_t *p, double rate, double scale, double offset)
fifo_t input_fifo
float * out[2]
filter_array_t chan[2]

References reverb_t::chan, fifo_create(), filter_array_allocate(), reverb_t::input_fifo, lsx_zalloc, and reverb_t::out.

Referenced by reverb_create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reverb_clear()

static void reverb_clear ( reverb_t p)
static

Definition at line 509 of file Reverb_libSoX.h.

510{
511 for (size_t c = 0; c < 2; c++)
512 {
513 auto& chn = p->chan[c];
514
515 chn.one_pole[0].i1 = 0.0;
516 chn.one_pole[0].o1 = 0.0;
517
518 chn.one_pole[1].i1 = 0.0;
519 chn.one_pole[1].o1 = 0.0;
520
521 for (size_t combIndex = 0; combIndex < array_length(comb_lengths); combIndex++)
522 {
523 auto& comb = chn.comb[combIndex];
524
525 memset(comb.buffer, 0, comb.size * sizeof(float));
526
527 comb.store = 0.0f;
528 }
529
530 for (size_t allpassIndex = 0; allpassIndex < array_length(allpass_lengths); allpassIndex++)
531 {
532 auto& allpass = chn.allpass[allpassIndex];
533
534 memset(allpass.buffer, 0, allpass.size * sizeof(float));
535
536 allpass.store = 0.0f;
537 }
538 } // loop on channels
539
540 fifo_clear( &(p->input_fifo) );
541}

References allpass_lengths, array_length, reverb_t::chan, comb_lengths, fifo_clear(), one_pole_t::i1, reverb_t::input_fifo, and filter_array_t::one_pole.

Referenced by EffectReverb::Instance::RealtimeSuspend().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reverb_create()

static void reverb_create ( reverb_t p,
double  sample_rate_Hz,
double  wet_gain_dB,
double  room_scale,
double  reverberance,
double  hf_damping,
double  pre_delay_ms,
double  stereo_depth,
double  tone_low,
double  tone_high,
size_t  buffer_size,
float **  out 
)
static

Definition at line 472 of file Reverb_libSoX.h.

483{
484 reverb_allocate(p, sample_rate_Hz, buffer_size, out);
485
486 reverb_init(p, sample_rate_Hz, wet_gain_dB, room_scale, reverberance, hf_damping, pre_delay_ms, stereo_depth, tone_low, tone_high);
487}
static void reverb_init(reverb_t *p, double sample_rate_Hz, double wet_gain_dB, double room_scale, double reverberance, double hf_damping, double pre_delay_ms, double stereo_depth, double tone_low, double tone_high)
static void reverb_allocate(reverb_t *p, double sample_rate_Hz, size_t buffer_size, float **out)

References reverb_allocate(), and reverb_init().

Referenced by EffectReverb::Instance::InstanceInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reverb_delete()

static void reverb_delete ( reverb_t p)
static

Definition at line 499 of file Reverb_libSoX.h.

500{
501 size_t i;
502 for (i = 0; i < 2 && p->out[i]; ++i) {
503 free(p->out[i]);
505 }
507}
static void fifo_delete(fifo_t *f)
static void filter_array_delete(filter_array_t *p)

References reverb_t::chan, fifo_delete(), filter_array_delete(), staffpad::vo::free(), reverb_t::input_fifo, and reverb_t::out.

Referenced by Reverb_priv_ex::~Reverb_priv_ex().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reverb_init()

static void reverb_init ( reverb_t p,
double  sample_rate_Hz,
double  wet_gain_dB,
double  room_scale,
double  reverberance,
double  hf_damping,
double  pre_delay_ms,
double  stereo_depth,
double  tone_low,
double  tone_high 
)
static

Definition at line 437 of file Reverb_libSoX.h.

450{
451 // Input queue
453 size_t delay = pre_delay_ms / 1000 * sample_rate_Hz + .5;
454 memset(fifo_write(&p->input_fifo, delay, 0), 0, delay * sizeof(float));
455
456 reverb_set_simple_params(p, sample_rate_Hz, wet_gain_dB, reverberance, hf_damping, tone_low, tone_high);
457
458 // Allpass & Comb filters
459 double scale = room_scale / 100 * .9 + .1;
460 double depth = stereo_depth / 100;
461 for (size_t i = 0; i <= ceil(depth); ++i)
462 {
463 filter_array_init(p->chan + i, sample_rate_Hz, scale, i * depth);
464 }
465
466 // Remember if stereo depth was set to 0, so we do not have to process twice
467 p->initializedWithZeroDepth = (stereo_depth == 0.0);
468
469}
static void reverb_set_simple_params(reverb_t *p, double sample_rate_Hz, double wet_gain_dB, double reverberance, double hf_damping, double tone_low, double tone_high)
static void fifo_clear_and_zero(fifo_t *f)
Definition: Reverb_libSoX.h:49
static void filter_array_init(filter_array_t *p, double rate, double scale, double offset)
static void * fifo_write(fifo_t *f, FIFO_SIZE_T n, void const *data)
Definition: Reverb_libSoX.h:81
bool initializedWithZeroDepth

References reverb_t::chan, fifo_clear_and_zero(), fifo_write(), filter_array_init(), reverb_t::initializedWithZeroDepth, reverb_t::input_fifo, and reverb_set_simple_params().

Referenced by EffectReverb::Instance::RealtimeProcess(), and reverb_create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reverb_process()

static void reverb_process ( reverb_t p,
size_t  length 
)
static

Definition at line 489 of file Reverb_libSoX.h.

490{
491 filter_array_process(p->chan, length, (float *) fifo_read_ptr(&p->input_fifo), p->out[0], &p->feedback, &p->hf_damping, &p->gain);
492
494 filter_array_process(p->chan + 1, length, (float*)fifo_read_ptr(&p->input_fifo), p->out[1], &p->feedback, &p->hf_damping, &p->gain);
495
496 fifo_read(&p->input_fifo, length, NULL);
497}
static void * fifo_read(fifo_t *f, FIFO_SIZE_T n, void *data)
Definition: Reverb_libSoX.h:89
#define fifo_read_ptr(f)
Definition: Reverb_libSoX.h:31
static void filter_array_process(filter_array_t *p, size_t length, float const *input, float *output, float const *feedback, float const *hf_damping, float const *gain)
float feedback
float hf_damping
float gain

References reverb_t::chan, reverb_t::feedback, fifo_read(), fifo_read_ptr, filter_array_process(), reverb_t::gain, reverb_t::hf_damping, reverb_t::initializedWithZeroDepth, reverb_t::input_fifo, and reverb_t::out.

Referenced by EffectReverb::Instance::InstanceProcess().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reverb_set_simple_params()

static void reverb_set_simple_params ( reverb_t p,
double  sample_rate_Hz,
double  wet_gain_dB,
double  reverberance,
double  hf_damping,
double  tone_low,
double  tone_high 
)
static

Definition at line 409 of file Reverb_libSoX.h.

419{
420 // Feedback, Damping, Gain
421 double a = -1 / log(1 - .3 ); /* Set minimum feedback */
422 double b = 100 / (log(1 - .98) * a + 1); /* Set maximum feedback */
423
424 p->feedback = 1 - exp((reverberance - b) / (a * b));
425 p->hf_damping = hf_damping / 100 * .3 + .2;
426 p->gain = dB_to_linear(wet_gain_dB) * .015;
427
428
429 // LP-HP Filters
430 double fc_highpass = midi_to_freq(72 - tone_low / 100 * 48);
431 double fc_lowpass = midi_to_freq(72 + tone_high / 100 * 48);
432 one_pole_init(&p->chan[0], sample_rate_Hz, fc_highpass, fc_lowpass);
433 one_pole_init(&p->chan[1], sample_rate_Hz, fc_highpass, fc_lowpass);
434}
#define midi_to_freq(n)
Definition: Reverb_libSoX.h:28
#define dB_to_linear(x)
Definition: Reverb_libSoX.h:27
static void one_pole_init(filter_array_t *p, double rate, double fc_highpass, double fc_lowpass)

References reverb_t::chan, dB_to_linear, reverb_t::feedback, reverb_t::gain, reverb_t::hf_damping, midi_to_freq, and one_pole_init().

Referenced by EffectReverb::Instance::RealtimeProcess(), and reverb_init().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ allpass_lengths

const size_t allpass_lengths[] = {225, 341, 441, 556}
static

◆ comb_lengths

const size_t comb_lengths[] = {1116, 1188, 1277, 1356, 1422, 1491, 1557, 1617}
static

◆ stereo_adjust

const size_t stereo_adjust = 12
static

Definition at line 150 of file Reverb_libSoX.h.

Referenced by filter_array_allocate(), filter_array_create(), and filter_array_init().