Why Does Oscilattor Output Seemingly 'Jump'?

I’m making an auto-panner plugin which uses a dsp::Oscilator object to control the gain in the left and right channels. It’s working just fine except that the oscillator(right now sine wave) seems to beo doing some weird jumping behaviour.

I think this gif demonstrates it better… It’s a visualiser of where the signal source is in the panorama.

Basically the oscillator cycles just fine for one cycle but on its second cyle it reaches a value of roughly -0.7 before it jumps straight back to +0.7 and it does this randomly again and again.

This is the initialisation code for the oscillator.

initialise([this](float x) {
        auto lfoOut = (depth * std::sin(x * frequency * juce::MathConstants<float>::twoPi)) + offset;
        if (offset < 0.f) {
            lfoOut = juce::jmax(-1.f, lfoOut);
        else if(offset > 0.f){
            lfoOut = juce::jmin(1.f, lfoOut);
        return lfoOut;

The ‘offset’ places the LFO’s centre somewhere other than 0 and the if statement makes sure the LFO stay in the range -1 to 1. Maybe there’s a better way of doing this, but for now, it works.

Any help? Because it’s really bugging me what the problem is :confused:

Edit: Also this isn’t just an issue in the paint() method. I’ve checked the plugin in the plugin host and the and the visualiser is accurate.