-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCutoff.cpp
59 lines (49 loc) · 1.1 KB
/
Cutoff.cpp
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
#include "Cutoff.h"
using namespace std;
using namespace Marsyas;
using namespace MarsyasGuitarEffects;
Cutoff::Cutoff (mrs_string name): MarSystem("Cutoff", name)
{
amount_ = 0.0;
addControls();
}
Cutoff::~Cutoff (void)
{
}
MarSystem* Cutoff::clone (void) const
{
return new Cutoff(*this);
}
void Cutoff::addControls (void)
{
addctrl("mrs_real/amount", 0.0, ctrl_amount_);
setctrlState("mrs_real/amount", true);
}
void Cutoff::myUpdate (MarControlPtr sender)
{
amount_ = ctrl_amount_->to<mrs_real>();
MarSystem::myUpdate(sender);
}
void Cutoff::myProcess (realvec& in, realvec& out)
{
mrs_natural t, o;
for (o = 0; o < inObservations_; o++ ) {
mrs_real norm(0.0);
for (t = 0; t < inSamples_; t++ ) {
norm += in(o, t) * in(o, t);
}
norm = sqrt(norm);
mrs_real cut = (1 - amount_) / 100 * norm;
mrs_real minuscut = -cut;
for (t = 0; t < inSamples_; t++ ) {
mrs_real temp = in(o, t);
if (temp > cut) {
out(o, t) = cut;
} else if (temp < minuscut) {
out(o, t) = minuscut;
} else {
out(o, t) = in(o, t);
}
}
}
}