~ubuntu-branches/ubuntu/feisty/muse/feisty

« back to all changes in this revision

Viewing changes to plugins/freeverb/comb.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2002-04-23 17:28:23 UTC
  • Revision ID: james.westby@ubuntu.com-20020423172823-w8yplzr81a759xa3
Tags: upstream-0.5.2
ImportĀ upstreamĀ versionĀ 0.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Comb filter class declaration
 
2
//
 
3
// Written by Jezar at Dreampoint, June 2000
 
4
// http://www.dreampoint.co.uk
 
5
// This code is public domain
 
6
 
 
7
#ifndef _comb_
 
8
#define _comb_
 
9
 
 
10
#include "denormals.h"
 
11
 
 
12
 
 
13
//---------------------------------------------------------
 
14
//   comb
 
15
//---------------------------------------------------------
 
16
 
 
17
class comb
 
18
      {
 
19
        float   feedback;
 
20
        float   filterstore;
 
21
        float   damp1;
 
22
        float   damp2;
 
23
        float   *buffer;
 
24
        int bufsize;
 
25
        int bufidx;
 
26
 
 
27
public:
 
28
      comb() {
 
29
              filterstore = 0;
 
30
              bufidx = 0;
 
31
            }
 
32
        void    setbuffer(float *buf, int size) {
 
33
              buffer = buf;
 
34
              bufsize = size;
 
35
            }
 
36
      float process(float input) {
 
37
        float output = buffer[bufidx];
 
38
              undenormalise(output);
 
39
        filterstore = (output*damp2) + (filterstore*damp1);
 
40
              undenormalise(filterstore);
 
41
        buffer[bufidx] = input + (filterstore*feedback);
 
42
            if (++bufidx >= bufsize)
 
43
                  bufidx = 0;
 
44
//            bufidx = ++bufidx % bufsize;
 
45
        return output;
 
46
            }
 
47
        void    mute() {
 
48
        for (int i=0; i<bufsize; i++)
 
49
                buffer[i]=0;
 
50
            }
 
51
        void    setdamp(float val) {
 
52
              damp1 = val;
 
53
              damp2 = 1-val;
 
54
            }
 
55
        float   getdamp()              { return damp1; }
 
56
        void    setfeedback(float val) { feedback = val; }
 
57
        float   getfeedback()          { return feedback; }
 
58
      };
 
59
 
 
60
 
 
61
// Big to inline - but crucial for speed
 
62
 
 
63
 
 
64
#endif //_comb_
 
65
 
 
66
//ends