MIDI song position pointer, and code optimization

Dan Nigrin's icon

I'd like to implement code to extract MIDI song position pointer information out of a MIDI input stream. I've written the code to do so (the messages are 3 bytes long, and start with decimal 242) - see below (the bytes are just printed to the Max window).

My question: does anyone have a better, more efficient way to capture these three bytes out of the incoming MIDI stream? For some reason, something tells me that I'm doing this in a more clunky fashion than I need to, and I'm having a mental block!

Max Patch
Copy patch and select New From Clipboard in Max.

Thanks in advance...

Emmanuel Jourdan's icon
Max Patch
Copy patch and select New From Clipboard in Max.

@dan not sure if that's more efficient, that's a few objects less.

broc's icon

I think vanille's solution is perfect.
Maybe a bit less efficient, but that does it really matter when processing midi?

Dan Nigrin's icon

Thanks to you guys for the two solutions! Both much cleaner and nicer than mine...

Macciza's icon

Ultimately though there should be an object for this - it is a standard system midi message, so it should only need minor editing of existing code ,
cheers

Tj Shredder's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Just another one:

and yes, a seperate object for MTC and SPP would definitely be handsome...

Dan Nigrin's icon

That's beautiful Stefan, one object!