correct parameter generation

This commit is contained in:
Gordon JC Pearce 2024-09-11 23:25:41 +01:00
parent 620914b500
commit 3980a1c966
3 changed files with 77 additions and 62 deletions

View File

@ -40,42 +40,7 @@ void Chassis::initProgramName(uint32_t index, String &programName) {
} }
void Chassis::loadProgram(uint32_t index) { void Chassis::loadProgram(uint32_t index) {
memmove(&s.patchRam, (uint8_t *)patchData + (index *18), 18);
uint8_t paramOrder[16] = {
paramLFORate,
paramLFODelay,
paramVCOLFO,
paramPWMLFO,
paramNoise,
paramVCFFreq,
paramVCFReso,
paramVCFEnv,
paramVCFLFO,
paramVCFKey,
paramVCALevel,
paramAttack,
paramDecay,
paramSustain,
paramRelease,
paramSub};
for (uint i = 0; i < 16; i++) {
setParameterValue(paramOrder[i], (float)patchData[index][i]);
}
switch (patchData[index][16] & 0x07) {
case 1: setParameterValue(paramVCORange, 0); break;
case 4: setParameterValue(paramVCORange, 2); break;
default: setParameterValue(paramVCORange, 1); break;
}
setParameterValue(paramSaw, (patchData[index][16] & 0x10) ? 1.0f : 0.0f);
setParameterValue(paramSqr, (patchData[index][16] & 0x08) ? 1.0f : 0.0f);
// FIXME chorus switch settings
setParameterValue(paramPWMMode, (patchData[index][17] & 0x01) ? 0.0f : 1.0f);
setParameterValue(paramVCFMode, (patchData[index][17] & 0x02) ? 0.0f : 1.0f);
setParameterValue(paramEnvGate, (patchData[index][17] & 0x04) ? 0.0f : 1.0f);
setParameterValue(paramHPF, (patchData[index][17] & 0x18) >> 3);
} }
// Processing functions // Processing functions
@ -181,10 +146,10 @@ void Chassis::run(const float **, float **outputs, uint32_t frames, const MidiEv
s.voice[i].calcPitch(s); s.voice[i].calcPitch(s);
switch (s.patchRam.switch1 & 0x07) { switch (s.patchRam.switch1 & 0x07) {
case 1: case 0:
s.voice[i].omega /= 2; s.voice[i].omega /= 2;
break; break;
case 4: case 2:
s.voice[i].omega *= 2; s.voice[i].omega *= 2;
default: default:
break; break;

View File

@ -18,7 +18,7 @@
#include "chassis.hpp" #include "chassis.hpp"
void Chassis::initParameter(uint32_t index, Parameter &parameter) { void Chassis::initParameter(uint32_t index, Parameter& parameter) {
switch (index) { switch (index) {
case paramLFORate: case paramLFORate:
parameter.hints = kParameterIsAutomatable; parameter.hints = kParameterIsAutomatable;
@ -48,6 +48,19 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.ranges.max = 2.0f; parameter.ranges.max = 2.0f;
parameter.ranges.def = 1.0f; parameter.ranges.def = 1.0f;
parameter.midiCC = 12; parameter.midiCC = 12;
parameter.enumValues.count = 3;
parameter.enumValues.restrictedMode = true;
{
ParameterEnumerationValue* const enumValues = new ParameterEnumerationValue[3];
enumValues[0].value = 0.0f;
enumValues[0].label = "16'";
enumValues[1].value = 1.0f;
enumValues[1].label = "8'";
enumValues[2].value = 2.0f;
enumValues[2].label = "4'";
parameter.enumValues.values = enumValues;
}
break; break;
case paramVCOLFO: case paramVCOLFO:
@ -78,6 +91,17 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.ranges.max = 1.0f; parameter.ranges.max = 1.0f;
parameter.ranges.def = 1.0f; parameter.ranges.def = 1.0f;
parameter.midiCC = 15; parameter.midiCC = 15;
parameter.enumValues.count = 2;
parameter.enumValues.restrictedMode = true;
{
ParameterEnumerationValue* const enumValues = new ParameterEnumerationValue[2];
enumValues[0].value = 0.0f;
enumValues[0].label = "LFO";
enumValues[1].value = 1.0f;
enumValues[1].label = "MAN";
parameter.enumValues.values = enumValues;
}
break; break;
case paramSaw: case paramSaw:
@ -149,13 +173,24 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.midiCC = 71; parameter.midiCC = 71;
break; break;
case paramVCFMode: case paramVCFMode:
parameter.hints = kParameterIsAutomatable | kParameterIsBoolean; parameter.hints = kParameterIsAutomatable | kParameterIsInteger;
parameter.name = "Polarity"; parameter.name = "Polarity";
parameter.symbol = "ch_vcfmode"; parameter.symbol = "ch_vcfmode";
parameter.ranges.min = 0.0f; parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f; parameter.ranges.max = 1.0f;
parameter.ranges.def = 1.0f; parameter.ranges.def = 1.0f;
parameter.midiCC = 21; parameter.midiCC = 21;
parameter.enumValues.count = 2;
parameter.enumValues.restrictedMode = true;
{
ParameterEnumerationValue* const enumValues = new ParameterEnumerationValue[2];
enumValues[0].value = 0.0f;
enumValues[0].label = "POS";
enumValues[1].value = 1.0f;
enumValues[1].label = "INV";
parameter.enumValues.values = enumValues;
}
break; break;
case paramVCFEnv: case paramVCFEnv:
parameter.hints = kParameterIsAutomatable; parameter.hints = kParameterIsAutomatable;
@ -226,13 +261,23 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
break; break;
case paramEnvGate: case paramEnvGate:
parameter.hints = kParameterIsAutomatable | kParameterIsBoolean; parameter.hints = kParameterIsAutomatable | kParameterIsInteger; // | kParameterIsBoolean;
parameter.name = "Env-Gate"; parameter.name = "Env-Gate";
parameter.symbol = "ch_envgate"; parameter.symbol = "ch_envgate";
parameter.ranges.min = 0.0f; parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f; parameter.ranges.max = 1.0f;
parameter.ranges.def = 1.0f; parameter.ranges.def = 1.0f;
parameter.midiCC = 25; parameter.midiCC = 25;
parameter.enumValues.count = 2;
parameter.enumValues.restrictedMode = true;
{
ParameterEnumerationValue* const enumValues = new ParameterEnumerationValue[2];
enumValues[0].value = 0.0f;
enumValues[0].label = "ENV";
enumValues[1].value = 1.0f;
enumValues[1].label = "GATE";
parameter.enumValues.values = enumValues;
}
break; break;
case paramVCALevel: case paramVCALevel:
@ -263,7 +308,7 @@ void Chassis::setParameterValue(uint32_t index, float value) {
if (value < 0.0f) value = 0.0f; if (value < 0.0f) value = 0.0f;
if (value > 127.0f) value = 127.0f; if (value > 127.0f) value = 127.0f;
//printf("setparam %d %f\n", index, value); printf("setparam %d %f\n", index, value);
switch (index) { switch (index) {
case paramLFORate: case paramLFORate:
@ -323,16 +368,16 @@ void Chassis::setParameterValue(uint32_t index, float value) {
case paramVCORange: // bits 0-2 of switch 1 case paramVCORange: // bits 0-2 of switch 1
// doesn't look great in Carla because of odd behaviour with small integer knobs // doesn't look great in Carla because of odd behaviour with small integer knobs
s.patchRam.switch1 &= 0xf8; s.patchRam.switch1 &= 0xf8;
s.patchRam.switch1 |= (1 << (int)(value-1)); s.patchRam.switch1 |= (1 << (int)(value - 1));
break; break;
case paramSqr: // bit 3 of switch 1 case paramSqr: // bit 3 of switch 1
s.patchRam.switch1 &= 0xf7; s.patchRam.switch1 &= 0xf7;
s.patchRam.switch1 |= (value >= 0.5 ) << 3; s.patchRam.switch1 |= (value >= 0.5) << 3;
break; break;
case paramSaw: // bit 4 of switch 1 case paramSaw: // bit 4 of switch 1
s.patchRam.switch1 &= 0xef; s.patchRam.switch1 &= 0xef;
s.patchRam.switch1 |= (value >= 0.5) << 4; s.patchRam.switch1 |= (value >= 0.5) << 4;
break; break;
// missing chorus switch // missing chorus switch
@ -340,23 +385,25 @@ void Chassis::setParameterValue(uint32_t index, float value) {
// switch 2 params // switch 2 params
case paramPWMMode: // bit 0 of switch 2 case paramPWMMode: // bit 0 of switch 2
s.patchRam.switch2 &= 0xfe; s.patchRam.switch2 &= 0xfe;
s.patchRam.switch2 |= (value < 0.5); s.patchRam.switch2 |= (value >= 0.5);
break; break;
case paramVCFMode: // bit 1 of switch 2 case paramVCFMode: // bit 1 of switch 2
s.patchRam.switch2 &= 0xfd; s.patchRam.switch2 &= 0xfd;
s.patchRam.switch2 |= (value < 0.5) << 1; s.patchRam.switch2 |= (value >= 0.5) << 1;
break; break;
case paramEnvGate: case paramEnvGate:
//printf("setting envgate %f %02x", value, s.patchRam.switch2);
s.patchRam.switch2 &= 0xfb; s.patchRam.switch2 &= 0xfb;
s.patchRam.switch2 |= (value < 0.5) << 2; s.patchRam.switch2 |= (value >= 0.5) << 2;
// printf(" set envgate %f %02x", value, s.patchRam.switch2);
break; break;
case paramHPF: // bits 3-4 of switch 2 case paramHPF: // bits 3-4 of switch 2
// doesn't look great in Carla because of odd behaviour with small integer knobs // doesn't look great in Carla because of odd behaviour with small integer knobs
if (value > 3) value = 3; if (value > 3) value = 3;
s.patchRam.switch2 &= 0xf3; s.patchRam.switch2 &= 0xf3;
s.patchRam.switch2 |= (int)value << 2; s.patchRam.switch2 |= (int)value << 3;
break; break;
case paramModWheel: case paramModWheel:
@ -377,9 +424,14 @@ float Chassis::getParameterValue(uint32_t index) const {
case paramVCORange: case paramVCORange:
// FIXME this needs to be better generally // FIXME this needs to be better generally
switch (s.patchRam.switch1 & 0x07) { switch (s.patchRam.switch1 & 0x07) {
case 1: return 0; break; case 1:
case 4: return 2; break; return 0;
default: return 1; break;
case 4:
return 2;
break;
default:
return 1;
} }
break; break;
case paramVCOLFO: case paramVCOLFO:
@ -388,17 +440,15 @@ float Chassis::getParameterValue(uint32_t index) const {
case paramPWMLFO: case paramPWMLFO:
return s.patchRam.pwmLfo * 1.27f; return s.patchRam.pwmLfo * 1.27f;
break; break;
// the "slide switches" appear inverted because up is on
case paramPWMMode: case paramPWMMode:
return (s.patchRam.switch2 & 0x01) ? 0.0f : 1.0f; return (s.patchRam.switch2 & 0x01) != 0;
break; break;
case paramSaw: case paramSaw:
return (s.patchRam.switch1 & 0x10) ? 1.0f : 0.0f; return (s.patchRam.switch1 & 0x10) != 0;
break; break;
case paramSqr: case paramSqr:
return (s.patchRam.switch1 & 0x08) ? 1.0f : 0.0f; return (s.patchRam.switch1 & 0x08) != 0;
break;
case paramSub: case paramSub:
return s.patchRam.sub; return s.patchRam.sub;
@ -425,7 +475,7 @@ float Chassis::getParameterValue(uint32_t index) const {
return s.patchRam.vcfKey; return s.patchRam.vcfKey;
break; break;
case paramVCFMode: case paramVCFMode:
return (s.patchRam.switch2 & 0x02) ? 0.0f : 1.0f; return (s.patchRam.switch2 & 0x02) != 0;
break; break;
case paramAttack: case paramAttack:
@ -442,8 +492,8 @@ float Chassis::getParameterValue(uint32_t index) const {
break; break;
case paramEnvGate: case paramEnvGate:
return (s.patchRam.switch2 & 0x04) ? 0.0f : 1.0f; //printf("envgate %d\n", s.patchRam.switch2 & 0x04);
break; return (s.patchRam.switch2 & 0x04) != 0;
case paramVCALevel: case paramVCALevel:
return s.patchRam.vca; return s.patchRam.vca;

View File

@ -123,7 +123,7 @@ void Voice::run(Synth &s, float *buffer, uint32_t samples) {
vr58c106 += ((vcaEnv - vr58c106) * 0.005); vr58c106 += ((vcaEnv - vr58c106) * 0.005);
lastpw = pw; lastpw = pw;
out = b4 * (0.5); out = b4 * (0.25);
buffer[i] += (gain * out * vr58c106); buffer[i] += (gain * out * vr58c106);
} }