-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdistortion.cpp
executable file
·36 lines (29 loc) · 1.13 KB
/
distortion.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
#include "distortion.h"
void Distortion::setTimbre(float timbre){
cout << bypass;
this->timbre = timbre;
}
void Distortion::setDepth(float depth){
this->depth = depth;
}
//processing samples
void Distortion::process_samples(float *inputbuffer, float *outputbuffer)
{
if (bypass == 1) {
for(int bufptr=0; bufptr<FRAMESPERBUFFER; bufptr++) {
outputbuffer[bufptr] = inputbuffer[bufptr];
}
}
else {
timbreInverse = (1 - (timbre * 0.099)) * 10; //inverse scaling from timbre
for(int bufptr=0; bufptr<FRAMESPERBUFFER; bufptr++) {
inputbuffer[bufptr] = inputbuffer[bufptr] * depth;
inputbuffer[bufptr] = tanh((inputbuffer[bufptr] * (timbre + 1)));
inputbuffer[bufptr] = (inputbuffer[bufptr] * ((0.1 + timbre) * timbreInverse));
inputbuffer[bufptr] = cos((inputbuffer[bufptr] + (timbre + 0.25)));
inputbuffer[bufptr] = tanh(inputbuffer[bufptr] * (timbre + 1));
inputbuffer[bufptr] = inputbuffer[bufptr] * 0.125;
outputbuffer[bufptr] = inputbuffer[bufptr];
}
}
}