filter of sorts

This commit is contained in:
Gordon JC Pearce 2024-09-09 16:31:43 +01:00
parent bde0863a15
commit 357cbbac9a
4 changed files with 37 additions and 5 deletions

View File

@ -115,6 +115,8 @@ void Chassis::run(const float **, float **outputs, uint32_t frames, const MidiEv
// flatten the left channel to use as temporary storage, since
// the synth engine only generates a mono channel
bzero(outputs[0], sizeof(float) * frames);
bzero(outputs[1], sizeof(float) * frames);
// get any of the last block's worth of MIDI out of the way
lastEvent = 0;
@ -157,6 +159,7 @@ void Chassis::run(const float **, float **outputs, uint32_t frames, const MidiEv
s.voice[i].run(s, outputs[0] + framePos, sizeThisTime);
}
framePos += sizeThisTime;
s.framesLeft -= sizeThisTime;
s.blockLeft -= sizeThisTime;

View File

@ -146,7 +146,7 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 0.0f;
parameter.midiCC = 74;
parameter.midiCC = 71;
break;
case paramVCFMode:
parameter.hints = kParameterIsAutomatable | kParameterIsBoolean;

View File

@ -41,9 +41,12 @@ void Voice::run(Synth &s, float *buffer, uint32_t samples) {
// there's a resistor on the panel board to sprag the range
float pw = s.ff4f / 32768.0f;
float sqr = (s.patchRam.switch1 & 0x08) ? 0.175 : 0;
float saw = (s.patchRam.switch1 & 0x10) ? 0.220 : 0;
float sub = (s.patchRam.sub / 127.0f) * 0.275;
float fb, res = s.patchRam.vcfReso / 24.0f; // guess
float cut = s.patchRam.vcfFreq / 400.0f; // guess
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 sub = (s.patchRam.sub / 127.0f); // * 0.275;
float gain = 0.5 * powf(2, (s.patchRam.vca / 64.0f) - 1);
@ -97,8 +100,29 @@ void Voice::run(Synth &s, float *buffer, uint32_t samples) {
out = y;
// widthDelay = pw;
//out *= 0.5;
for (uint8_t ovs = 0; ovs < 4; ovs++) {
fb = b4;
// hard clip
if (fb > 1) fb = 1;
if (fb < -1) fb = -1;
fb = out - (fb * res);
b1 = ((fb - b1) * cut) + b1;
b2 = ((b1 - b2) * cut) + b2;
b3 = ((b2 - b3) * cut) + b3;
b4 = ((b3 - b4) * cut) + b4;
}
vr58c106 += ((vcaEnv - vr58c106) * 0.0075);
lastpw = pw;
buffer[i] += (gain * out * vr58c106);
out = b4 * (0.275);
buffer[i] += (gain * b4 * vr58c106);
}
}
void Voice::filter(Synth &s, float *buffer, uint32_t samples) {
}

View File

@ -34,6 +34,8 @@ class Voice {
void run(Synth &s, float *buffer, uint32_t samples);
void gate(Synth &s);
void calcPitch(Synth &s);
void filter(Synth &s, float *buffer, uint32_t samples);
uint16_t ff71 = 0; // stores pitch + fraction
float omega;
@ -64,6 +66,9 @@ class Voice {
float lastpw = 0;
float vr58c106 = 0;
float b1, b2, b3, b4;
uint16_t attack_table[128] = {
0x4000, 0x2000, 0x1000, 0x0aaa, 0x0800, 0x0666, 0x0555, 0x0492, 0x0400,
0x038e, 0x0333, 0x02e9, 0x02ab, 0x0276, 0x0249, 0x0222, 0x0200, 0x01e2,