Deluge Firmware
Loading...
Searching...
No Matches
allpass.hpp
Go to the documentation of this file.
1// Allpass filter 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 _allpass_
25#define _allpass_
26#include "r_typedefs.h"
27#include "functions.h"
28
30{
31public:
32 allpass();
33 void setbuffer(int32_t *buf, int size);
34 inline int32_t process(int32_t inp);
35 void mute();
36 void setfeedback(float val);
37 float getfeedback();
38// private:
39 int32_t feedback;
40 int32_t *buffer;
42 int bufidx;
43};
44
45
46// Big to inline - but crucial for speed
47inline int32_t allpass::process(int32_t input)
48{
49 int32_t output;
50 int32_t bufout;
51
52 bufout = buffer[bufidx];
53
54 output = -input + bufout;
55 buffer[bufidx] = input + (bufout >> 1); // Shortcut - because feedback was always one half by default anyway
56 //buffer[bufidx] = input + (multiply_32x32_rshift32_rounded(bufout, feedback) << 1);
57
58 if(++bufidx >= bufsize) bufidx = 0;
59
60 return output;
61}
62
63#endif//_allpass
64
65//ends
Definition: allpass.hpp:30
int bufsize
Definition: allpass.hpp:41
float getfeedback()
Definition: allpass.cpp:48
int32_t feedback
Definition: allpass.hpp:39
int bufidx
Definition: allpass.hpp:42
void setbuffer(int32_t *buf, int size)
Definition: allpass.cpp:31
allpass()
Definition: allpass.cpp:26
void setfeedback(float val)
Definition: allpass.cpp:43
int32_t process(int32_t inp)
Definition: allpass.hpp:47
void mute()
Definition: allpass.cpp:37
int32_t * buffer
Definition: allpass.hpp:40