filter and oscillator tuning

This commit is contained in:
Gordon JC Pearce 2025-12-23 22:54:08 +00:00
parent 8ce34e6b3a
commit 5c5f8f2229
3 changed files with 31 additions and 9 deletions

View File

@ -121,11 +121,12 @@ void Module::run(Voice* voices, uint32_t blockSize) {
px *= (patchRam.switch1 & 0x07); px *= (patchRam.switch1 & 0x07);
v->omega = px / (sampleRate * 4.0f); // fixme use proper scaler v->omega = px / (sampleRate * 8.0f); // fixme use proper scaler
// per voice we need to calculate the key follow amount and envelope amount // per voice we need to calculate the key follow amount and envelope amount
v->vcfCut = (patchRam.vcfFreq << 7) + ((vcf * v->env) >> 14); v->vcfCut = (patchRam.vcfFreq << 7) + ((vcf * v->env) >> 14);
v->vcfCut += (int)(v->note * (patchRam.vcfKey << 1) * 0.375); v->vcfCut += (int)((v->note-36) * (patchRam.vcfKey << 1) * 0.375);
if (v->vcfCut > 0x3fff) v->vcfCut = 0x3fff; if (v->vcfCut > 0x3fff) v->vcfCut = 0x3fff;
if (v->vcfCut < 0) v->vcfCut = 0; if (v->vcfCut < 0) v->vcfCut = 0;

View File

@ -46,8 +46,8 @@ class Module {
float saw = 0, square = 0, sub = 0, noise = 0; float saw = 0, square = 0, sub = 0, noise = 0;
struct { struct {
uint8_t lfoRate = 0x18; uint8_t lfoRate = 0x18;
uint8_t lfoDelay = 0x00; uint8_t lfoDelay = 0x00;
uint8_t vcoLfo = 0x00; uint8_t vcoLfo = 0x00;
@ -66,6 +66,29 @@ class Module {
uint8_t sub = 0x40; uint8_t sub = 0x40;
uint8_t switch1 = 0x59; uint8_t switch1 = 0x59;
uint8_t switch2 = 0x18; uint8_t switch2 = 0x18;
/*
// VCF tune
uint8_t lfoRate = 0x40;
uint8_t lfoDelay = 0x00;
uint8_t vcoLfo = 0x00;
uint8_t pwmLfo = 0x00;
uint8_t noise = 0x00;
uint8_t vcfFreq = 0x31; // 1c; // 0x3f80
uint8_t vcfReso = 0x7f;
uint8_t vcfEnv = 0x00; // 4e;
uint8_t vcfLfo = 0x00;
uint8_t vcfKey = 0x7f; // 47;
uint8_t vca = 0x40;
uint8_t env_a = 0x00;
uint8_t env_d = 0x00;
uint8_t env_s = 0x7f; // 0x3f80
uint8_t env_r = 0x00;
uint8_t sub = 0x00;
uint8_t switch1 = 0x62;
uint8_t switch2 = 0x10;
*/
} patchRam; } patchRam;
Chorus* chorus; Chorus* chorus;

View File

@ -40,11 +40,9 @@ Voice::Voice() {
} }
void Voice::on(uint8_t midiNote) { void Voice::on(uint8_t midiNote) {
// omega = 261.63 * powf(2, (note - 60) / 12.0f) / 48000.0f; while (midiNote < 24) midiNote += 12;
if (midiNote > 24) while (midiNote > 108) midiNote -=12;
note = midiNote - 24; note = midiNote - 24;
else
note = 24;
envPhase = 1; envPhase = 1;
} }