Search code examples
synthesisphasemodulation

Source of crackle in phase modulation synthesis


I'm trying to make a simple phase modulation synthesizer based on wavetables and DDS. I have a 12bit wavetable containing 4096 sample of a sine wave and I'm using a 32bit phase accumulator.

Implementing my idea works but it seems to have a lot of low level crackle associated with modulating the depth of phase modulation. I'm generating my sample like so:

Modulator = Modulation*SineWavetable[PhaseAc2>>20];
Sample = SineWavetable[(PhaseAc1 + Modulator)>>20];

I thought the crackle could be generated by modulating the "Modulation" parameter a bit too hard/fast but this doesn't seem to be the cause of the problem. Could anybody enlighten me on potential problems with this method of phase modulation?

As ever, thanks!


Solution

  • As it turns out, typecasting is a very big deal here! I was trying to mix an int32_t (Modulator) with a uint32_t (PhaseAc1) and it was causing strange overflow problems where the phase would momentarily glitch, causing the audible problems. The phase accumulator was calculated outside of the array index section and shifted at a single variable like so:

    Modulator = Modulation*SineWavetable[PhaseAc2>>20];
    PhaseAc1 += (int32_t)Modulator;
    Sample = SineWavetable[(PhaseAc1 + Modulator)>>20];