MuseScore  3.4
Music composition and notation
freeverb.h
Go to the documentation of this file.
1 /*
2  Freeverb
3 
4  Written by Jezar at Dreampoint, June 2000
5  http://www.dreampoint.co.uk
6  This code is public domain
7 
8  modified for MuseScore Werner Schweer, 2009
9 */
10 
11 #ifndef _REV_H
12 #define _REV_H
13 
14 #include "effects/effect.h"
15 
16 static const int numcombs = 8;
17 static const int numallpasses = 4;
18 
19 //---------------------------------------------------------
20 // Allpass
21 //---------------------------------------------------------
22 
23 class Allpass {
24  float feedback;
25  float* buffer;
26  int bufsize;
27  int bufidx;
28 
29  public:
30  void setbuffer(int size);
31  void setfeedback(float val) { feedback = val; }
32  float getfeedback() const { return feedback; }
33 
34  float process(float _input) {
35  float bufout = buffer[bufidx];
36  float output = bufout - _input;
37  buffer[bufidx] = _input + (bufout * feedback);
38  ++bufidx %= bufsize;
39  return output;
40  }
41  };
42 
43 //---------------------------------------------------------
44 // Comb
45 //---------------------------------------------------------
46 
47 class Comb {
48  float feedback;
49  float filterstore;
50  float damp1;
51  float damp2;
52  float* buffer;
53  int bufsize;
54  int bufidx;
55 
56  public:
57  void setbuffer(int size);
58  void setdamp(float val);
59  float getdamp() const { return damp1; }
60  void setfeedback(float val) { feedback = val; }
61  float getfeedback() const { return feedback; }
62 
63  float process(float input) {
64  float tmp = buffer[bufidx];
65  filterstore = (tmp * damp2) + (filterstore * damp1);
66  buffer[bufidx] = input + (filterstore * feedback);
67  ++bufidx %= bufsize;
68  return tmp;
69  }
70  };
71 
72 //---------------------------------------------------------
73 // Freeverb
74 //---------------------------------------------------------
75 
76 class Freeverb : public Effect {
77  //Q_OBJECT
78 
79  float roomsize, damp, width, sendLevel, wet;
80  float newRoomsize, newDamp, newWidth, newSendLevel, newWet;
81  float wet1, wet2;
83 
84  Comb combL[numcombs];
85  Comb combR[numcombs];
86 
87  Allpass allpassL[numallpasses];
88  Allpass allpassR[numallpasses];
89 
90  void update();
91 
92  public:
93  Freeverb();
94  virtual void process(int n, float* in, float* out);
95 
96  virtual void setNValue(int idx, double value);
97  virtual double nvalue(int idx) const;
98 
99  bool setPreset(int);
100  virtual const char* name() const { return "Freeverb"; }
101  virtual EffectGui* gui();
102  virtual const std::vector<ParDescr>& parDescr() const;
103  };
104 
105 #endif
float wet2
Definition: freeverb.h:81
float process(float _input)
Definition: freeverb.h:34
float getdamp() const
Definition: freeverb.h:59
float process(float input)
Definition: freeverb.h:63
void setfeedback(float val)
Definition: freeverb.h:31
float getfeedback() const
Definition: freeverb.h:61
int bufsize
Definition: freeverb.h:26
float * buffer
Definition: freeverb.h:52
int bufidx
Definition: freeverb.h:54
bool parameterChanged
Definition: freeverb.h:82
float newWidth
Definition: freeverb.h:80
float damp1
Definition: freeverb.h:50
Definition: freeverb.h:23
float feedback
Definition: freeverb.h:24
float filterstore
Definition: freeverb.h:49
virtual const char * name() const
Definition: freeverb.h:100
void setbuffer(int size)
Definition: freeverb.cpp:71
int bufsize
Definition: freeverb.h:53
Definition: freeverb.h:76
float width
Definition: freeverb.h:79
float feedback
Definition: freeverb.h:48
float getfeedback() const
Definition: freeverb.h:32
float damp2
Definition: freeverb.h:51
int bufidx
Definition: freeverb.h:27
float * buffer
Definition: freeverb.h:25
Definition: freeverb.h:47
void setfeedback(float val)
Definition: freeverb.h:60