-
Notifications
You must be signed in to change notification settings - Fork 8
/
reverbsc96.h
70 lines (59 loc) · 2.27 KB
/
reverbsc96.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
Copyright (c) 2023 Electrosmith, Corp, Sean Costello, Istvan Varga, Paul Batchelor
Use of this source code is governed by the LGPL V2.1
license that can be found in the LICENSE file or at
https://opensource.org/license/lgpl-2-1/
*/
#pragma once
#ifndef REVERBSC96_H
#define REVERBSC96_H
#define DSY_REVERBSC_MAX_SIZE 98936
/**Delay line for internal reverb use
*/
typedef struct
{
int write_pos; /**< write position */
int buffer_size; /**< buffer size */
int read_pos; /**< read position */
int read_pos_frac; /**< fractional component of read pos */
int read_pos_frac_inc; /**< increment for fractional */
int dummy; /**< dummy var */
int seed_val; /**< randseed */
int rand_line_cnt; /**< number of random lines */
float filter_state; /**< state of filter */
float *buf; /**< buffer ptr */
} ReverbSc96Dl;
/** Stereo Reverb */
class ReverbSc96
{
public:
ReverbSc96() {}
~ReverbSc96() {}
/** Initializes the reverb module, and sets the sample_rate at which the Process function will be called.
Returns 0 if all good, or 1 if it runs out of delay times exceed maximum allowed.
*/
int Init(float sample_rate);
/** Process the input through the reverb, and updates values of out1, and out2 with the new processed signal.
*/
int Process(const float &in1, const float &in2, float *out1, float *out2);
/** controls the reverb time. reverb tail becomes infinite when set to 1.0
\param fb - sets reverb time. range: 0.0 to 1.0
*/
inline void SetFeedback(const float &fb) { feedback_ = fb; }
/** controls the internal dampening filter's cutoff frequency.
\param freq - low pass frequency. range: 0.0 to sample_rate / 2
*/
inline void SetLpFreq(const float &freq) { lpfreq_ = freq; }
private:
void NextRandomLineseg(ReverbSc96Dl *lp, int n);
int InitDelayLine(ReverbSc96Dl *lp, int n);
float feedback_, lpfreq_;
float i_sample_rate_, i_pitch_mod_, i_skip_init_;
float sample_rate_;
float damp_fact_;
float prv_lpfreq_;
int init_done_;
ReverbSc96Dl delay_lines_[8];
float aux_[DSY_REVERBSC_MAX_SIZE];
};
#endif