-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRepeatSine.cpp
66 lines (53 loc) · 1.27 KB
/
RepeatSine.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
60
61
62
63
64
65
66
#include "RepeatSine.h"
using namespace std;
using namespace Marsyas;
using namespace MarsyasGuitarEffects;
RepeatSine::RepeatSine (mrs_string name): MarSystem("RepeatSine", name)
{
amount_ = 0;
addControls();
}
RepeatSine::~RepeatSine (void)
{
}
MarSystem* RepeatSine::clone (void) const
{
return new RepeatSine(*this);
}
void RepeatSine::addControls (void)
{
addctrl("mrs_natural/amount", 0, ctrl_amount_);
setctrlState("mrs_natural/amount", true);
}
void RepeatSine::myUpdate (MarControlPtr sender)
{
amount_ = ctrl_amount_->to<mrs_natural>();
MarSystem::myUpdate(sender);
}
void RepeatSine::myProcess (realvec& in, realvec& out)
{
mrs_natural t, o, i;
for (o = 0; o < inObservations_; o++ ) {
mrs_real max(0.0001); // in case input is silent
for (t = 0; t < inSamples_; t++ ) {
mrs_real comp = abs(in(o, t));
if (comp > max) {
max = comp;
}
}
//mrs_real norm(0.0);
//for (t = 0; t < inSamples_; t++ ) {
// norm += out(o, t) * out(o, t);
//}
//norm = sqrt(norm);
for (t = 0; t < inSamples_; t++ ) {
out(o, t) = in(o, t) / max;
for (i = 0; i < amount_; i++ ) {
out(o, t) = sin(out(o, t));
}
}
for (t = 0; t < inSamples_; t++ ) {
out(o, t) *= max;
}
}
}