Deluge Firmware 1.3.0
Build date: 2025.06.05
Loading...
Searching...
No Matches
impulse_response_processor.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/stereo_sample.h"
21#include "util/fixedpoint.h"
22#include <cstdint>
23
24class [[gnu::hot]] ImpulseResponseProcessor {
25 constexpr static size_t IR_SIZE = 26;
26 constexpr static size_t IR_BUFFER_SIZE = (IR_SIZE - 1);
27
28 constexpr static std::array<int32_t, IR_SIZE> ir = {
29 -3203916, 8857848, 24813136, 41537808, 35217472, 15195632, -27538592, -61984128, 1944654848,
30 1813580928, 438462784, 101125088, 6042048, -22429488, -46218864, -56638560, -64785312, -52108528,
31 -37256992, -11863856, 1390352, 14663296, 12784464, 14254800, 5690912, 4490736,
32 };
33
34public:
35 ImpulseResponseProcessor() = default;
36
37 inline void process(const StereoSample input, StereoSample& output) {
38 output.l = buffer_[0].l + multiply_32x32_rshift32_rounded(input.l, ir[0]);
39 output.r = buffer_[0].r + multiply_32x32_rshift32_rounded(input.r, ir[0]);
40
41 for (int32_t i = 1; i < IR_BUFFER_SIZE; i++) {
42 buffer_[i - 1].l = buffer_[i].l + multiply_32x32_rshift32_rounded(input.l, ir[i]);
43 buffer_[i - 1].r = buffer_[i].r + multiply_32x32_rshift32_rounded(input.r, ir[i]);
44 }
45
46 buffer_[IR_BUFFER_SIZE - 1].l = multiply_32x32_rshift32_rounded(input.l, ir[IR_BUFFER_SIZE]);
47 buffer_[IR_BUFFER_SIZE - 1].r = multiply_32x32_rshift32_rounded(input.r, ir[IR_BUFFER_SIZE]);
48 }
49
50private:
51 std::array<StereoSample, IR_BUFFER_SIZE> buffer_;
52};
Definition stereo_sample.h:25