cleaned up some names, pwm works, knobs all present

This commit is contained in:
Gordon JC Pearce 2024-09-08 21:50:42 +01:00
parent 5f1d620a46
commit 0274204809
4 changed files with 197 additions and 13 deletions

View File

@ -27,6 +27,66 @@ Chassis::Chassis() : Plugin(parameterCount, 0, 0), sampleRate(getSampleRate()) {
void Chassis::initParameter(uint32_t index, Parameter &parameter) { void Chassis::initParameter(uint32_t index, Parameter &parameter) {
switch (index) { 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: case paramSaw:
parameter.hints = kParameterIsAutomatable | kParameterIsBoolean; parameter.hints = kParameterIsAutomatable | kParameterIsBoolean;
parameter.name = "Saw"; parameter.name = "Saw";
@ -57,6 +117,81 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.midiCC = 18; parameter.midiCC = 18;
break; 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: case paramAttack:
parameter.hints = kParameterIsAutomatable; parameter.hints = kParameterIsAutomatable;
parameter.name = "Attack"; parameter.name = "Attack";
@ -120,8 +255,32 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
} }
void Chassis::setParameterValue(uint32_t index, float value) { 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) { 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: case paramSaw:
s.patchRam.switch1 &= 0xef; s.patchRam.switch1 &= 0xef;
s.patchRam.switch1 |= (value > 63) << 4; s.patchRam.switch1 |= (value > 63) << 4;

View File

@ -32,15 +32,35 @@ START_NAMESPACE_DISTRHO
class Chassis : public Plugin { class Chassis : public Plugin {
public: public:
enum Parameters { enum Parameters {
paramLFORate,
paramLFODelay,
paramVCORange,
paramVCOLFO,
paramPWMLFO,
paramPWMMode,
paramSaw, paramSaw,
paramSqr, paramSqr,
paramSub, paramSub,
paramNoise,
paramHPF,
paramVCFFreq,
paramVCFReso,
paramVCFMode,
paramVCFEnv,
paramVCFLFO,
paramVCFKey,
paramEnvGate,
paramVCALevel,
paramAttack, paramAttack,
paramDecay, paramDecay,
paramSustain, paramSustain,
paramRelease, paramRelease,
paramEnvGate,
paramVCALevel,
parameterCount parameterCount
}; };

View File

@ -141,7 +141,12 @@ static inline float poly3blep1(float t) {
} }
void Voice::run(Synth &s, float *buffer, uint32_t samples) { 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 sqr = (s.patchRam.switch1 & 0x08) ? 0.175 : 0;
float saw = (s.patchRam.switch1 & 0x10) ? 0.220 : 0; float saw = (s.patchRam.switch1 & 0x10) ? 0.220 : 0;

View File

@ -123,16 +123,16 @@ class Synth {
// around and memcpy() values from sysex on top of it // around and memcpy() values from sysex on top of it
struct { struct {
uint8_t lfo_rate = 57; uint8_t lfoRate = 57;
uint8_t lfo_delay = 45; uint8_t lfoDelay = 45;
uint8_t lfo_dco = 0; uint8_t vcoLfo = 0;
uint8_t lfo_pwm = 55; uint8_t pwmLfo = 55;
uint8_t noise = 0; uint8_t noise = 0;
uint8_t vcf_cut = 85; uint8_t vcfFreq = 85;
uint8_t vcf_res = 0; uint8_t vcfResp = 0;
uint8_t vcf_env = 0; uint8_t vcfEnv = 0;
uint8_t vcf_lfo = 0; uint8_t vcfLfo = 0;
uint8_t vcf_kyb = 108; uint8_t vcfKey = 108;
uint8_t vca = 52; uint8_t vca = 52;
uint8_t env_a = 59; uint8_t env_a = 59;
uint8_t env_d = 32; uint8_t env_d = 32;