saneish looking parameters

This commit is contained in:
Gordon JC Pearce 2024-09-11 21:40:11 +01:00
parent 3588c3459b
commit 620914b500
4 changed files with 85 additions and 69 deletions

View File

@ -40,6 +40,7 @@ void Chassis::initProgramName(uint32_t index, String &programName) {
}
void Chassis::loadProgram(uint32_t index) {
uint8_t paramOrder[16] = {
paramLFORate,
paramLFODelay,
@ -60,14 +61,20 @@ void Chassis::loadProgram(uint32_t index) {
for (uint i = 0; i < 16; i++) {
setParameterValue(paramOrder[i], (float)patchData[index][i]);
}
setParameterValue(paramVCORange, patchData[index][16] & 0x07);
setParameterValue(paramSaw, (patchData[index][16] & 0x10) ? 127.0f : 0.0f);
setParameterValue(paramSqr, (patchData[index][16] & 0x08) ? 127.0f : 0.0f);
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) ? 127.0f : 0.0f);
setParameterValue(paramVCFMode, (patchData[index][17] & 0x02) ? 127.0f : 0.0f);
setParameterValue(paramEnvGate, (patchData[index][17] & 0x04) ? 127.0f : 0.0f);
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);
}

View File

@ -26,7 +26,7 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.symbol = "ch_lforate";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 57.0f;
parameter.ranges.def = 48.0f;
parameter.midiCC = 3;
break;
@ -36,7 +36,7 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.symbol = "ch_lfodelay";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 45.0f;
parameter.ranges.def = 0.0f;
parameter.midiCC = 9;
break;
@ -45,8 +45,8 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.name = "Range";
parameter.symbol = "ch_vcorange";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 4.0f;
parameter.ranges.def = 2.0f;
parameter.ranges.max = 2.0f;
parameter.ranges.def = 1.0f;
parameter.midiCC = 12;
break;
@ -56,7 +56,7 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.symbol = "ch_lfo";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 0.0f;
parameter.ranges.def = 10.0f;
parameter.midiCC = 13;
break;
@ -66,7 +66,7 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.symbol = "ch_pwm";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 55.0f;
parameter.ranges.def = 48.0f;
parameter.midiCC = 14;
break;
@ -75,8 +75,8 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.name = "PWM Mode";
parameter.symbol = "ch_pwmmode";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 0.0f;
parameter.ranges.max = 1.0f;
parameter.ranges.def = 1.0f;
parameter.midiCC = 15;
break;
@ -85,8 +85,8 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.name = "Saw";
parameter.symbol = "ch_saw";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 127.0f;
parameter.ranges.max = 1.0f;
parameter.ranges.def = 1.0f;
parameter.midiCC = 17;
break;
@ -95,8 +95,8 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.name = "Square";
parameter.symbol = "ch_sqr";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 127.0f;
parameter.ranges.max = 1.0f;
parameter.ranges.def = 1.0f;
parameter.midiCC = 16;
break;
@ -125,7 +125,7 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.name = "HPF";
parameter.symbol = "ch_hpf";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 4.0f;
parameter.ranges.max = 3.0f;
parameter.ranges.def = 0.0f;
parameter.midiCC = 20;
break;
@ -136,7 +136,7 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.symbol = "ch_freq";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 0.0f;
parameter.ranges.def = 60.0f;
parameter.midiCC = 74;
break;
case paramVCFReso:
@ -153,8 +153,8 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.name = "Polarity";
parameter.symbol = "ch_vcfmode";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 0.0f;
parameter.ranges.max = 1.0f;
parameter.ranges.def = 1.0f;
parameter.midiCC = 21;
break;
case paramVCFEnv:
@ -163,7 +163,7 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.symbol = "ch_vcfenv";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 0.0f;
parameter.ranges.def = 46.0f;
parameter.midiCC = 22;
break;
case paramVCFLFO:
@ -181,7 +181,7 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.symbol = "ch_vcfkey";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 0.0f;
parameter.ranges.def = 71.0f;
parameter.midiCC = 24;
break;
@ -191,7 +191,7 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.symbol = "ch_attack";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 59.0f;
parameter.ranges.def = 27.0f;
parameter.midiCC = 73;
break;
@ -201,7 +201,7 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.symbol = "ch_decay";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 32.0f;
parameter.ranges.def = 57.0f;
parameter.midiCC = 75;
break;
@ -211,7 +211,7 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.symbol = "ch_sustain";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 86.0f;
parameter.ranges.def = 57.0f;
parameter.midiCC = 27;
break;
@ -221,7 +221,7 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.symbol = "ch_release";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 40.0f;
parameter.ranges.def = 48.0f;
parameter.midiCC = 72;
break;
@ -230,8 +230,8 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.name = "Env-Gate";
parameter.symbol = "ch_envgate";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 0.0f;
parameter.ranges.max = 1.0f;
parameter.ranges.def = 1.0f;
parameter.midiCC = 25;
break;
@ -263,6 +263,8 @@ void Chassis::setParameterValue(uint32_t index, float value) {
if (value < 0.0f) value = 0.0f;
if (value > 127.0f) value = 127.0f;
//printf("setparam %d %f\n", index, value);
switch (index) {
case paramLFORate:
s.patchRam.lfoRate = value;
@ -321,16 +323,16 @@ void Chassis::setParameterValue(uint32_t index, float value) {
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);
s.patchRam.switch1 |= (1 << (int)(value-1));
break;
case paramSqr: // bit 3 of switch 1
s.patchRam.switch1 &= 0xf7;
s.patchRam.switch1 |= (value > 63) << 3;
s.patchRam.switch1 |= (value >= 0.5 ) << 3;
break;
case paramSaw: // bit 4 of switch 1
s.patchRam.switch1 &= 0xef;
s.patchRam.switch1 |= (value > 63) << 4;
s.patchRam.switch1 |= (value >= 0.5) << 4;
break;
// missing chorus switch
@ -338,16 +340,16 @@ void Chassis::setParameterValue(uint32_t index, float value) {
// switch 2 params
case paramPWMMode: // bit 0 of switch 2
s.patchRam.switch2 &= 0xfe;
s.patchRam.switch2 |= (value > 63);
s.patchRam.switch2 |= (value < 0.5);
break;
case paramVCFMode: // bit 1 of switch 2
s.patchRam.switch2 &= 0xfd;
s.patchRam.switch2 |= (value > 63) << 1;
s.patchRam.switch2 |= (value < 0.5) << 1;
break;
case paramEnvGate:
s.patchRam.switch2 &= 0xfb;
s.patchRam.switch2 |= (value > 63) << 2;
s.patchRam.switch2 |= (value < 0.5) << 2;
break;
case paramHPF: // bits 3-4 of switch 2
@ -374,7 +376,11 @@ float Chassis::getParameterValue(uint32_t index) const {
break;
case paramVCORange:
// FIXME this needs to be better generally
return (s.patchRam.switch1 & 0x07) << 1;
switch (s.patchRam.switch1 & 0x07) {
case 1: return 0; break;
case 4: return 2; break;
default: return 1;
}
break;
case paramVCOLFO:
return s.patchRam.vcoLfo;
@ -382,15 +388,16 @@ float Chassis::getParameterValue(uint32_t index) const {
case paramPWMLFO:
return s.patchRam.pwmLfo * 1.27f;
break;
case paramPWMMode:
return (s.patchRam.switch2 & 0x01) ? 127.0f : 0.0f;
break;
// the "slide switches" appear inverted because up is on
case paramPWMMode:
return (s.patchRam.switch2 & 0x01) ? 0.0f : 1.0f;
break;
case paramSaw:
return (s.patchRam.switch1 & 0x10) ? 127.0f : 0.0f;
return (s.patchRam.switch1 & 0x10) ? 1.0f : 0.0f;
break;
case paramSqr:
return (s.patchRam.switch1 & 0x08) ? 127.0f : 0.0f;
return (s.patchRam.switch1 & 0x08) ? 1.0f : 0.0f;
break;
case paramSub:
@ -418,7 +425,7 @@ float Chassis::getParameterValue(uint32_t index) const {
return s.patchRam.vcfKey;
break;
case paramVCFMode:
return (s.patchRam.switch2 & 0x02) ? 127.0f : 0.0f;
return (s.patchRam.switch2 & 0x02) ? 0.0f : 1.0f;
break;
case paramAttack:
@ -435,7 +442,7 @@ float Chassis::getParameterValue(uint32_t index) const {
break;
case paramEnvGate:
return (s.patchRam.switch2 & 0x04) ? 127.0f : 0.0f;
return (s.patchRam.switch2 & 0x04) ? 0.0f : 1.0f;
break;
case paramVCALevel:

View File

@ -57,6 +57,8 @@ void Voice::run(Synth &s, float *buffer, uint32_t samples) {
float gain = 0.5 * powf(2, (s.patchRam.vca / 64.0f) - 1);
//printf("patchram.switches= %3d %3d\n", s.patchRam.switch1, s.patchRam.switch2);
float vcaEnv = (s.patchRam.switch2 & 0x04) ? (float)ff11:(env / 16384.0f);
for (uint32_t i = 0; i < samples; i++) {
@ -103,7 +105,7 @@ void Voice::run(Synth &s, float *buffer, uint32_t samples) {
out = y;
// widthDelay = pw;
//out *= 0.5;
out *= 0.707;
for (uint8_t ovs = 0; ovs < 4; ovs++) {
fb = b4;
@ -118,11 +120,11 @@ void Voice::run(Synth &s, float *buffer, uint32_t samples) {
b4 = ((b3 - b4) * cut) + b4;
}
vr58c106 += ((vcaEnv - vr58c106) * 0.0075);
vr58c106 += ((vcaEnv - vr58c106) * 0.005);
lastpw = pw;
out = b4 * (0.2);
out = b4 * (0.5);
buffer[i] += (gain * b4 * vr58c106);
buffer[i] += (gain * out * vr58c106);
}
}

View File

@ -112,24 +112,24 @@ class Synth {
// the comments indicate what the defaults are set to
// in the routine at 02c2h, in case they're important
struct {
uint8_t lfoRate = 57; // lookup value defaults to 0x0200
uint8_t lfoDelay = 45;
uint8_t vcoLfo = 0;
uint8_t pwmLfo = 55;
uint8_t noise = 0;
uint8_t vcfFreq = 85; // 0x3f80
uint8_t vcfReso = 0;
uint8_t vcfEnv = 0;
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 = 108;
uint8_t vca = 52;
uint8_t env_a = 59;
uint8_t env_d = 32;
uint8_t env_s = 86; // 0x3f80
uint8_t env_r = 40;
uint8_t sub = 0;
uint8_t switch1 = 26;
uint8_t switch2 = 24;
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;
float pitchCV[104];