Syncing phase of multiple NCOs/WaveTable Oscillators

Hi long time lurker and big fan of this forum. There is serious amounts of knowledge here.

Okay with that aside, here’s where I am at. We’re developing this hybrid synth with an STM32F3 at its core. I’ve managed to get wavetable oscillators working from reading up on NCO’s around the internet, mostly from here primarily.

So I’m rocking 8 of these oscillators with custom band limited wavetables and everything seems great. Apart from this particular “problem”:

  • If I set the pitch of all the oscillators to the same frequency, it works great, there is no phasing between them.
  • However, if I change the pitch of one of them, I can never get them back in phase.

Here’s my oscillators update() function:

    int32_t DSPOscillator::update(){
     m_phaseAcc += m_phaseDelta;
     m_phaseAcc &= TABLE_SIZE*(1<<16) - 1;
     int idx = m_phaseAcc >> 16;
         case OSC_WT:
             m_value = waveForms_[m_wTable][idx];
         case OSC_PWM:
             m_value = idx < 127 ? 0 : 4087;
         return m_value;

And here’s my setFrequency() function:

void DSPOscillator::setFrequency(float t_freq){
     m_phaseDelta = Q16((float)t_freq * TABLE_SIZE / SAMPLE_RATE);

The Q16 macro expands to

#define FRAC 16
#define Q16(X) (X * (float)(1<<FRAC))

Now, a part of me thinks that with this naive approach, it isn’t possible to get the phase back, because if I’m arbitrarily changing the frequency, which in turn is changing the phase, I won’t be able to sync the phase back up, right? I have figured out a lot of other concepts and ideas (including DMA / event queues / ADC handling etc.) from the Mutable source code but, didn’t fully understand how the oscillators work in this context, any help would be appreciated.

1 Like

I am not aware of any synth trying to sync the phases of its oscillators when they are at the same frequency.

It is the expected behavior that changing the frequency of an oscillator, then bringing it back to the same frequency as another oscillator, will cause some unexpected amont of dephasing with that other oscillator. This could be “fixed” by slightly changing the frequency of the oscillator until its phase “catches up” with the master phase.


Thank you for this. I guess its something I made into an issue myself haha. :slight_smile:

If you want them to be locked in phase you could briefly hard sync n - 1 oscillators to the remaining 1 oscillator, or sync them to another event, such as keyboard trigger / gate. The Moog Minitaur has an option to hard sync the oscillators to keyboard gate, not necessarily to put them in phase with each other, but so the phase of the oscillators will be consistent across repeated notes for bass lines.

In general I think people don’t want multiple oscillators to be in phase, otherwise you could just be using a single oscillator, since the wave shaped outputs of a single oscillator (saw, square, triangle) will always be in phase with each other.

1 Like