blob: 5d70e0b13475ec1aa63d147997aad902dc7d98f4 (
plain)
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
|
//=========================================================
// MusE
// Linux Music Editor
// $Id: ./plugins/freeverb/comb.h $
//
// Written by Jezar at Dreampoint, June 2000
// http://www.dreampoint.co.uk
// This code is public domain
//
//=========================================================
// Comb filter class declaration
//
#ifndef _comb_
#define _comb_
#include "denormals.h"
//---------------------------------------------------------
// comb
//---------------------------------------------------------
class comb
{
float feedback;
float filterstore;
float damp1;
float damp2;
float *buffer;
int bufsize;
int bufidx;
public:
comb() {
filterstore = 0;
bufidx = 0;
}
void setbuffer(float *buf, int size) {
buffer = buf;
bufsize = size;
}
float process(float input) {
float output = buffer[bufidx];
undenormalise(output);
filterstore = (output*damp2) + (filterstore*damp1);
undenormalise(filterstore);
buffer[bufidx] = input + (filterstore*feedback);
if (++bufidx >= bufsize)
bufidx = 0;
// bufidx = ++bufidx % bufsize;
return output;
}
void mute() {
for (int i=0; i<bufsize; i++)
buffer[i]=0;
}
void setdamp(float val) {
damp1 = val;
damp2 = 1-val;
}
float getdamp() { return damp1; }
void setfeedback(float val) { feedback = val; }
float getfeedback() { return feedback; }
};
// Big to inline - but crucial for speed
#endif //_comb_
//ends
|