fix module being updated at the wrong time causing incorrect LFO speed

This commit is contained in:
Gordon JC Pearce 2026-01-05 21:34:30 +00:00
parent 8d987fa5b0
commit ffe4026b18
3 changed files with 7 additions and 8 deletions

View File

@ -76,8 +76,8 @@ void Module::runLFO() {
else else
lfo = (lfoPhase & 0x3fff) - 0x1fff; lfo = (lfoPhase & 0x3fff) - 0x1fff;
pw = 0x3fff-(((0x2000 + lfo) * patchRam.pwmLfo) >> 7); pw = 0x3fff - (((0x2000 + lfo) * patchRam.pwmLfo) >> 7);
pw = (patchRam.switch2 & 0x01) ? 0x3fff - (patchRam.pwmLfo << 7 ) : pw; pw = (patchRam.switch2 & 0x01) ? 0x3fff - (patchRam.pwmLfo << 7) : pw;
lfo = (lfo * lfoDelay) >> 14; lfo = (lfo * lfoDelay) >> 14;
} }

View File

@ -92,7 +92,7 @@ class Module {
*/ */
struct { struct {
uint8_t lfoRate = 0x00; uint8_t lfoRate = 0x1f;
uint8_t lfoDelay = 0x00; uint8_t lfoDelay = 0x00;
uint8_t vcoLfo = 0x00; uint8_t vcoLfo = 0x00;
uint8_t pwmLfo = 0x3c; uint8_t pwmLfo = 0x3c;
@ -124,6 +124,7 @@ class Module {
private: private:
void runLFO(); void runLFO();
// precalculated coefficients for RC networks // precalculated coefficients for RC networks
float pwmTC = 0, subTC = 0, mVcaTC = 0; float pwmTC = 0, subTC = 0, mVcaTC = 0;
float pwmRC = 0, subRC = 0, vcaRC = 0; float pwmRC = 0, subRC = 0, vcaRC = 0;

View File

@ -80,16 +80,14 @@ void Peacock::run(const float**, float** outputs, uint32_t frames, const MidiEve
while (framePos < frames) { while (framePos < frames) {
if (blockLeft == 0) { if (blockLeft == 0) {
// no more samples to calculate in this update period // 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); runMidi(midiEvents, midiEventCount, framePos + blockLeft);
m->run(voice, blockLeft);
} }
// how many frames to do? Are we about to run off an update block // how many frames to do? Are we about to run off an update block
sizeThisTime = (framesLeft < blockLeft) ? framesLeft : blockLeft; 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 // now run all the voices for this chunk of samples
for (uint32_t i = 0; i < NUM_VOICES; i++) { for (uint32_t i = 0; i < NUM_VOICES; i++) {
voice[i].run(m, outputs[0], framePos, sizeThisTime); voice[i].run(m, outputs[0], framePos, sizeThisTime);