Deluge Firmware
Loading...
Searching...
No Matches
comb.hpp
Go to the documentation of this file.
1// Comb filter class declaration
2//
3// Written by Jezar at Dreampoint, June 2000
4// http://www.dreampoint.co.uk
5// This code is public domain
6
7/*
8 * Copyright © 2015-2023 Synthstrom Audible Limited
9 *
10 * This file is part of The Synthstrom Audible Deluge Firmware.
11 *
12 * The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
13 * terms of the GNU General Public License as published by the Free Software Foundation,
14 * either version 3 of the License, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
17 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 * See the GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along with this program.
21 * If not, see <https://www.gnu.org/licenses/>.
22*/
23
24#ifndef _comb_
25#define _comb_
26
27#include "r_typedefs.h"
28#include "functions.h"
29
30class comb
31{
32public:
33 comb();
34 void setbuffer(int32_t *buf, int size);
35 inline int32_t process(int32_t inp);
36 void mute();
37 void setdamp(float val);
38 float getdamp();
39 void setfeedback(int32_t val);
40 int32_t getfeedback();
41private:
42 int32_t feedback;
43 int32_t filterstore;
44 int32_t damp1;
45 int32_t damp2;
46 int32_t *buffer;
47 int bufsize;
48 int bufidx;
49};
50
51
52// Big to inline - but crucial for speed
53
54inline int32_t comb::process(int32_t input)
55{
56 int32_t output;
57
58 output = buffer[bufidx];
59
60 filterstore = (multiply_32x32_rshift32_rounded(output, damp2) + multiply_32x32_rshift32_rounded(filterstore, damp1)) << 1;
61
62 buffer[bufidx] = input + (multiply_32x32_rshift32_rounded(filterstore, feedback) << 1);
63
64 if(++bufidx>=bufsize) bufidx = 0;
65
66 return output;
67}
68
69#endif //_comb_
70
71//ends
Definition: comb.hpp:31
int32_t process(int32_t inp)
Definition: comb.hpp:54
comb()
Definition: comb.cpp:26
void setfeedback(int32_t val)
Definition: comb.cpp:55
int32_t getfeedback()
Definition: comb.cpp:61
float getdamp()
Definition: comb.cpp:50
void setdamp(float val)
Definition: comb.cpp:44
void setbuffer(int32_t *buf, int size)
Definition: comb.cpp:32
void mute()
Definition: comb.cpp:38