How do I update LFO value correctly if I am just iterating through midi in my processBlock() in this code here?

This is my first LFO in a midi plugin; I think its normal to update the LFO value by processSample.
However, I am only iterating through midi messages in my buffer in the process block, not samples.
How do I ensure the accurate updating of the LFO value in this situation?

void myplugin::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages)
{
    buffer.clear();

    juce::MidiBuffer processedMidi;
    juce::MidiMessage currentMessage;
    int samplePos;
    juce::MidiBuffer::Iterator it(midiMessages);

    while (it.getNextEvent(currentMessage, samplePos))
    {
        // Process my LFO values
        float lfo1Value = mLfo1.processSample(0.0f) * get_mLfo1Depth() + get_mLfo1Offset();

make a sample index starting at 0 at the beginning of each block. for each midi event you while loop and process the lfo on until the timestamp of the event and only then update the lfo with the midi input. after the midi loop you process the lfo from the sample index to numSamples

1 Like

:+1: I’ll look into that