summaryrefslogtreecommitdiff
path: root/muse_qt4_evolution/plugins/freeverb/allpass.h
blob: 2f27691e28a901cd786920ecd30af1ef3ada6d98 (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
// Allpass filter declaration
//
// Written by Jezar at Dreampoint, June 2000
// http://www.dreampoint.co.uk
// This code is public domain

#ifndef _allpass_
#define _allpass_
#include "denormals.h"

//---------------------------------------------------------
//   allpass
//---------------------------------------------------------

class allpass
      {
	float	feedback;
	float	*buffer;
	int bufsize;
	int bufidx;

   public:
      allpass() { bufidx = 0; }
	void	setbuffer(float *buf, int size) {
      	buffer = buf;
	      bufsize = size;
            }
      float process(float input) {
	      float bufout = buffer[bufidx];
      	undenormalise(bufout);
	      float output = -input + bufout;
      	buffer[bufidx] = input + (bufout*feedback);
            if (++bufidx >= bufsize)
                  bufidx = 0;
//            bufidx = ++bufidx % bufsize;
      	return output;
            }
	void	mute() {
      	for (int i=0; i<bufsize; i++)
	      	buffer[i]=0;
            }
	void	setfeedback(float val)  { feedback = val; }
	float	getfeedback()           { return feedback; }
      };


#endif//_allpass