start adding parameters

This commit is contained in:
Gordon JC Pearce 2025-08-18 11:52:21 +01:00
parent d5394a1fe2
commit 81b17f1a0a
4 changed files with 87 additions and 12 deletions

View File

@ -9,7 +9,7 @@
NAME = sonnenlicht
FILES_DSP = assigner.cpp generator.cpp chorus.cpp svf.cpp sonnenlicht.cpp
FILES_DSP = assigner.cpp generator.cpp chorus.cpp svf.cpp parameters.cpp sonnenlicht.cpp
include ../dpf/Makefile.plugins.mk
TARGETS += vst2 vst3 jack lv2_dsp

80
plugin/parameters.cpp Normal file
View File

@ -0,0 +1,80 @@
/*
sonnenlicht poly ensemble
Copyright 2025 Gordon JC Pearce <gordonjcp@gjcp.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "sonnenlicht.hpp"
void Sonnenlicht::initParameter(uint32_t index, Parameter& parameter) {
// define all the different control input parameters
switch (index) {
case pViola:
parameter.hints = kParameterIsAutomatable | kParameterIsBoolean;
parameter.name = "Viola";
parameter.symbol = "s_viola";
parameter.ranges.def = 1;
break;
case pViolin:
parameter.hints = kParameterIsAutomatable | kParameterIsBoolean;
parameter.name = "Violin";
parameter.symbol = "s_violin";
parameter.ranges.def = 1;
break;
case pBassVolume:
parameter.hints = kParameterIsAutomatable;
parameter.name = "Bass Volume";
parameter.symbol = "s_bassvol";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
parameter.ranges.def = 0.7f;
break;
}
}
void Sonnenlicht::setParameterValue(uint32_t index, float value) {
switch (index) {
case pViola:
viola = value;
break;
case pViolin:
violin = value;
break;
case pBassVolume:
bassVolume = value;
default:
break;
}
// we don't need to handle a default condition
// if there's a parameter left unhandled, it's probably
// a mistake by the plugin host, and we don't much care
}
float Sonnenlicht::getParameterValue(uint32_t index) const {
switch (index) {
case pViola:
return viola;
case pBassVolume:
return bassVolume;
default:
return 0;
}
// if we fall all the way through...
return 2;
}

View File

@ -35,10 +35,6 @@ Sonnenlicht::~Sonnenlicht() {
delete chorus;
}
void Sonnenlicht::setParameterValue(uint32_t index, float value) {
printf("got parameter %d, %f\n", index, value);
}
void Sonnenlicht::initAudioPort(bool input, uint32_t index, AudioPort& port) {
port.groupId = kPortGroupStereo;
Plugin::initAudioPort(input, index, port);
@ -53,12 +49,6 @@ void Sonnenlicht::activate() {
void Sonnenlicht::deactivate() {
}
void Sonnenlicht::initParameter(uint32_t index, Parameter& parameter) {
(void)index;
(void)&parameter; // pretend these aren't here
return;
}
void Sonnenlicht::run(const float**, float** outputs, uint32_t frames,
const MidiEvent* ev, uint32_t evCount) {
for (uint32_t i = 0; i < evCount; i++) {

View File

@ -21,14 +21,17 @@
#include "DistrhoPlugin.hpp"
#include "assigner.hpp"
#include "generator.hpp"
#include "chorus.hpp"
#include "generator.hpp"
START_NAMESPACE_DISTRHO
class Sonnenlicht : public Plugin {
public:
enum Parameters {
pViola,
pViolin,
pBassVolume,
kParameterCount
};
@ -47,6 +50,7 @@ class Sonnenlicht : public Plugin {
void initParameter(uint32_t index, Parameter &parameter) override;
void setParameterValue(uint32_t index, float value) override;
float getParameterValue(uint32_t index) const override;
// Initialisation
void initAudioPort(bool input, uint32_t index, AudioPort &port) override;
@ -59,6 +63,7 @@ class Sonnenlicht : public Plugin {
const MidiEvent *midiEvents, uint32_t midiEventCount) override;
private:
float viola = 0, violin = 0, bassVolume = 0;
double fSampleRate;
Assigner *assigner;
Generator *genny;