Deluge Firmware 1.3.0
Build date: 2025.09.14
Loading...
Searching...
No Matches
base.hpp
1#pragma once
2#include "definitions_cxx.hpp"
3#include "dsp_ng/core/types.hpp"
4#include <cmath>
5#include <span>
6
7namespace deluge::dsp::reverb {
8struct Base {
9 Base() = default;
10 virtual ~Base() = default;
11
12 virtual void process(std::span<int32_t> input, StereoBuffer<q31_t> output) = 0;
13
14 constexpr void setPanLevels(const int32_t amplitude_left, const int32_t amplitude_right) {
15 amplitude_right_ = amplitude_right;
16 amplitude_left_ = amplitude_left;
17 }
18 enum class FilterType { LowPass, HighPass };
19 template <FilterType filtertype>
20 static constexpr float calcFilterCutoff(float f) {
21 float minFreq;
22 float maxFreq;
23 // this exp will be between 1 and 4.48, half the knob range is about 2
24 // for the HPF the result will then be from 0 to 500Hz with half the knob range at 300hz
25 // then shift to 20-520Hz as there is a low end buildup in the reverb that should always be filtered out
26 // for the LPF the result will be from 0 to 20000 with half the knob range at 5678.537hz
27 if constexpr (filtertype == FilterType::LowPass) {
28 minFreq = 0.0f;
29 maxFreq = 5083.74f;
30 }
31 else if constexpr (filtertype == FilterType::HighPass) {
32 minFreq = 20.0f;
33 maxFreq = 150.0f;
34 }
35 float fc_hz = minFreq + (std::exp(1.5f * f) - 1) * maxFreq;
36 float fc = fc_hz / float(kSampleRate);
37 float wc = fc / (1 + fc);
38 return wc;
39 }
40
41 // Dummy functions
42 virtual void setRoomSize(float value) {}
43 [[nodiscard]] virtual float getRoomSize() const { return 0; };
44
45 virtual void setHPF(float f) {}
46 [[nodiscard]] virtual float getHPF() const { return 0; }
47
48 virtual void setLPF(float f) {}
49 [[nodiscard]] virtual float getLPF() const { return 0; }
50
51 virtual void setDamping(float value) {}
52 [[nodiscard]] virtual float getDamping() const { return 0; }
53
54 virtual void setWidth(float value) {}
55 [[nodiscard]] virtual float getWidth() const { return 0; };
56
57 [[nodiscard]] constexpr int32_t getPanLeft() const { return amplitude_left_; }
58 [[nodiscard]] constexpr int32_t getPanRight() const { return amplitude_right_; }
59
60private:
61 int32_t amplitude_right_ = 0;
62 int32_t amplitude_left_ = 0;
63};
64} // namespace deluge::dsp::reverb