Old 11-23-2020, 04:42 AM   #1
Coachz
Human being with feelings
 
Coachz's Avatar
 
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,769
Default Pedal off when midi split

It would be nice to have an option that when you split a midi item that any pedal ons get a pedal off at the end of the split. I get LOTS of sustained midi notes from splitting midi and I have to go back and draw the pedal offs on them all. Any work arounds ?

Is there a way to write a script that makes sure all midi items with 64 Pedal Hold data have an off with each on ?

Before split


After Split
Coachz is online now   Reply With Quote
Old 11-23-2020, 09:46 AM   #2
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 4,031
Default

It seems sustain off should be copied over to end of previous item, then deleting next item, same for note off's.

Shifting of off events to end of previous item.

Not sure if there is already any such or similar script?
TonE is offline   Reply With Quote
Old 11-23-2020, 11:01 AM   #3
Coachz
Human being with feelings
 
Coachz's Avatar
 
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,769
Default

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.
Coachz is online now   Reply With Quote
Old 11-26-2020, 06:58 AM   #4
BenjyO
Human being with feelings
 
Join Date: Nov 2011
Posts: 308
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
Old 11-26-2020, 07:25 AM   #5
Coachz
Human being with feelings
 
Coachz's Avatar
 
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,769
Default

Quote:
Originally Posted by BenjyO View Post
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.
Thanks so much. I can't wait to try it. How is it someone as smart as you only has 30 posts?
Coachz is online now   Reply With Quote
Old 11-26-2020, 12:57 PM   #6
BenjyO
Human being with feelings
 
Join Date: Nov 2011
Posts: 308
Default

Quote:
Originally Posted by Coachz View Post
Thanks so much. I can't wait to try it. How is it someone as smart as you only has 30 posts?
Say that I'm smart only after you've tried it and it works

I appreciate the compliment though
BenjyO is offline   Reply With Quote
Old 11-27-2020, 08:22 AM   #7
Coachz
Human being with feelings
 
Coachz's Avatar
 
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,769
Default

I only have these mpl scripts. Is it one of those ?

Coachz is online now   Reply With Quote
Old 11-28-2020, 08:42 AM   #8
BenjyO
Human being with feelings
 
Join Date: Nov 2011
Posts: 308
Default

Quote:
Originally Posted by Coachz View Post
I only have these mpl scripts. Is it one of those ?

Hey Coachz, I cannot see or open the link of the screenshot you've attached to your post.

I forgot to mention that "mpl_Add CC64 off to channel 0 of active MIDI Editor take" is in the "MIDI Editor" section of the actions list not in the "Main" section.
BenjyO is offline   Reply With Quote
Old 11-28-2020, 12:30 PM   #9
BenjyO
Human being with feelings
 
Join Date: Nov 2011
Posts: 308
Default

Weird ... Now I see the screenshot. I really didn't see it before when I posted my last post. Anyway, it's the one in the middle: Add CC64 off to channel 0 of active MIDI Editor take
BenjyO is offline   Reply With Quote
Old 11-29-2020, 07:24 AM   #10
Coachz
Human being with feelings
 
Coachz's Avatar
 
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,769
Default BenjyO saves the day

Thanks so much for the code. I got it to do exactly what I needed and this is going to help my workflow tremendously. We do a lot of keyboard midi recording and then do lots of splitting / punching in / editing and every damn time I would have to go back and add a pedal off because the previous notes would just keep sustaining.

Another side effect was tiny orphan notes where the split happened and I found the action to throw those "trailing" notes out. Here is what I got. Thanks so much !! Huge win for me. I hope it helps others and wish it was already built into Reaper as this seems a desirable midi behavior at least for me.

Would you be able to show me how to extend these two to work for multiple selected items (at same mouse/edit cursor position) on separate tracks possibly ? Basically for all midi items under the edit cursor.

This show splitting with no snap first and then with snap. Both cases show how the pedal off is now present.






Code:
-- Script: jb_split pedal off (no snapping).lua
-- split midi item and add pedal offs at split with no snapping
-- credits to mpl for his "mpl_Add CC64 off to channel 0 of active MIDI Editor take"

function main()

	saveCursorPos = reaper.NamedCommandLookup("_BR_SAVE_CURSOR_POS_SLOT_1")  -- save edit cursor position
	reaper.Main_OnCommand(saveCursorPos, 0)

	reaper.Main_OnCommand(40514, 0) -- move edit cursor to mouse position

	reaper.Main_OnCommand(40746, 0) -- Item: Split item under mouse cursor
	
	reaper.Main_OnCommand(40104, 0) -- View: Move cursor left one pixel

	selitem = reaper.NamedCommandLookup("_XENAKIOS_SELITEMSUNDEDCURSELTX")  -- select items under mouse
	reaper.Main_OnCommand(selitem, 0)

	reaper.Main_OnCommand(41729, 0) -- delete trailing notes
	
	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

	restoreCursorPos = reaper.NamedCommandLookup("_BR_RESTORE_CURSOR_POS_SLOT_1")  -- recall edit cursor position
	reaper.Main_OnCommand(restoreCursorPos, 0)

	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)
Code:
-- Script: jb_split pedal off (snapping).lua
-- split midi item and add pedal offs at split with snapping
-- credits to mpl for his "mpl_Add CC64 off to channel 0 of active MIDI Editor take"

function main()

	reaper.Main_OnCommand(40757, 0) -- Item: Split items at edit cursor (no change selection)
	
	reaper.Main_OnCommand(40104, 0) -- View: Move cursor left one pixel

	selitem = reaper.NamedCommandLookup("_XENAKIOS_SELITEMSUNDEDCURSELTX")  -- select items under mouse
	reaper.Main_OnCommand(selitem, 0)

	reaper.Main_OnCommand(41729, 0) -- delete trailing notes
	
	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.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)

Last edited by Coachz; 11-29-2020 at 09:29 AM.
Coachz is online now   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 08:40 AM.


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