Find a way to automatically turn off LEDs on an ESP32-based MIDI footswitch when Gig Performer is closed

The context is that I’m building a MIDI controller footswitch, and I activate the LEDs by pressing the widgets in a rackspace. So, basically, when a widget is on, it sends a MIDI note on, and my ESP32 lights up the LED, and vice versa. The problem is that if some of the widgets are on (meaning the LEDs are on as well) and I close Gig Performer, the LEDs do not switch off (of course). I want to figure out if there’s a way to send an ‘all notes off’ message immediately after I close Gig Performer. If you guys have any ideas that would work in this scenario, I would be very grateful. I couldn’t think of anything better than that, except maybe doing a loop that sends a ‘keep-alive’ flag. The ESP32 could capture that, and as soon as it stops receiving the flag, it would recognize this and switch off all the LEDs.

In the external API there is a callback OnClose() which gets called immediately before GigPerformer exits. That could be used to do what you want to do. There may be a pretty steep learning curve to figure out how to get there if you’re not already familiar with building stuff in C or C++.

I’m not aware of a similar callback in GP script, but somebody who does more GPScript may know better.

Oh, I see. I didn’t want to run more things outside of Gig Performer, but that might be the answer. Is GitHub - gigperformer/gp-sdk: SDK for Gig Performer extensions the API you’re referring to? Just to make sure I understand, I’ll need a C++ program that waits for the OnClose() callback, and in this program, I send the ‘all MIDI notes off’ message. Is that correct? Sorry if I’m a bit confused; I just started experimenting with Gig Performer. Thanks for your support!

Yes, that’s the SDK. For a basic working example of how to use it (in C++) you could look at gigperformer/gp-extension-cpp: Example extension for Gig Performer, written in C++ (github.com)

If you go into src/LibMain.h and LibMain.c you’ll see many of the callbacks there (although the OnClose() callback is not). Most of them just print data to the console log. For what you want to do you could just erase most of them.

If you’re fluent in C++ you can take a look at WidnerM/GP-MC8: Morningstar MC8 GIgPerformer extension (github.com) and in the LibMain.h in that you’ll see I do something similar to what you want when GP closes. I clear a display and do some resets through MIDI.

The way Extensions like this work is that you compile them, then put them in the folder where GP will find them. GP will then load them automatically when it starts.

If you just need a bunch of note offs it should be pretty simple to do in a loop in that OnClose() callback. The trick will be communicating to the extension what MIDI port it should write them to.

Oh, I totally get it now. I’ve discovered a whole new world, thanks! I’m going to try this solution.

1 Like