File: freeverb.h

package info (click to toggle)
musescore 2.3.2%2Bdfsg2-7~deb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 187,932 kB
  • sloc: cpp: 264,610; xml: 176,707; sh: 3,311; ansic: 1,384; python: 356; makefile: 188; perl: 82; pascal: 78
file content (105 lines) | stat: -rw-r--r-- 2,679 bytes parent folder | download | duplicates (12)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
  Freeverb

  Written by Jezar at Dreampoint, June 2000
  http://www.dreampoint.co.uk
  This code is public domain

  modified for MuseScore Werner Schweer, 2009
*/

#ifndef _REV_H
#define _REV_H

#include "effects/effect.h"

static const int numcombs = 8;
static const int numallpasses = 4;

//---------------------------------------------------------
//   Allpass
//---------------------------------------------------------

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

   public:
      void setbuffer(int size);
      void setfeedback(float val) { feedback = val;  }
      float getfeedback() const   { return feedback; }

      float process(float _input) {
            float bufout   = buffer[bufidx];
            float output   = bufout - _input;
            buffer[bufidx] = _input + (bufout * feedback);
            ++bufidx      %= bufsize;
            return output;
            }
      };

//---------------------------------------------------------
//   Comb
//---------------------------------------------------------

class Comb {
      float feedback;
      float filterstore;
      float damp1;
      float damp2;
      float* buffer;
      int bufsize;
      int bufidx;

   public:
      void setbuffer(int size);
      void setdamp(float val);
      float getdamp() const       { return damp1;    }
      void setfeedback(float val) { feedback = val;  }
      float getfeedback() const   { return feedback; }

      float process(float input) {
            float tmp      = buffer[bufidx];
            filterstore    = (tmp * damp2) + (filterstore * damp1);
            buffer[bufidx] = input + (filterstore * feedback);
            ++bufidx      %= bufsize;
            return tmp;
            }
      };

//---------------------------------------------------------
//   Freeverb
//---------------------------------------------------------

class Freeverb : public Effect {
      //Q_OBJECT

      float roomsize, damp, width, sendLevel, wet;
      float newRoomsize, newDamp, newWidth, newSendLevel, newWet;
      float wet1, wet2;
      bool parameterChanged;

      Comb combL[numcombs];
      Comb combR[numcombs];

      Allpass allpassL[numallpasses];
      Allpass allpassR[numallpasses];

      void update();

   public:
      Freeverb();
      virtual void process(int n, float* in, float* out);

      virtual void setNValue(int idx, double value);
      virtual double nvalue(int idx) const;

      bool setPreset(int);
      virtual const char* name() const { return "Freeverb"; }
      virtual EffectGui* gui();
      virtual const std::vector<ParDescr>& parDescr() const;
      };

#endif