Deluge Firmware
1.3.0
Build date: 2026.11.28
Toggle main menu visibility
Loading...
Searching...
No Matches
svf.h
1
/*
2
* Copyright © 2015-2023 Synthstrom Audible Limited
3
*
4
* This file is part of The Synthstrom Audible Deluge Firmware.
5
*
6
* The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7
* terms of the GNU General Public License as published by the Free Software Foundation,
8
* either version 3 of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
* See the GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License along with this program.
15
* If not, see <https://www.gnu.org/licenses/>.
16
*/
17
18
#pragma once
19
20
#include "dsp/filter/filter.h"
21
#include "util/fixedpoint.h"
22
23
namespace
deluge::dsp::filter {
24
25
class
SVFilter :
public
Filter<SVFilter> {
26
public
:
27
SVFilter() =
default
;
28
// returns a compensatory gain value
29
q31_t setConfig(q31_t hpfFrequency, q31_t hpfResonance, FilterMode lpfMode, q31_t lpfMorph, q31_t filterGain);
30
void
doFilter(q31_t* startSample, q31_t* endSample, int32_t sampleIncrememt);
31
void
doFilterStereo(q31_t* startSample, q31_t* endSample);
32
void
resetFilter() {
33
l = (
SVFState
){0, 0};
34
r = (
SVFState
){0, 0};
35
}
36
37
private
:
38
struct
SVFState
{
39
q31_t low;
40
q31_t band;
41
};
42
// Per-buffer copy of the coefficients. The loops work on locals so stores to the q31_t sample buffer can't force
43
// the compiler to reload the q31_t members and store the state back every sample.
44
struct
Coeffs
{
45
q31_t fc;
46
q31_t q;
47
q31_t in;
48
q31_t c_low;
49
q31_t c_band;
50
q31_t c_high;
51
};
52
[[gnu::always_inline]]
Coeffs
getCoeffs()
const
{
return
Coeffs
{fc, q, in, c_low, c_band, c_high}; }
53
template
<
bool
kBand>
54
[[gnu::always_inline]]
static
inline
q31_t doSVF(q31_t input, SVFState& state,
const
Coeffs& c);
55
template
<
bool
kBand>
56
void
doFilterT(q31_t* startSample, q31_t* endSample, int32_t sampleIncrement);
57
template
<
bool
kBand>
58
void
doFilterStereoT(q31_t* startSample, q31_t* endSample);
59
SVFState l;
60
SVFState r;
61
62
q31_t q;
63
q31_t in;
64
q31_t c_low;
65
q31_t c_band;
66
q31_t c_notch;
67
q31_t c_high;
68
bool
band_mode;
69
};
70
}
// namespace deluge::dsp::filter
deluge::dsp::filter::SVFilter::Coeffs
Definition
svf.h:44
deluge::dsp::filter::SVFilter::SVFState
Definition
svf.h:38