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

View File

@ -42,14 +42,14 @@ void Voice::run(Synth &s, float *buffer, uint32_t samples) {
float pw = s.ff4f / 32768.0f; float pw = s.ff4f / 32768.0f;
float fb, res = s.patchRam.vcfReso / 28.0f; // guess float fb, res = s.patchRam.vcfReso / 28.0f; // guess
//float cut = s.patchRam.vcfFreq / 400.0f; // guess // float cut = s.patchRam.vcfFreq / 400.0f; // guess
float cut = 248.0f * (powf(2,(vcfenv-0x1880)/1143.0f)); float cut = 248.0f * (powf(2, (vcfenv - 0x1880) / 1143.0f));
// now radians // now radians
cut = 0.25 * 6.2832 * cut / 48000.0f; cut = 0.25 * 6.2832 * cut / 48000.0f;
// now correct // now correct
cut = cut/(1+cut); cut = cut / (1 + cut);
float sqr = (s.patchRam.switch1 & 0x08) ? 0.63 : 0; //? 0.175 : 0; float sqr = (s.patchRam.switch1 & 0x08) ? 0.63 : 0; //? 0.175 : 0;
float saw = (s.patchRam.switch1 & 0x10) ? 0.8 : 0; //? 0.220 : 0; float saw = (s.patchRam.switch1 & 0x10) ? 0.8 : 0; //? 0.220 : 0;
@ -57,7 +57,9 @@ void Voice::run(Synth &s, float *buffer, uint32_t samples) {
float gain = 0.5 * powf(2, (s.patchRam.vca / 64.0f) - 1); float gain = 0.5 * powf(2, (s.patchRam.vca / 64.0f) - 1);
float vcaEnv = (s.patchRam.switch2 & 0x04) ? (float)ff11 : (env / 16384.0f); //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++) { for (uint32_t i = 0; i < samples; i++) {
y = delay; y = delay;
@ -103,7 +105,7 @@ void Voice::run(Synth &s, float *buffer, uint32_t samples) {
out = y; out = y;
// widthDelay = pw; // widthDelay = pw;
//out *= 0.5; out *= 0.707;
for (uint8_t ovs = 0; ovs < 4; ovs++) { for (uint8_t ovs = 0; ovs < 4; ovs++) {
fb = b4; fb = b4;
@ -118,11 +120,11 @@ void Voice::run(Synth &s, float *buffer, uint32_t samples) {
b4 = ((b3 - b4) * cut) + b4; b4 = ((b3 - b4) * cut) + b4;
} }
vr58c106 += ((vcaEnv - vr58c106) * 0.0075); vr58c106 += ((vcaEnv - vr58c106) * 0.005);
lastpw = pw; 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 // the comments indicate what the defaults are set to
// in the routine at 02c2h, in case they're important // in the routine at 02c2h, in case they're important
struct { struct {
uint8_t lfoRate = 57; // lookup value defaults to 0x0200 uint8_t lfoRate = 0x30; // lookup value defaults to 0x0200
uint8_t lfoDelay = 45; uint8_t lfoDelay = 0x00;
uint8_t vcoLfo = 0; uint8_t vcoLfo = 0x0a;
uint8_t pwmLfo = 55; uint8_t pwmLfo = 0x30;
uint8_t noise = 0; uint8_t noise = 0x00;
uint8_t vcfFreq = 85; // 0x3f80 uint8_t vcfFreq = 0x3c; // 0x3f80
uint8_t vcfReso = 0; uint8_t vcfReso = 0x00;
uint8_t vcfEnv = 0; uint8_t vcfEnv = 0x2e;
uint8_t vcfLfo = 0; uint8_t vcfLfo = 0;
uint8_t vcfKey = 108; uint8_t vcfKey = 0x47;
uint8_t vca = 52; uint8_t vca = 0x28;
uint8_t env_a = 59; uint8_t env_a = 0x1b;
uint8_t env_d = 32; uint8_t env_d = 0x39;
uint8_t env_s = 86; // 0x3f80 uint8_t env_s = 0x39; // 0x3f80
uint8_t env_r = 40; uint8_t env_r = 0x30;
uint8_t sub = 0; uint8_t sub = 0x00;
uint8_t switch1 = 26; uint8_t switch1 = 0x1a;
uint8_t switch2 = 24; uint8_t switch2 = 0x18;
} patchRam; } patchRam;
float pitchCV[104]; float pitchCV[104];