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.
 
 

55 lines
1023 B

#ifndef __REVERB_H__
#define __REVERB_H__
// Velvet noise reverb ("Late Reverberation Synthesis Using Filtered Velvet Noise")
#include <algorithm>
#include "frame.h"
#include "delayline.h"
#include "sap.h"
#define REVERB_FRAMES 131072
#define REVERB_TAPS 256
class Reverb {
private:
struct Tap {
size_t lp, rp;
float lg, rg;
};
DelayLine<REVERB_FRAMES> dl;
Tap taps[REVERB_TAPS];
float lpfL = 0.f, lpfR = 0.f;
float hpfL = 0.f, hpfR = 0.f;
public:
float mix = 0.25f;
Reverb();
frame tick(frame in) {
dl.tick(in);
frame out{0, 0};
for(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 mix * out + (1 - mix) * in;
}
};
#endif