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