-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathReverb.h
More file actions
106 lines (77 loc) · 2.89 KB
/
Copy pathReverb.h
File metadata and controls
106 lines (77 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Copyright (C) 2025, 2026 Theo Niessink <theo@taletn.com>
// This work is free. You can redistribute it and/or modify it under the
// terms of the Do What The Fuck You Want To Public License, Version 2,
// as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
#pragma once
#include "System.h"
#include "WDL/wdltypes.h"
namespace TG101 {
class Reverb
{
public:
Reverb();
~Reverb();
void SetSampleRate(double sampleRate);
void SetReverbType(EReverbType type);
void SetReverbFeedback(const unsigned short coeff[4][2], int num = 4);
void SetOutputLevel(int level);
inline void MuteOutput() { mOutputLevel = 0.0f; }
void Reset();
void Process(float input, float output[2]);
#ifndef NDEBUG
void ExtractIR(const char* filename, int maxLen = 0);
#endif
private:
struct DelayLine
{
int mIdx, mLen;
};
struct CombFilter
{
DelayLine mDelay;
int mTap[2];
float mFeedback, mGain;
double WDL_FIXALIGN mFilterState;
}
WDL_FIXALIGN;
int SetDiffuserType(int type, double ratio);
int SetCombFilterType(int type, double ratio);
static double GetLowPassCoeff(double cutoff, double ratio);
float* ProcessDelayLine(float input, float* output, DelayLine* delay, float* buf);
float* ProcessReverb(float input, float output[2], int type, float* buf);
float* ProcessDelay(float input, float output[2], int type, float* buf);
float* ProcessEarlyReflect(float input, float output[3], int type, float* buf);
float* ProcessDelayFeedback(float input, float output[2], const float coeff[2], float* buf);
static float ProcessLowPassFilter(float input, double* state, double coeff);
static float* ProcessDiffuser(float input, float* output, DelayLine* diff, float* buf, const float coeff[4]);
static float* ProcessCombFilter(float input, float output[2], CombFilter* comb, float* buf, double damp);
int mReverbType, mBufSize;
float* mBuf;
DelayLine mLatency;
DelayLine mDelay;
int mDelayTap[2];
DelayLine mPreDelay;
double WDL_FIXALIGN mLowPassState, mLowPassCoeff[2];
DelayLine mInputDiff[2];
double WDL_FIXALIGN mHighDamp;
CombFilter mComb[4];
DelayLine mOutputDiff[2];
float mOutputLevel;
double WDL_FIXALIGN mSampleRatio;
static const double mNativeSampleRate;
static const unsigned short mMaxDelayTbl[9];
static const unsigned short mERDelayTbl[8][3];
static const float mERGainTbl[3][4];
static const float mDelayFeedbackTbl[2][2];
static const double mLowPassCutoffTbl[2];
static const unsigned short mDiffDelayTbl[3][4];
static const float mDiffCoeffTbl[4][4];
static const double mCombDampTbl[6];
static const unsigned short mCombDelayTbl[3][4][3];
static const unsigned short mDampCutoffTbl[6];
static const float mCombFeedbackTbl[6];
static const float mDelayMixTbl[2][4];
static const unsigned char mOutputLevelTbl[13];
}
WDL_FIXALIGN;
} // namespace TG101