LFO question

Hi everyone.
I'm trying to add a simple FLO modulation to my synthesizer. In the beginning I tried to do so,

FLO calc in processBlock

rate = 20 / getSampleRate(); 

  for (size_t i = 0; i < buffer.getNumSamples(); i++)
        lfo += rate;
        if (lfo > 2.0) lfo -= 2.0;
        out = lfo -1;

send to voice 


and render :)

synth.renderNextBlock(buffer, midiMessages, 0, numSamples);

It works fine, but if the audio buffer size has changed in the Audio Setting a new value comes less from FLO

I found a forum on how to render parts


void processBlock (AudioSampleBuffer& audio, MidiBuffer& midi)
        // if audio is 512 and you want to process in blocks of 32
        int numSamples = audio.getNumSamples();
        int startSample = 0;
        while (numSamples > 0)
            const int numThisTime = jmin (32, numSamples);
            AudioSampleBuffer section (audio.getArrayOfChannels(), audio.getNumChannels(), startSample, numThisTime);
            // and do a similar thing for the MIDI
            child->processBlock (section, midi);
            numSamples -= numThisTime;
            startSample += numThisTime;

But there were clicks. If I change the num numThisTime to 256-512 clicks disappear, but that's not what I need (cry) 

Help to understand how to make the FLO do not depend on the size of the audio buffer settings

For example:

one global LFO for all the votes

audio buffer settings is 2248

change freq OSC1 or filter setting every 32-64 samples

I understand I needed to fill the buffer in advance, sorry