better LFO and PW

This commit is contained in:
Gordon JC Pearce 2026-01-06 20:20:30 +00:00
parent 8c2263c129
commit 7ff0bf0659
2 changed files with 19 additions and 9 deletions

View File

@ -70,15 +70,23 @@ void Module::runLFO() {
lfoDelay = 0x3fff;
}
lfoPhase += lfoRateTable[patchRam.lfoRate];
if (lfoPhase & 0x4000)
lfo = 0x1fff - (lfoPhase & 0x3fff);
else
lfo = (lfoPhase & 0x3fff) - 0x1fff;
lfoRate = lfoRateTable[patchRam.lfoRate]; // FIXME move to parameters
pw = 0x3fff - (((0x2000 + lfo) * patchRam.pwmLfo) >> 7);
pw = (patchRam.switch2 & 0x01) ? 0x3fff - (patchRam.pwmLfo << 7) : pw;
lfo = (lfo * lfoDelay) >> 14;
lfoPhase += (lfoState & 0x01) ? -lfoRate : lfoRate;
if (lfoPhase > 0x1fff) {
lfoPhase = 0x1fff;
lfoState++;
}
if (lfoPhase < 0x0000) {
lfoPhase = 0x0000;
lfoState++;
}
lfo = (lfoState & 0x02) ? -lfoPhase : lfoPhase;
pw = (lfoState & 0x02) ? lfoPhase + 0x2000 : 0x2000 - lfoPhase; // PW LFO is unipolar
pw = (patchRam.switch2 & 0x01) ? 0x3fff : pw; // either LFO or "all on"
pw = 0x3fff - ((pw * patchRam.pwmLfo) >> 7); // scaled by PWM pot
// lfo = (lfo * lfoDelay) >> 14;
}
void Module::run(Voice* voices, uint32_t blockSize) {

View File

@ -130,7 +130,9 @@ class Module {
float pwmRC = 0, subRC = 0, vcaRC = 0;
int16_t lfo, pw;
uint32_t lfoPhase;
int16_t lfoPhase;
uint8_t lfoState = 0;
uint16_t lfoRate;
uint32_t noiseRNG = 1;