From 5c5f8f22297140ac438f61635436065f08fc58ca Mon Sep 17 00:00:00 2001 From: Gordon JC Pearce Date: Tue, 23 Dec 2025 22:54:08 +0000 Subject: [PATCH] filter and oscillator tuning --- plugin/module.cpp | 5 +++-- plugin/module.hpp | 27 +++++++++++++++++++++++++-- plugin/voice.cpp | 8 +++----- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/plugin/module.cpp b/plugin/module.cpp index af93a7b..98aecd9 100644 --- a/plugin/module.cpp +++ b/plugin/module.cpp @@ -121,11 +121,12 @@ void Module::run(Voice* voices, uint32_t blockSize) { 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 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 < 0) v->vcfCut = 0; diff --git a/plugin/module.hpp b/plugin/module.hpp index 057bea8..5fc696b 100644 --- a/plugin/module.hpp +++ b/plugin/module.hpp @@ -46,8 +46,8 @@ class Module { float saw = 0, square = 0, sub = 0, noise = 0; - struct { + uint8_t lfoRate = 0x18; uint8_t lfoDelay = 0x00; uint8_t vcoLfo = 0x00; @@ -66,6 +66,29 @@ class Module { uint8_t sub = 0x40; uint8_t switch1 = 0x59; 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; Chorus* chorus; @@ -75,7 +98,7 @@ class Module { float* vcaBuf; float* subBuf; float* pwmBuf; - + private: // precalculated coefficients for RC networks float pwmTC = 0, subTC = 0, mVcaTC = 0; diff --git a/plugin/voice.cpp b/plugin/voice.cpp index 460974d..ec81b15 100644 --- a/plugin/voice.cpp +++ b/plugin/voice.cpp @@ -40,11 +40,9 @@ Voice::Voice() { } void Voice::on(uint8_t midiNote) { - // omega = 261.63 * powf(2, (note - 60) / 12.0f) / 48000.0f; - if (midiNote > 24) - note = midiNote - 24; - else - note = 24; + while (midiNote < 24) midiNote += 12; + while (midiNote > 108) midiNote -=12; + note = midiNote - 24; envPhase = 1; }