-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.cc
40 lines (29 loc) · 1.24 KB
/
plugin.cc
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
#include "plugin.hh"
#include <cmath>
#include "util.hh"
using namespace std;
namespace Dynamite {
void Drive::run(uint32_t n_samples) {
const float coeff = dbCo(*p(p_drive));
const float threshCoeff = dbCo(*p(p_threshold));
const float gainCoeff = dbCo(*p(p_gain));
const float mix = *p(p_mix);
const float algoMix = *p(p_algorithm_mix);
const float transmogrifier = dbCo(*p(p_transmogrify_gain));
const float transmogrifyThreshold = dbCo(*p(p_transmogrify_threshold));
const float *input = p(p_audio_in);
float *output = p(p_audio_out);
for(uint32_t pos = 0; pos < n_samples; pos++) {
float dist = input[pos] * coeff;
if(dist > threshCoeff) {
dist = threshCoeff;
} else if (dist < -threshCoeff) {
dist = -threshCoeff;
}
dist = dist * gainCoeff;
float transmogrified = (input[pos] < 0 ? -transmogrifier : transmogrifier);
if(abs(input[pos]) < transmogrifyThreshold) transmogrified = 0;
output[pos] = (mix * ((algoMix * transmogrified) + ((1.0 - algoMix) * dist))) + ((1.0 - mix) * input[pos] * coeff * threshCoeff * gainCoeff);
}
}
}