Add Actions to entering/exiting a song

When switching songs the Mastermind can set the tempo when entering the song. I would be great if it could also run an action or macro.
In my case I use the 1st preset of the song to send MIDI commands to my MainStage program. I have discovered that the only way for MainStage to process the PC and CC messages is to put a delay of 500msec between the PC and CC messages. Because of the delay I can no longer use the preset while playing the song so it is essentially a setup preset and I have to duplicate the preset without the delay for use during the song. It would be great to run these actions when the song is selected and even better to run different actions when leaving the song (such as muting MainStage).

Many thanks as always!