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
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;

View File

@ -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;

View File

@ -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);