Deluge Firmware 1.3.0
Build date: 2026.11.28
Loading...
Searching...
No Matches
allpass.hpp
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#pragma once
25#include "dsp/reverb/freeverb/delay_lines.hpp"
26#include "dsp/reverb/freeverb/tuning.h"
27#include <cstdint>
28#include <span>
29
30namespace freeverb {
31// All the allpass filters: numallpasses in series for the left channel, then numallpasses for the right
32class Allpasses {
33public:
34 Allpasses() = default;
35
36 // For allpass i; the last maxblockframes words of the buffer are spare
37 void setBuffer(size_t i, std::span<int32_t> buffer) { lines_.setBuffer(i, buffer); }
38
39 void mute() { lines_.mute(); }
40
41 // One frame, in place
42 [[gnu::always_inline]] void process(int32_t& l, int32_t& r) {
43 for (size_t i = 0; i < numallpasses; i++) {
44 l = process(i, l);
45 r = process(numallpasses + i, r);
46 }
47 lines_.advance();
48 }
49
50 // Exactly the same as process() for each frame of a block (a multiple of four frames long, at most
51 // maxblockframes), in place
52 void processBlock(int32_t* samples_l, int32_t* samples_r, size_t numFrames);
53
54private:
55 [[gnu::always_inline]] int32_t process(size_t i, int32_t input) {
56 int32_t bufout = lines_[i];
57 int32_t output = -input + bufout;
58
59 lines_[i] = input + (bufout >> 1); // Shortcut - because feedback was always one half by default anyway
60 // buffer[bufidx] = input + (multiply_32x32_rshift32_rounded(bufout, feedback) << 1);
61
62 return output;
63 }
64
66};
67} // namespace freeverb
Definition delay_lines.hpp:33