Duplicated midi signal problem | demo tutorial

Hello, I was trying to test the demo presented here: https://docs.juce.com/master/tutorial_code_basic_plugin.html

I opened the AudioPluginHost and added my plugin as well as an external Midi Monitor plugin along the path to check if the velocity of the notes got changed or not. When the midi signal pass through the plugin, it duplicates the midi signal and change it’s velocity and output both signals, the original one and the modified one. is this behavior normal? I think it should only output the modified signal. I have attached an image with the behavior. Can someone explain?

This sounds like the modified MIDI notes are added to the original MIDI buffer instead of to a new one. Could you copy-paste the contents of the processBlock function that you wrote?

this is what’s inside the processBlock

    buffer.clear();
	MidiBuffer processedMidi;
	int time;
	MidiMessage m;
	for (MidiBuffer::Iterator i(midiMessages); i.getNextEvent(m, time);)
	{
		if (m.isNoteOn())
		{
			uint8 newVel = (uint8)noteOnVel;
			m = MidiMessage::noteOn(m.getChannel(), m.getNoteNumber(), newVel);
		}
		else if (m.isNoteOff())
		{
		}
		else if (m.isAftertouch())
		{
		}
		else if (m.isPitchWheel())
		{
		}

		processedMidi.addEvent(m, time);
	}
	midiMessages.swapWith(processedMidi);

I tried to create a new audio plugin from Projucer without adding any thing into the code. Just changed the characteristics of the plugin to allow midi-in and out from the Projucer settings and still the midi monitor counts the signal twice. I tried the midi monitor with other vst3 plugins that has midi in and out and didn’t encounter this weird effect.