View Single Post
Old 11-26-2020, 06:58 AM   #4
BenjyO
Human being with feelings
 
Join Date: Nov 2011
Posts: 41
Default

Quote:
Originally Posted by Coachz View Post
I agree. I wonder if anyone knows how to write a script to do it. Then I could put it in a custom action for splits.
Here's a script that works for me. It's very crude and it's definitely not fault-proof but it does the trick. It splits the selected item at edit cursor and inserts a CC64 Off message a few pixels before the split point in the left item. It requires SWS and mpl's scripts.

I don't know (yet) if Reaper assigns different ID identifier's for custom actions and user scripts to different users. If that's the case, substitute the parameter in the reaper.NamedCommandLookup() function for the ID which shows up in your action list (MIDI Editor actions) for "mpl_Add CC64 off to channel 0 of active MIDI Editor take".

Code:
-- credits to mpl for his "mpl_Add CC64 off to channel 0 of active MIDI Editor take"

function main()
	reaper.Main_OnCommand(40759, 0) -- Item: Split items at edit cursor (select right)
	reaper.Main_OnCommand(40006, 0) -- Item: Remove items
	
	reaper.Main_OnCommand(40104, 0) -- View: Move cursor left one pixel
	reaper.Main_OnCommand(40104, 0) -- View: Move cursor left one pixel
	reaper.Main_OnCommand(40104, 0) -- View: Move cursor left one pixel
	
	selitem = reaper.NamedCommandLookup("_XENAKIOS_SELITEMSUNDEDCURSELTX")
	reaper.Main_OnCommand(selitem, 0)
	
	reaper.Main_OnCommand(40153, 0) -- Item: Open in built-in MIDI editor (set default behavior in preferences)
	
	actmidieditor = reaper.MIDIEditor_GetActive()
	idofpedaloff = reaper.NamedCommandLookup("_RS7d3c_d030d666f7decf53fd1dee3680ec2d970b916137") -- MIDI Editor: mpl_Add CC64 off to channel 0 of active MIDI Editor take.lua
	reaper.MIDIEditor_OnCommand(actmidieditor, idofpedaloff)
	reaper.MIDIEditor_OnCommand(actmidieditor, 2) -- File: Close window
	
	reaper.Main_OnCommand(40319, 0) -- Item navigation: Move cursor right to edge of item
	reaper.UpdateArrange()
end

script_title = "Script: BenjyO_Split MIDI item at edit cursor and add CC64 Off-message a few pixels before.lua"
reaper.Undo_BeginBlock()
main()
reaper.Undo_EndBlock(script_title, 0)
Hope this helps somehow.
BenjyO is offline   Reply With Quote