From ca653441f95328909820149a474fc422580b4499 Mon Sep 17 00:00:00 2001 From: Gordon JC Pearce Date: Wed, 5 Feb 2025 23:48:58 +0000 Subject: [PATCH] uses patches a bit --- plugin/Makefile | 1 + plugin/chassis.cpp | 8 ++++++-- plugin/chassis.hpp | 26 +++++++++++++++++++++++--- patches.hpp => plugin/patches.hpp | 3 --- plugin/ui.cpp | 22 +++++++++++++++++++--- 5 files changed, 49 insertions(+), 11 deletions(-) rename patches.hpp => plugin/patches.hpp (99%) diff --git a/plugin/Makefile b/plugin/Makefile index 9bfe9ed..1683a6c 100644 --- a/plugin/Makefile +++ b/plugin/Makefile @@ -10,6 +10,7 @@ NAME = chassis FILES_DSP = \ + parameters.cpp \ chassis.cpp diff --git a/plugin/chassis.cpp b/plugin/chassis.cpp index 3b9b10b..a9319b1 100644 --- a/plugin/chassis.cpp +++ b/plugin/chassis.cpp @@ -1,6 +1,8 @@ #include "chassis.hpp" +#include "patches.hpp" + START_NAMESPACE_DISTRHO Chassis::Chassis() : Plugin(parameterCount, 128, 0), sampleRate(getSampleRate()) { @@ -18,11 +20,13 @@ void Chassis::initAudioPort(bool input, uint32_t index, AudioPort &port) { } void Chassis::initProgramName(uint32_t index, String &programName) { - return; + programName = patchName[index & 0x7f].c_str(); + //printf("prog = %s\n", patchName[index]); } void Chassis::loadProgram(uint32_t index) { - return; + index &= 0x7f; + memmove(&patchRam, (uint8_t *)patchData + (index * 18), 18); } // Processing functions diff --git a/plugin/chassis.hpp b/plugin/chassis.hpp index dba033a..b2b0af0 100644 --- a/plugin/chassis.hpp +++ b/plugin/chassis.hpp @@ -67,10 +67,10 @@ class Chassis : public Plugin { // Initialisation void initAudioPort(bool input, uint32_t index, AudioPort &port) override; - // void initParameter(uint32_t index, Parameter ¶meter) override; + void initParameter(uint32_t index, Parameter ¶meter) override; - // void setParameterValue(uint32_t index, float value) override; - // float getParameterValue(uint32_t index) const override; + void setParameterValue(uint32_t index, float value) override; + float getParameterValue(uint32_t index) const override; void initProgramName(uint32_t index, String &programName) override; void loadProgram(uint32_t index) override; @@ -82,6 +82,26 @@ class Chassis : public Plugin { private: double sampleRate; + struct { + uint8_t lfoRate = 0x30; // lookup value defaults to 0x0200 + uint8_t lfoDelay = 0x00; + uint8_t vcoLfo = 0x0a; + uint8_t pwmLfo = 0x30; + uint8_t noise = 0x00; + uint8_t vcfFreq = 0x3c; // 0x3f80 + uint8_t vcfReso = 0x00; + uint8_t vcfEnv = 0x2e; + uint8_t vcfLfo = 0; + uint8_t vcfKey = 0x47; + uint8_t vca = 0x28; + uint8_t env_a = 0x1b; + uint8_t env_d = 0x39; + uint8_t env_s = 0x39; // 0x3f80 + uint8_t env_r = 0x30; + uint8_t sub = 0x00; + uint8_t switch1 = 0x1a; + uint8_t switch2 = 0x18; + } patchRam; DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Chassis); }; diff --git a/patches.hpp b/plugin/patches.hpp similarity index 99% rename from patches.hpp rename to plugin/patches.hpp index 8ce3af3..f7029f4 100644 --- a/patches.hpp +++ b/plugin/patches.hpp @@ -3,9 +3,6 @@ #include #include -#include "DistrhoPlugin.hpp" - - const std::string patchName[] = { "Brass Set 1", "Brass Swell", "Trumpet", "Flutes", "Moving Strings", "Brass & Strings", "Choir", "Piano I", "Organ I", "Organ II", "Combo Organ", "Calliope", "Donald Pluck", "Celeste* (1 oct.up)", "Elect. Piano I", diff --git a/plugin/ui.cpp b/plugin/ui.cpp index 2be3dea..7c5f0d8 100644 --- a/plugin/ui.cpp +++ b/plugin/ui.cpp @@ -144,7 +144,7 @@ DistrhoUIchassis::~DistrhoUIchassis() { } void DistrhoUIchassis::programLoaded(uint32_t index) { - // printf("in programLoaded %d\n", i + printf("in programLoaded %d\n", index); switch (index) { case Chassis::pLFORate: xSliderLFORate->setValue(0.5); @@ -160,12 +160,28 @@ void DistrhoUIchassis::parameterChanged(uint32_t index, float value) { // printf("in parameterchanged %d %f\n", index, value); if (index == Chassis::pLFORate) { xSliderLFORate->setValue(value); - printf("changed lforate\n"); } if (index == Chassis::pLFODelay) { xSliderLFODelay->setValue(value); - printf("changed lfoDelay\n"); } + + switch(index) { + case Chassis::pLFORate: xSliderLFORate->setValue(value); break; + case Chassis::pLFODelay: xSliderLFODelay->setValue(value); break; + case Chassis::pLFODepth: xSliderLFODepth->setValue(value); break; + case Chassis::pPWMDepth: xSliderPWMDepth->setValue(value); break; + case Chassis::pSubLevel: xSliderSubLevel->setValue(value); break; + case Chassis::pNoiseLevel: xSliderNoiseLevel->setValue(value); break; + case Chassis::pHPF: xSliderHPF->setValue(value); break; + case Chassis::pCutoff: xSliderCutoff->setValue(value); break; + case Chassis::pRes: xSliderRes->setValue(value); break; + case Chassis::pEnv: xSliderEnv->setValue(value); break; + case Chassis::pLfo: xSliderLfo->setValue(value); break; + case Chassis::pKyb: xSliderKyb->setValue(value); break; + + + } + } void DistrhoUIchassis::imageSliderDragStarted(ImageSlider* slider) {