The problem appears when the phase jump is one sample before or at the same sample like the hard sync.
I tried to ignore the phase jump when the sub oscillator hard sync happens within the next one or two samples. But this produces new edge cases where the phase jump sometimes happens and sometimes not. This introduces also some unwanted frequencies.
Code: Select all
phaseIncrement = frequency * sampleRateInv;
phase += phaseIncrement;
if (hardSync)
{
float newPhase = phaseStart + phaseHardSync * phaseIncrement / phaseHardSyncInc;
mixInBlep(phaseHardSync / phaseHardSyncInc, phase - newPhase);
phase = newPhase;
}
if (phase >= 1.0f)
{
phase -= 1.0f;
mixInBlep(phase/phaseIncrement, 1.0f);
}
return getNextBlep() + phase - 0.5f;