If you're doing anything with MIDI, you can supercharge Keyboard Maestro by pairing it with MIDI Translator. The link between the two is AppleScript; you can pass variables back and forth, and call macros directly from MIDI Translator.
If you're doing complex work, you'll need to pay close attention to control flow. Both environments are multi-threaded, and MT has a few features here such as global function calls for AppleScript. While Turing-Decidable, MT isn't really a development environment like KM, which has semaphores and other sophisticated runtime management features—so get your data as quickly as possible out of MT.
An example of the above where you can get into trouble is if you're setting variables directly in KB from MT, instead of calling Macros—and this ability is important—but remember that you cannot control when the variable changes, so you must analyse if you need to control for that (which KM has plenty of tools for doing with).
An open quesiton on my end is how to pass a data structure (e.g. array) from MT to KM. A variable is simply—just remember that it will come in drom MT as the Trigger variable (if used as part of a trigger call in AS).