From f1b054ec6554607454b06d1e037f0b6ec908c07b Mon Sep 17 00:00:00 2001 From: Aleks Rutins Date: Sat, 15 Apr 2023 20:17:02 -0400 Subject: [PATCH] Actually use the ports from the generated PEG --- plugin.cc | 35 +++++++++-------------------------- plugin.hh | 10 ++-------- 2 files changed, 11 insertions(+), 34 deletions(-) diff --git a/plugin.cc b/plugin.cc index d06aa28..c04731d 100644 --- a/plugin.cc +++ b/plugin.cc @@ -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]); } } -} \ No newline at end of file +} diff --git a/plugin.hh b/plugin.hh index 396617c..57b8617 100644 --- a/plugin.hh +++ b/plugin.hh @@ -1,6 +1,7 @@ #pragma once #include #include +#include "dynamite.peg" using namespace LV2; @@ -10,15 +11,8 @@ namespace Dynamite { }; class Drive : public Plugin { - const float *drive; - const float *threshold; - const float *gain; - const float *mix; - const float *input; - float *output; public: - Drive(double rate) : Plugin(1) {} - void connect_port(uint32_t port, void* data); + Drive(double rate) : Plugin(p_n_ports) {} void run(uint32_t n_samples); }; } \ No newline at end of file