You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1009 B
53 lines
1009 B
#ifndef __REVERB_H__
|
|
#define __REVERB_H__
|
|
|
|
// Velvet noise reverb ("Late Reverberation Synthesis Using Filtered Velvet Noise")
|
|
|
|
#include <algorithm>
|
|
|
|
#include "globals.h"
|
|
#include "frame.h"
|
|
#include "stereodelayline.h"
|
|
|
|
#define REVERB_FRAMES (3 * SAMPLE_RATE)
|
|
#define REVERB_TAPS 256
|
|
|
|
class Reverb {
|
|
private:
|
|
struct Tap {
|
|
size_t lp, rp;
|
|
float lg, rg;
|
|
};
|
|
|
|
StereoDelayLine<REVERB_FRAMES> dl;
|
|
Tap taps[REVERB_TAPS];
|
|
float lpfL = 0.f, lpfR = 0.f;
|
|
float hpfL = 0.f, hpfR = 0.f;
|
|
|
|
public:
|
|
Reverb();
|
|
|
|
frame tick(frame in) {
|
|
dl.tick(in);
|
|
|
|
frame out{0, 0};
|
|
|
|
for(const Tap& tap : taps) {
|
|
out.l += tap.lg * dl.tap(tap.lp).l;
|
|
out.r += tap.rg * dl.tap(tap.rp).r;
|
|
}
|
|
|
|
lpfL += 0.1f * (out.l - lpfL);
|
|
lpfR += 0.1f * (out.r - lpfR);
|
|
|
|
hpfL += 0.05f * (lpfL - hpfL);
|
|
hpfR += 0.05f * (lpfR - hpfR);
|
|
|
|
out.l = lpfL - hpfL;
|
|
out.r = lpfR - hpfR;
|
|
|
|
return out;
|
|
}
|
|
};
|
|
|
|
#endif |