Comparing two MidiMessages


#1

Hi

What is the best way to find out if two midimessages match?

Say I want to do something when a certain message is recived how can I compare the incomming messagewith my "target"?

By creating a function with a bunch of nested if/else comperators ?

Or is there a more clever way of doing this.

Could I simply compare the raw midi bytes in a fast way?


#2

You could just check the sizes and do a memcmp.

Odd that I never added an operator==, but I guess isn't actually not a very common thing to do, as you normally would want to compare things like midi channel, note number, controller type, etc. rather than just comparing two events in their entirety.


#3

Hi

Thanks for getting back to me Jules. You are right most of the time you would want to do a more detailed comperasion.

But a classic case would be to check if Message Type, Channel and note/controller number mach.

Maybe I can create some nice function for these cases. like "compareMessageType" etc