Deluge Firmware
1.3.0
Build date: 2026.08.29
Toggle main menu visibility
Loading...
Searching...
No Matches
ladder_components.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 "util/fixedpoint.h"
21
#include <cstdint>
22
namespace
deluge::dsp::filter {
23
class
BasicFilterComponent {
24
public
:
25
BasicFilterComponent() { reset(); }
26
// moveability is tan(f)/(1+tan(f))
27
[[gnu::always_inline]]
inline
q31_t doFilter(q31_t input, q31_t moveability) {
28
q31_t a = multiply_32x32_rshift32_rounded(input - memory, moveability) << 1;
29
q31_t b = a + memory;
30
memory = b + a;
31
return
b;
32
}
33
[[gnu::always_inline]]
inline
int32_t doAPF(q31_t input, int32_t moveability) {
34
q31_t a = multiply_32x32_rshift32_rounded(input - memory, moveability) << 1;
35
q31_t b = a + memory;
36
memory = a + b;
37
return
b * 2 - input;
38
}
39
[[gnu::always_inline]]
inline
void
affectFilter(q31_t input, int32_t moveability) {
40
memory += multiply_32x32_rshift32_rounded(input - memory, moveability) << 2;
41
}
42
[[gnu::always_inline]]
inline
void
reset() { memory = 0; }
43
[[gnu::always_inline]]
inline
q31_t getFeedbackOutput(int32_t feedbackAmount) {
44
return
multiply_32x32_rshift32_rounded(memory, feedbackAmount) << 2;
45
}
46
[[gnu::always_inline]]
inline
q31_t getFeedbackOutputWithoutLshift(int32_t feedbackAmount) {
47
return
multiply_32x32_rshift32_rounded(memory, feedbackAmount);
48
}
49
50
q31_t memory = 0;
51
};
52
}
// namespace deluge::dsp::filter