Old 09-05-2019, 12:16 PM   #1
kenm
Human being with feelings
 
Join Date: Dec 2011
Location: San Jose, CA, USA
Posts: 73
Default Trigger Action based on MIDI CC Value (3rd byte)

Forgive me if this isn't the right place to post this.

I'm trying to figure out how to trigger an action based on the value (3rd byte) of a MIDI CC message. I've looked extensively through the manual and have come to the conclusion that this needs to be done with a script. The problem is I don't know where to start with the script.

I have a MIDI controller that has a latching button. It sends CC# 0x6D with a value of 0x7F when pressed/latched and a value of 0x00 when released/unlatched. I want to assign 0x7F to Transport:Play and 0x00 to Transport:Stop.

Any guidance on how to go about this would be greatly appreciated.

Ken
kenm is offline   Reply With Quote
Old 09-05-2019, 04:22 PM   #2
kenm
Human being with feelings
 
Join Date: Dec 2011
Location: San Jose, CA, USA
Posts: 73
Default

OK. So this is pretty cheesy and took me an embarrassingly long time to figure out but it works.

In Lua:

Code:
is_new,filename,sectionID,cmdID,mode,resolution,value = reaper.get_action_context()
if is_new then
  reaper.ShowConsoleMsg("DEBUG: \nmode: " .. mode .. "\nresolution: " .. resolution .. "\nvalue: " .. value .. "\n")
  if value == 127 then
    action = "Play" -- Triggering Play Action
    reaper.Main_OnCommand(1007, 0)
  elseif value == 0 then
    action = "Stop" -- Triggering Stop Action
    reaper.Main_OnCommand(1016, 0)
  else
    action = "Ignore" -- Ignore Everything else
  end
reaper.ShowConsoleMsg(action .. "\n")
end
I have the action to run the script set to whenever a MIDI CC of 0x6D (109) is received on Channel 1 (the default button channel for my controller).

EDIT: Here's a minimal version without my testing stuff in it:

Code:
is_new,filename,sectionID,cmdID,mode,resolution,value = reaper.get_action_context()
if is_new then
  if value == 127 then
    reaper.Main_OnCommand(1007, 0)
  elseif value == 0 then
    reaper.Main_OnCommand(1016, 0)
  else
  end
end
BTW, I haven't written anything in Lua since my Autodesk days. Be kind.

Ken

Last edited by kenm; 09-05-2019 at 04:37 PM. Reason: Added minimal version of code
kenm is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:02 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.