LMMS
Loading...
Searching...
No Matches
Reverb.h
Go to the documentation of this file.
1/*
2 Reverb.h
3
4 Copyright 2002-5 Tim Goetze <tim@quitte.de>
5
6 http://quitte.de/dsp/
7
8 two reverb units: JVRev and Plate.
9
10 the former is a rewrite of STK's JVRev, a traditional design.
11
12 original comment:
13
14 This is based on some of the famous
15 Stanford CCRMA reverbs (NRev, KipRev)
16 all based on the Chowning/Moorer/
17 Schroeder reverberators, which use
18 networks of simple allpass and comb
19 delay filters.
20
21 (STK is an effort of Gary Scavone).
22
23 the algorithm is mostly unchanged in this implementation; the delay
24 line lengths have been fiddled with to make the stereo field more
25 evenly weighted, and denormal protection has been added.
26
27 the Plate reverb is based on the circuit discussed in Jon Dattorro's
28 september 1997 JAES paper on effect design (part 1: reverb & filters).
29*/
30/*
31 This program is free software; you can redistribute it and/or
32 modify it under the terms of the GNU General Public License
33 as published by the Free Software Foundation; either version 2
34 of the License, or (at your option) any later version.
35
36 This program is distributed in the hope that it will be useful,
37 but WITHOUT ANY WARRANTY; without even the implied warranty of
38 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39 GNU General Public License for more details.
40
41 You should have received a copy of the GNU General Public License
42 along with this program; if not, write to the Free Software
43 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
44 02111-1307, USA or point your web browser to http://www.gnu.org.
45*/
46
47#ifndef _REVERB_H_
48#define _REVERB_H_
49
50#include <stdio.h>
51
52#include "dsp/Delay.h"
53#include "dsp/OnePole.h"
54#include "dsp/Sine.h"
55#include "dsp/util.h"
56
57/* both reverbs use this */
59: public DSP::Delay
60{
61 public:
62 inline sample_t
63 process (sample_t x, double d)
64 {
65 sample_t y = get();
66 x -= d * y;
67 put (x);
68 return d * x + y;
69 }
70};
71
72/* helper for JVRev */
73class JVComb
74: public DSP::Delay
75{
76 public:
77 float c;
78
79 inline sample_t
81 {
82 x += c * get();
83 put (x);
84 return x;
85 }
86};
87
88class JVRev
89: public Plugin
90{
91 public:
92 static int default_length[9];
94
97
99
100 double apc;
101
102 template <sample_func_t F>
103 void one_cycle (int frames);
104
105 int length [9];
106
108
109 public:
111
112 void init();
113 void activate();
114
115 void run (int n)
116 {
118 }
119
120 void run_adding (int n)
121 {
123 }
124};
125
126/* /////////////////////////////////////////////////////////////////////// */
127
129{
130 public:
131 float n0, width;
132
136
137 void init (int n, int w)
138 {
139 n0 = n;
140 width = w;
141 delay.init (n + w);
142 }
143
144 void reset()
145 {
146 delay.reset();
147 tap.reset();
148 }
149
150 inline sample_t
151 process (sample_t x, double d)
152 {
153 /* TODO: try all-pass interpolation */
154 sample_t y = delay.get_at (n0 + width * lfo.get());
155 x += d * y;
156 delay.put (x);
157 return y - d * x; /* note sign */
158 }
159};
160
162: public Plugin
163{
164 public:
166
168
169 struct {
173
174 struct {
176 Lattice lattice[2];
179 int taps[12];
181
182 public:
183 void init();
184 void activate()
185 {
186 input.bandwidth.reset();
187
188 for (int i = 0; i < 4; ++i)
189 {
190 input.lattice[i].reset();
191 tank.delay[i].reset();
192 }
193
194 for (int i = 0; i < 2; ++i)
195 {
196 tank.mlattice[i].reset();
197 tank.lattice[i].reset();
198 tank.damping[i].reset();
199 }
200
201 tank.mlattice[0].lfo.set_f (1.2, fs, 0);
202 tank.mlattice[1].lfo.set_f (1.2, fs, .5 * M_PI);
203 }
204
205 inline void process (sample_t x, sample_t decay,
206 sample_t * xl, sample_t * xr);
207};
208
209/* /////////////////////////////////////////////////////////////////////// */
210
211class Plate
212: public PlateStub
213{
214 public:
215 template <sample_func_t F>
216 void one_cycle (int frames);
217
218 public:
220
221 void run (int n)
222 {
224 }
225
226 void run_adding (int n)
227 {
229 }
230};
231
232/* /////////////////////////////////////////////////////////////////////// */
233
235: public PlateStub
236{
237 public:
238 template <sample_func_t F>
239 void one_cycle (int frames);
240
241 public:
243
244 void run (int n)
245 {
247 }
248
249 void run_adding (int n)
250 {
252 }
253};
254
255#endif /* _REVERB_H_ */
LADSPA_Data sample_t
Definition basics.h:100
Definition Delay.h:41
sample_t get()
Definition Delay.h:85
void put(sample_t x)
Definition Delay.h:78
Definition Delay.h:138
Definition OnePole.h:34
Definition Sine.h:34
Definition Reverb.h:75
sample_t process(sample_t x)
Definition Reverb.h:80
float c
Definition Reverb.h:77
Definition Reverb.h:90
void set_t60(sample_t t)
static int default_length[9]
Definition Reverb.h:92
double apc
Definition Reverb.h:100
void run_adding(int n)
Definition Reverb.h:120
DSP::Delay right
Definition Reverb.h:98
void activate()
static PortInfo port_info[]
Definition Reverb.h:110
DSP::Delay left
Definition Reverb.h:98
void one_cycle(int frames)
JVComb comb[4]
Definition Reverb.h:96
void run(int n)
Definition Reverb.h:115
sample_t t60
Definition Reverb.h:93
void init()
Lattice allpass[3]
Definition Reverb.h:95
int length[9]
Definition Reverb.h:105
Definition Reverb.h:60
sample_t process(sample_t x, double d)
Definition Reverb.h:63
Definition Reverb.h:129
float n0
Definition Reverb.h:131
sample_t process(sample_t x, double d)
Definition Reverb.h:151
DSP::Sine lfo
Definition Reverb.h:134
void reset()
Definition Reverb.h:144
DSP::Delay delay
Definition Reverb.h:133
float width
Definition Reverb.h:131
DSP::DelayTapA tap
Definition Reverb.h:135
void init(int n, int w)
Definition Reverb.h:137
Definition Reverb.h:236
void run(int n)
Definition Reverb.h:244
static PortInfo port_info[]
Definition Reverb.h:242
void one_cycle(int frames)
void run_adding(int n)
Definition Reverb.h:249
Definition Reverb.h:213
static PortInfo port_info[]
Definition Reverb.h:219
void one_cycle(int frames)
void run_adding(int n)
Definition Reverb.h:226
void run(int n)
Definition Reverb.h:221
Definition Reverb.h:163
void process(sample_t x, sample_t decay, sample_t *xl, sample_t *xr)
DSP::OnePoleLP bandwidth
Definition Reverb.h:170
struct PlateStub::@131115250147370117033347261241136341115055010136 tank
void activate()
Definition Reverb.h:184
void init()
Lattice lattice[4]
Definition Reverb.h:171
sample_t indiff2
Definition Reverb.h:167
sample_t dediff2
Definition Reverb.h:167
sample_t f_lfo
Definition Reverb.h:165
struct PlateStub::@154242362230203007167335043244264307372147035273 input
ModLattice mlattice[2]
Definition Reverb.h:175
sample_t dediff1
Definition Reverb.h:167
DSP::OnePoleLP damping[2]
Definition Reverb.h:178
sample_t indiff1
Definition Reverb.h:167
DSP::Delay delay[4]
Definition Reverb.h:177
int taps[12]
Definition Reverb.h:179
Definition basics.h:174
double fs
Definition basics.h:176
#define M_PI
Definition compat.h:149
UINT_D64 w
Definition inflate.c:942
struct huft * t
Definition inflate.c:943
int y
Definition inflate.c:1588
unsigned d
Definition inflate.c:940
register unsigned i
Definition inflate.c:1575
unsigned x[BMAX+1]
Definition inflate.c:1586
Definition basics.h:94
int n
Definition crypt.c:458