diff --git a/plugin/chassis.cpp b/plugin/chassis.cpp index 9e999be..9e502f0 100644 --- a/plugin/chassis.cpp +++ b/plugin/chassis.cpp @@ -27,6 +27,66 @@ Chassis::Chassis() : Plugin(parameterCount, 0, 0), sampleRate(getSampleRate()) { void Chassis::initParameter(uint32_t index, Parameter ¶meter) { switch (index) { + case paramLFORate: + parameter.hints = kParameterIsAutomatable; + parameter.name = "LFO Rate"; + parameter.symbol = "ch_lforate"; + parameter.ranges.min = 0.0f; + parameter.ranges.max = 127.0f; + parameter.ranges.def = 57.0f; + parameter.midiCC = 3; + break; + + case paramLFODelay: + parameter.hints = kParameterIsAutomatable; + parameter.name = "LFO Delay"; + parameter.symbol = "ch_lfodelay"; + parameter.ranges.min = 0.0f; + parameter.ranges.max = 127.0f; + parameter.ranges.def = 45.0f; + parameter.midiCC = 9; + break; + + case paramVCORange: + parameter.hints = kParameterIsAutomatable | kParameterIsInteger; + parameter.name = "Range"; + parameter.symbol = "ch_vcorange"; + parameter.ranges.min = 0.0f; + parameter.ranges.max = 4.0f; + parameter.ranges.def = 2.0f; + parameter.midiCC = 12; + break; + + case paramVCOLFO: + parameter.hints = kParameterIsAutomatable; + parameter.name = "LFO"; + parameter.symbol = "ch_lfo"; + parameter.ranges.min = 0.0f; + parameter.ranges.max = 127.0f; + parameter.ranges.def = 0.0f; + parameter.midiCC = 13; + break; + + case paramPWMLFO: + parameter.hints = kParameterIsAutomatable; + parameter.name = "PWM"; + parameter.symbol = "ch_pwm"; + parameter.ranges.min = 0.0f; + parameter.ranges.max = 127.0f; + parameter.ranges.def = 55.0f; + parameter.midiCC = 14; + break; + + case paramPWMMode: + parameter.hints = kParameterIsAutomatable | kParameterIsBoolean; + parameter.name = "LFO/Manual"; + parameter.symbol = "ch_pwmmode"; + parameter.ranges.min = 0.0f; + parameter.ranges.max = 127.0f; + parameter.ranges.def = 0.0f; + parameter.midiCC = 15; + break; + case paramSaw: parameter.hints = kParameterIsAutomatable | kParameterIsBoolean; parameter.name = "Saw"; @@ -57,6 +117,81 @@ void Chassis::initParameter(uint32_t index, Parameter ¶meter) { parameter.midiCC = 18; break; + case paramNoise: + parameter.hints = kParameterIsAutomatable; + parameter.name = "Noise"; + parameter.symbol = "ch_noise"; + parameter.ranges.min = 0.0f; + parameter.ranges.max = 127.0f; + parameter.ranges.def = 0.0f; + parameter.midiCC = 19; + break; + + case paramHPF: + parameter.hints = kParameterIsAutomatable | kParameterIsInteger; + parameter.name = "HPF"; + parameter.symbol = "ch_hpf"; + parameter.ranges.min = 0.0f; + parameter.ranges.max = 4.0f; + parameter.ranges.def = 0.0f; + parameter.midiCC = 20; + break; + + case paramVCFFreq: + parameter.hints = kParameterIsAutomatable; + parameter.name = "Freq"; + parameter.symbol = "ch_freq"; + parameter.ranges.min = 0.0f; + parameter.ranges.max = 127.0f; + parameter.ranges.def = 0.0f; + parameter.midiCC = 74; + break; + case paramVCFReso: + parameter.hints = kParameterIsAutomatable; + parameter.name = "Res"; + parameter.symbol = "ch_reso"; + parameter.ranges.min = 0.0f; + parameter.ranges.max = 127.0f; + parameter.ranges.def = 0.0f; + parameter.midiCC = 74; + break; + case paramVCFMode: + parameter.hints = kParameterIsAutomatable | kParameterIsBoolean; + parameter.name = "Polarity"; + parameter.symbol = "ch_vcfmode"; + parameter.ranges.min = 0.0f; + parameter.ranges.max = 127.0f; + parameter.ranges.def = 0.0f; + parameter.midiCC = 21; + break; + case paramVCFEnv: + parameter.hints = kParameterIsAutomatable; + parameter.name = "Env"; + parameter.symbol = "ch_vcfenv"; + parameter.ranges.min = 0.0f; + parameter.ranges.max = 127.0f; + parameter.ranges.def = 0.0f; + parameter.midiCC = 22; + break; + case paramVCFLFO: + parameter.hints = kParameterIsAutomatable; + parameter.name = "LFO"; + parameter.symbol = "ch_vcflfo"; + parameter.ranges.min = 0.0f; + parameter.ranges.max = 127.0f; + parameter.ranges.def = 0.0f; + parameter.midiCC = 23; + break; + case paramVCFKey: + parameter.hints = kParameterIsAutomatable; + parameter.name = "Kybd"; + parameter.symbol = "ch_vcfkey"; + parameter.ranges.min = 0.0f; + parameter.ranges.max = 127.0f; + parameter.ranges.def = 0.0f; + parameter.midiCC = 24; + break; + case paramAttack: parameter.hints = kParameterIsAutomatable; parameter.name = "Attack"; @@ -120,8 +255,32 @@ void Chassis::initParameter(uint32_t index, Parameter ¶meter) { } void Chassis::setParameterValue(uint32_t index, float value) { - // printf("setparametervalue %d\n", index); + // should be trapped by host, but let's be safe + if (value < 0.0f) value = 0.0f; + if (value > 127.0f) value = 127.0f; + switch (index) { + case paramLFORate: + s.patchRam.lfoRate = value; + break; + case paramLFODelay: + s.patchRam.lfoDelay = value; + break; + + case paramVCORange: + // bits 0-2 of switch 1 + // doesn't look great in Carla because of odd behaviour with small integer knobs + s.patchRam.switch1 &= 0xf8; + s.patchRam.switch1 |= (1 << (int)value); + break; + + case paramVCOLFO: + s.patchRam.vcoLfo = value; + break; + case paramPWMLFO: + s.patchRam.pwmLfo = value; + break; + case paramSaw: s.patchRam.switch1 &= 0xef; s.patchRam.switch1 |= (value > 63) << 4; diff --git a/plugin/chassis.hpp b/plugin/chassis.hpp index efb114e..11a867a 100644 --- a/plugin/chassis.hpp +++ b/plugin/chassis.hpp @@ -32,15 +32,35 @@ START_NAMESPACE_DISTRHO class Chassis : public Plugin { public: enum Parameters { + paramLFORate, + paramLFODelay, + + paramVCORange, + paramVCOLFO, + paramPWMLFO, + paramPWMMode, paramSaw, paramSqr, paramSub, + paramNoise, + + paramHPF, + + paramVCFFreq, + paramVCFReso, + paramVCFMode, + paramVCFEnv, + paramVCFLFO, + paramVCFKey, + + paramEnvGate, + paramVCALevel, + paramAttack, paramDecay, paramSustain, paramRelease, - paramEnvGate, - paramVCALevel, + parameterCount }; diff --git a/plugin/voice.cpp b/plugin/voice.cpp index ff9be2a..4c7b3b0 100644 --- a/plugin/voice.cpp +++ b/plugin/voice.cpp @@ -141,7 +141,12 @@ static inline float poly3blep1(float t) { } void Voice::run(Synth &s, float *buffer, uint32_t samples) { - float y, out, pw = 0.5, t; + float y, out, t; + + // 325, because it needs PW to be from 0 to 0.5 + // but really the control range is limited from 0 to 100 + // there's a resistor on the panel board to sprag the range + float pw = 0.5 - s.patchRam.pwmLfo/325.0f; float sqr = (s.patchRam.switch1 & 0x08) ? 0.175 : 0; float saw = (s.patchRam.switch1 & 0x10) ? 0.220 : 0; diff --git a/plugin/voice.hpp b/plugin/voice.hpp index 5c0c282..6d64506 100644 --- a/plugin/voice.hpp +++ b/plugin/voice.hpp @@ -123,16 +123,16 @@ class Synth { // around and memcpy() values from sysex on top of it struct { - uint8_t lfo_rate = 57; - uint8_t lfo_delay = 45; - uint8_t lfo_dco = 0; - uint8_t lfo_pwm = 55; + uint8_t lfoRate = 57; + uint8_t lfoDelay = 45; + uint8_t vcoLfo = 0; + uint8_t pwmLfo = 55; uint8_t noise = 0; - uint8_t vcf_cut = 85; - uint8_t vcf_res = 0; - uint8_t vcf_env = 0; - uint8_t vcf_lfo = 0; - uint8_t vcf_kyb = 108; + uint8_t vcfFreq = 85; + uint8_t vcfResp = 0; + uint8_t vcfEnv = 0; + uint8_t vcfLfo = 0; + uint8_t vcfKey = 108; uint8_t vca = 52; uint8_t env_a = 59; uint8_t env_d = 32;