From ffe4026b1832a59c08195d2dd7b508fb1f6ae560 Mon Sep 17 00:00:00 2001 From: Gordon JC Pearce Date: Mon, 5 Jan 2026 21:34:30 +0000 Subject: [PATCH] fix module being updated at the wrong time causing incorrect LFO speed --- plugin/module.cpp | 6 +++--- plugin/module.hpp | 3 ++- plugin/peacock.cpp | 6 ++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/plugin/module.cpp b/plugin/module.cpp index d873111..a6350a9 100644 --- a/plugin/module.cpp +++ b/plugin/module.cpp @@ -76,8 +76,8 @@ void Module::runLFO() { else lfo = (lfoPhase & 0x3fff) - 0x1fff; - pw = 0x3fff-(((0x2000 + lfo) * patchRam.pwmLfo) >> 7); - pw = (patchRam.switch2 & 0x01) ? 0x3fff - (patchRam.pwmLfo << 7 ) : pw; + pw = 0x3fff - (((0x2000 + lfo) * patchRam.pwmLfo) >> 7); + pw = (patchRam.switch2 & 0x01) ? 0x3fff - (patchRam.pwmLfo << 7) : pw; lfo = (lfo * lfoDelay) >> 14; } @@ -94,7 +94,7 @@ void Module::run(Voice* voices, uint32_t blockSize) { // originally I had 0.28, 0.36, 0.4 // measurement suggests that saw and square are around 100mV each with sub 160mV - + square = (patchRam.switch1 & 0x08) ? 0.3 : 0; saw = (patchRam.switch1 & 0x10) ? .3 : 0; sub = (patchRam.sub / 127.0f) * 0.48; diff --git a/plugin/module.hpp b/plugin/module.hpp index f23966e..cce369c 100644 --- a/plugin/module.hpp +++ b/plugin/module.hpp @@ -92,7 +92,7 @@ class Module { */ struct { - uint8_t lfoRate = 0x00; + uint8_t lfoRate = 0x1f; uint8_t lfoDelay = 0x00; uint8_t vcoLfo = 0x00; uint8_t pwmLfo = 0x3c; @@ -124,6 +124,7 @@ class Module { private: void runLFO(); + // precalculated coefficients for RC networks float pwmTC = 0, subTC = 0, mVcaTC = 0; float pwmRC = 0, subRC = 0, vcaRC = 0; diff --git a/plugin/peacock.cpp b/plugin/peacock.cpp index 0c6e194..09b1211 100644 --- a/plugin/peacock.cpp +++ b/plugin/peacock.cpp @@ -80,16 +80,14 @@ void Peacock::run(const float**, float** outputs, uint32_t frames, const MidiEve while (framePos < frames) { if (blockLeft == 0) { // no more samples to calculate in this update period - blockLeft = sampleRate / 238; // update rate in Hz + blockLeft = sampleRate / 233.5; // update rate in Hz, measured runMidi(midiEvents, midiEventCount, framePos + blockLeft); + m->run(voice, blockLeft); } // how many frames to do? Are we about to run off an update block sizeThisTime = (framesLeft < blockLeft) ? framesLeft : blockLeft; - // update the module board for this block - m->run(voice, sizeThisTime); - // now run all the voices for this chunk of samples for (uint32_t i = 0; i < NUM_VOICES; i++) { voice[i].run(m, outputs[0], framePos, sizeThisTime);