Okay I'm thinking this: You want to keep the C++ part as small as
possible and do as much as you can in bash so you can have control even
if you don't now C++.
What do you think of a utility that listens for a MIDI program change on
a MIDI channel you give it as an argument, then returns which change it
was in the exit code?
Should be doable under five kilobytes.