filtering echo uart

Hello

I hope I am writing in the right forum section.

I am trying to write a program in which I will be able to define several midi messages, two or three bytes it depends, which after receiving will not be sent. All undefined messages must go on.

So a program that is echoing but selective.

The echo program itself has and is trivial, as I understand it at every loop, if a byte of messages has appeared, it is sent immediately. At least on an oscilloscope this is how it looks.

byte BajtOdebrany;


void setup() {
  // Initialize the serial port for MIDI
  Serial.begin(31250) ;
}
 
void loop() {
  if (Serial.available() > 0) {
    BajtOdebrany = Serial.read() ;
    Serial.write(BajtOdebrany);
  }
}

I can't understand what to write next so that specific messages are filtered.

Is each message terminated in some way, perhaps with a Carriage Return or Linefeed ?
How many different types of message do you want to block ?
How many different types of message do you want to allow ?
Is there any pattern to either, ie do all of the blocked messages perhaps start with 'X'

The basic midi messages are Control Change and Program Change that interest me
Control Change is 3 bytes - the first byte says that it is CC and what channel (0-15), the second byte tells which controller number (0-127) and the third by what its value (0-127)
Program Change is 2 bytes, the first byte says that it is a PC and what channel (0-15), the second byte says what program number (0-127)

I want to be able to define a few (3-4) values in the ranges listed above to be blocked.

As I previously asked, is each data package terminated ?
If so, then it would allow the messages to be read and compared with an inclusion or exclusion list