Inject notes to a synthesiser

Hi oxxyyd,
in the meantime, I moved on on with my development and I wrote another version of the code.

Taking inspiration from an older topic of this forum (i.e.: https://forum.juce.com/t/midi-generator-creation/12912/15)

class MidiSource : public juce::AudioProcessor
{
public:
    MidiSource()
    {
        keyStatePtr.reset(new juce::MidiKeyboardState());
        for (auto i = 0; i < 5; i++)
            synth.addVoice(new SineWaveVoice());

        synth.addSound(new SineWaveSound());

        notesToPlay.add(56, 76, 65, 77, 81, 45);
        playNotes();

    }
/===========================================================/

    juce::Synthesiser synth;
    std::unique_ptr<juce::MidiKeyboardState> keyStatePtr;
}

Then, I call the function playNotes() which is in charge of populating a MidiBuffer with the notes to be played:

    void playNote()
    {
        juce::MidiBuffer myBuff;
        int time;
        
        for (auto note : notesToPlay)
        {
            juce::MidiMessage myMessage;
            myMessage = juce::MidiMessage::noteOn(1, note, (std::uint8_t)1.0);
            myMessage.setTimeStamp(time);
            myBuff.addEvent(myMessage, time);

            juce::MidiMessage mySecondMessage;
            mySecondMessage = juce::MidiMessage::noteOff(1, note, (std::uint8_t)1.0);
            mySecondMessage.setTimeStamp(time + 1000);
            time = time + 100;
            myBuff.addEvent(mySecondMessage, time);

            time = time + 100;
        }

Finally, I would like to reproduce this buffer by my processBlock. In the previous post, I tried to use a MidiMessageSequence, (i.e.: juce::MidiMessageSequence msgSeq in the previous messages), but with no results