Actually use the ports from the generated PEG
This commit is contained in:
parent
f26a5265f6
commit
f1b054ec65
2 changed files with 11 additions and 34 deletions
33
plugin.cc
33
plugin.cc
|
@ -2,31 +2,14 @@
|
||||||
#include "util.hh"
|
#include "util.hh"
|
||||||
|
|
||||||
namespace Dynamite {
|
namespace Dynamite {
|
||||||
void Drive::connect_port(uint32_t port, void* data) {
|
|
||||||
switch((PluginPort)port) {
|
|
||||||
case IN:
|
|
||||||
input = (const float *)data;
|
|
||||||
break;
|
|
||||||
case OUT:
|
|
||||||
output = (float *)data;
|
|
||||||
break;
|
|
||||||
case DRIVE:
|
|
||||||
drive = (const float *)data;
|
|
||||||
break;
|
|
||||||
case THRESHOLD:
|
|
||||||
threshold = (const float *)data;
|
|
||||||
break;
|
|
||||||
case GAIN:
|
|
||||||
gain = (const float *)data;
|
|
||||||
case MIX:
|
|
||||||
mix = (const float *)data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Drive::run(uint32_t n_samples) {
|
void Drive::run(uint32_t n_samples) {
|
||||||
const float coeff = dbCo(*drive);
|
const float coeff = dbCo(*p(p_drive));
|
||||||
const float threshCoeff = dbCo(*threshold);
|
const float threshCoeff = dbCo(*p(p_threshold));
|
||||||
const float gainCoeff = dbCo(*gain);
|
const float gainCoeff = dbCo(*p(p_gain));
|
||||||
|
const float mix = *p(p_mix);
|
||||||
|
|
||||||
|
const float *input = p(p_audio_in);
|
||||||
|
float *output = p(p_audio_out);
|
||||||
|
|
||||||
for(uint32_t pos = 0; pos < n_samples; pos++) {
|
for(uint32_t pos = 0; pos < n_samples; pos++) {
|
||||||
float dist = input[pos] * coeff;
|
float dist = input[pos] * coeff;
|
||||||
|
@ -39,7 +22,7 @@ namespace Dynamite {
|
||||||
|
|
||||||
dist = dist * gainCoeff;
|
dist = dist * gainCoeff;
|
||||||
|
|
||||||
output[pos] = (*mix * dist) + ((1.0 - *mix) * input[pos]);
|
output[pos] = (mix * dist) + ((1.0 - mix) * input[pos]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
10
plugin.hh
10
plugin.hh
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <lv2plugin.hpp>
|
#include <lv2plugin.hpp>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include "dynamite.peg"
|
||||||
|
|
||||||
using namespace LV2;
|
using namespace LV2;
|
||||||
|
|
||||||
|
@ -10,15 +11,8 @@ namespace Dynamite {
|
||||||
};
|
};
|
||||||
|
|
||||||
class Drive : public Plugin<Drive> {
|
class Drive : public Plugin<Drive> {
|
||||||
const float *drive;
|
|
||||||
const float *threshold;
|
|
||||||
const float *gain;
|
|
||||||
const float *mix;
|
|
||||||
const float *input;
|
|
||||||
float *output;
|
|
||||||
public:
|
public:
|
||||||
Drive(double rate) : Plugin<Drive>(1) {}
|
Drive(double rate) : Plugin<Drive>(p_n_ports) {}
|
||||||
void connect_port(uint32_t port, void* data);
|
|
||||||
void run(uint32_t n_samples);
|
void run(uint32_t n_samples);
|
||||||
};
|
};
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue