Debian Codegraph @

plugins/dragonfly-plate-reverb/DSP.hpp

raw
1 /*
2 * Dragonfly Reverb, copyright (c) 2019 Michael Willis, Rob van den Berg
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 3 of
7 * the License, or any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * For a full copy of the GNU General Public License see the LICENSE file.
15 */
16
17 #ifndef DRAGONFLY_REVERB_DSP_HPP_INCLUDED
18 #define DRAGONFLY_REVERB_DSP_HPP_INCLUDED
19
20 #include "AbstractDSP.hpp"
21 #include "freeverb/nrev.hpp"
22 #include "freeverb/nrevb.hpp"
23 #include "freeverb/strev.hpp"
24
25
26 class NRev : public fv3::nrev_f {
27 public:
28 NRev();
29 void setDampLpf(float value);
30 virtual void mute();
31 virtual void setFsFactors();
32 virtual void processloop2(long count, float *inputL, float *inputR, float *outputL, float *outputR);
33 private:
34 float dampLpf = 20000;
35 fv3::iir_1st_f dampLpfL, dampLpfR;
36 };
37
38
39 class NRevB : public fv3::nrevb_f {
40 public:
41 NRevB();
42 void setDampLpf(float value);
43 virtual void mute();
44 virtual void setFsFactors();
45 virtual void processloop2(long count, float *inputL, float *inputR, float *outputL, float *outputR);
46 private:
47 float dampLpf = 20000;
48 fv3::iir_1st_f dampLpfL, dampLpfR;
49 };
50
51
52 class DragonflyReverbDSP : public AbstractDSP {
53 public:
54 DragonflyReverbDSP(double sampleRate);
55 float getParameterValue(uint32_t index) const;
56 void setParameterValue(uint32_t index, float value);
57 void run(const float** inputs, float** outputs, uint32_t frames);
58 void sampleRateChanged(double newSampleRate);
59 void mute();
60
61 private:
62 float oldParams[paramCount];
63 float newParams[paramCount];
64
65 double sampleRate;
66
67 float dryLevel = 0.0;
68 float wetLevel = 0.0;
69
70 static const uint32_t BUFFER_SIZE = 256;
71
72 fv3::iir_1st_f input_lpf_0, input_lpf_1, input_hpf_0, input_hpf_1;
73
74 fv3::revbase_f *model; // points to one of the following:
75 NRev nrev;
76 NRevB nrevb;
77 fv3::strev_f strev;
78
79 float filtered_input_buffer[2][BUFFER_SIZE];
80 float output_buffer[2][BUFFER_SIZE];
81
82 void setInputLPF(float freq);
83 void setInputHPF(float freq);
84 };
85
86 #endif