Since we are flipping between two apps, I made it so that the switching CC (89) flips between app A and app B as you move the fader up/down. If you really need the apps switched based on a specific value of CC 89 let me know and I can advise on how to adjust.
Here is what you do:
You add two StreamByters to AUM and connect the external controller to both of these in the MIDI matrix. You then connect each of the StreamByters to app A or app B.
Paste the code below into each StreamByter (and press Install Rules), but for the StreamByter connected to app B, make the following change to this line near the top:
define app_id 0
define app_id 1
and press 'Install Rules'
(this is important!)
So you can see at a glance which app is active (A or B) the script sets the icon name in AUM with 'APP A' or 'APP B' and then a '+' (active) or a '-' (inactive) at the start. You could give these more meaningful names; the code that sets these is marked as '# set icon name' in the code.
If app A is active (which means app B is inactive) then CC0 and 32 are passed and CC52 (BX 34) is remapped to PC. If app A is inactive (which means app B is active) then CC0 and 32 are blocked and CC52 is not remapped. And vice versa.
# reathpd switcher by audeonic
if load # app_id - set this to 1 for app B define app_id 0
# cc used to switch apps define switch_cc B0 $89
# internals alias L0 active assign active = 0 send switch_cc 0 +inject end
# handle app switch cc if M0 == switch_cc assign I0 = 0 if app_id == 0 if M2 < 40 assign I0 = 1 end else if M2 >= 40 assign I0 = 1 end end
# if changed, flip if I0 != active assign active = I0 end
# set icon name if active == 1 if app_id == 0 set name +APP_A else set name +APP_B end else if app_id == 0 set name -APP_A else set name -APP_B end end block end
# handle CC0 and 32 if MT == B0 if M1 == 0 if active == 0 block end end if M1 == $32 if active == 0 block end end end
# convert CC to PC if active if active == 1 BX 34 = CX X3 end