Actually use the ports from the generated PEG

This commit is contained in:
Aleks Rutins 2023-04-15 20:17:02 -04:00
parent f26a5265f6
commit f1b054ec65
2 changed files with 11 additions and 34 deletions

View file

@ -2,31 +2,14 @@
#include "util.hh"
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) {
const float coeff = dbCo(*drive);
const float threshCoeff = dbCo(*threshold);
const float gainCoeff = dbCo(*gain);
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 *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;
@ -39,7 +22,7 @@ namespace Dynamite {
dist = dist * gainCoeff;
output[pos] = (*mix * dist) + ((1.0 - *mix) * input[pos]);
output[pos] = (mix * dist) + ((1.0 - mix) * input[pos]);
}
}
}
}

View file

@ -1,6 +1,7 @@
#pragma once
#include <lv2plugin.hpp>
#include <stdint.h>
#include "dynamite.peg"
using namespace LV2;
@ -10,15 +11,8 @@ namespace Dynamite {
};
class Drive : public Plugin<Drive> {
const float *drive;
const float *threshold;
const float *gain;
const float *mix;
const float *input;
float *output;
public:
Drive(double rate) : Plugin<Drive>(1) {}
void connect_port(uint32_t port, void* data);
Drive(double rate) : Plugin<Drive>(p_n_ports) {}
void run(uint32_t n_samples);
};
}