Multiple MIDI messages with a single buttonpress.

I fell like this is easy, but I cant figure it out.

I am using PieterP's ever-amazing Control_Surface Library. When I want to send multiple messages from a single button press, right now I am just wiring the button to multiple PINS, and defining each pin independently.

Is there a more elegant way to do this? I feel like there must be a way, but I am dumb and a hack :slight_smile:

Thank you for any advice youall might have!

You don't have to use different pins, you can use multiple MIDIButton objects with the same pin, for example:

CCButton b1 = { 2, MIDI_CC::Pan };
NoteButton b2 = { 2, note(C, 4) };
NoteButton b3 = { 2, note(G, 2) };

Most of the time, the messages will be sent in the order that the buttons were defined in, except when the button state changes after b1 has been updated, but before b2 is updated, for instance. If the button is pressed for a very short period of time, it's possible that not all of the three messages are sent.

I guess a more elegant (or at least more idiomatic) way would be to write your own MIDI Output Element for it, one that sends multiple messages. Custom-MIDI-Output-Element.ino

Personally, if the approach with the multiple buttons works, I wouldn't bother writing a custom class for it.

Pieter

Dude, every time you write a message to me, a giant light goes off in my brain and illuminates huge sectors.
I had tried a bunch of, like, multiple-instance code ideas that didn't work... but this is exactly what I was searching for.

You are the man, if you ever need a foot controller let me know I will build it for you.