|
|
|
08-13-2018, 11:34 AM
|
#1
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
New Script: Cubase style multi-cut with mouse
EDIT - 2018-09-16 -- updated script to fix a bug if cursor was exactly at item start.
Hi guys,
I wrote a script for a feature I found missing in Reaper. Not sure if another script out there does the same, but I couldn't find it. This is especially useful when invoking the script by Arming an Icon by right-clicking it (as seen in the GIF).
Currently I called it: Cut item repeatedly based on initial cut length but I'm 100% open to a better name. I don't think calling it "Cubase Style Multi Cut" will help anyone who hasn't used Cubase.
Basically, when this script is on, wherever you click an item with the mouse, it will repeat the cut at equal intervals based on the size of your first cut. Snap can be ON to guide the cut or it can be wild. So if you cut 1 bar into the Item, then there will be subsequent 1 bar cuts to that item until the end of the initial item. It's easier to show on a GIF. In this example I had Snap set to bars:
Here is the code:
Code:
--[[
Description: Cut item repeatedly based on initial cut length
Version: 1.0.0
Author: Thonex
]]--
function Cut_item_repeatedly_based_on_initial_cut_length ()
reaper.PreventUIRefresh(1)
reaper.Undo_BeginBlock()
reaper.ClearConsole()
-- Get initial len and starting item --
Cur_Pos = reaper.GetCursorPosition() -- to get length by subtracting item start
Item_ID = reaper.GetSelectedMediaItem(0,0)
if Item_ID == nil then -- exit function if nothing is selected
return
end
Start = reaper.GetMediaItemInfo_Value( Item_ID, "D_POSITION")
if Cur_Pos <= Start then -- exit if cursor pos = item start (causes crash)
return
end
Item_Len = reaper.GetMediaItemInfo_Value( Item_ID, "D_LENGTH")
Len = Cur_Pos-Start -- used to how long to make the cuts
Num_Cuts = math.floor(Item_Len/Len)
for i=0, Num_Cuts do -- Sart loop here to see if next item is contiguous
reaper.Main_OnCommand(40012, 0 ) -- Item: Split items at edit or play cursor
Item_ID = reaper.GetSelectedMediaItem(0,0)
Start = reaper.GetMediaItemInfo_Value( Item_ID, "D_POSITION")
Next_Len = reaper.GetMediaItemInfo_Value( Item_ID, "D_LENGTH")
reaper.SetEditCurPos( Start+Len, 0, 0 )
end
reaper.SetEditCurPos( Cur_Pos, 0, 0 ) -- set back to inital location before script
reaper.SelectAllMediaItems( 0, 0 )
reaper.PreventUIRefresh(-1)
reaper.UpdateArrange()
reaper.Undo_EndBlock("Cuts based on Cursor",-1)
end
Cut_item_repeatedly_based_on_initial_cut_length ()
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 Catalina Mac Mini 2020 6 core i7 64GB RAM OS: Catalina 4K monitor RME RayDAT card with Sync Card and extended Light Pipe.
Last edited by Thonex; 09-16-2018 at 11:00 AM.
|
|
|
08-13-2018, 11:42 AM
|
#2
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,874
|
Nice idea ! :P
|
|
|
08-13-2018, 11:45 AM
|
#3
|
Human being with feelings
Join Date: Jul 2012
Location: Netherlands
Posts: 5,247
|
This is incredibly useful !
Reminds of same kind of functionality in Logic Pro X, using it's Scissors Tool while CMD key.
Thank you !!
|
|
|
08-13-2018, 12:20 PM
|
#5
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
Awesome Andrew! I had this on my todo list
|
|
|
08-13-2018, 12:21 PM
|
#7
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
Quote:
Originally Posted by spk77
|
@spk77
Nice one! Is that multi-selection friendly and Snap friendly? Is so, I think it is indeed the same... no?
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 Catalina Mac Mini 2020 6 core i7 64GB RAM OS: Catalina 4K monitor RME RayDAT card with Sync Card and extended Light Pipe.
Last edited by Thonex; 08-13-2018 at 01:09 PM.
|
|
|
08-13-2018, 12:23 PM
|
#8
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,874
|
@Thonex
BWT, you definitly have to consider GitHub and Reapack now :P Escpeially if you have to update your scripts.
|
|
|
08-13-2018, 11:51 AM
|
#9
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
Quote:
Originally Posted by X-Raym
Nice idea ! :P
|
Thanks X-Raym,
I wish I could take credit for it... but Cubase cir. 1990 LOL
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 Catalina Mac Mini 2020 6 core i7 64GB RAM OS: Catalina 4K monitor RME RayDAT card with Sync Card and extended Light Pipe.
|
|
|
08-13-2018, 11:56 AM
|
#10
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
Edited the code... removed an unnecessary line of code (Continue = 1). That was a vestige of a previous version.
All cleaned up now.
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 Catalina Mac Mini 2020 6 core i7 64GB RAM OS: Catalina 4K monitor RME RayDAT card with Sync Card and extended Light Pipe.
|
|
|
08-13-2018, 11:58 AM
|
#11
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Neat idea.
For future reference, we also have this in the API:
Quote:
MediaItem reaper.SplitMediaItem(MediaItem item, number position)
The original item becomes the left-hand split, the function returns the right-hand split (or NULL if the split failed)
|
|
|
|
08-13-2018, 12:07 PM
|
#12
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
Quote:
Originally Posted by Lokasenna
Neat idea.
For future reference, we also have this in the API:
|
Oooohhh.... thanks Loka!!
Will check it out. Maybe I can shave a bunch of code from my script.
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 Catalina Mac Mini 2020 6 core i7 64GB RAM OS: Catalina 4K monitor RME RayDAT card with Sync Card and extended Light Pipe.
|
|
|
08-13-2018, 12:18 PM
|
#13
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
Quote:
Originally Posted by Lokasenna
Neat idea.
For future reference, we also have this in the API:
|
Ok... on first blush, that function is not as multi-item friendly as splitting with reaper.Main_OnCommand(40012, 0 ) -- Item: Split items at edit or play cursor
I think i'd have to eventually do more item checks than the code I have now.
But very nice to know about that function now
Love Reaper... love the community! And thanks yet again for you help Loka!
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 Catalina Mac Mini 2020 6 core i7 64GB RAM OS: Catalina 4K monitor RME RayDAT card with Sync Card and extended Light Pipe.
|
|
|
08-13-2018, 12:03 PM
|
#14
|
Human being with feelings
Join Date: Jul 2012
Location: Netherlands
Posts: 5,247
|
Quote:
Originally Posted by Thonex
Edited the code... removed an unnecessary line of code (Continue = 1). That was a vestige of a previous version.
All cleaned up now.
|
Thanks !!
|
|
|
08-16-2018, 01:28 PM
|
#15
|
Human being with feelings
Join Date: Oct 2017
Location: Larisa, Greece
Posts: 3,795
|
Very useful script,thanks!
|
|
|
09-16-2018, 11:02 AM
|
#16
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
Updated the OP with a new version of the script that fixed crash when trying to cut an item at exactly it's start (divide by zero crash I suspect.... )
Cheers!
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 Catalina Mac Mini 2020 6 core i7 64GB RAM OS: Catalina 4K monitor RME RayDAT card with Sync Card and extended Light Pipe.
|
|
|
02-22-2019, 04:51 AM
|
#17
|
Human being with feelings
Join Date: Oct 2017
Location: Larisa, Greece
Posts: 3,795
|
Hi Thonex, as a previous Cubase user, i use a lot this script for editing.
I came back to ask if it's possible to update it so it could split the same way Automations Items.That would be really great.
Thanks in advance
Last edited by Vagelis; 02-22-2019 at 08:16 AM.
|
|
|
02-27-2019, 07:56 AM
|
#18
|
Human being with feelings
Join Date: Jul 2007
Location: Jazz City
Posts: 5,065
|
Very cool! Thanks a lot - I also remember using this quite a lot during my Logic days.
__________________
Windows 10x64 | AMD Ryzen 3700X | ATI FirePro 2100 | Marian Seraph AD2, 4.3.8 | Yamaha Steinberg MR816x
"If I can hear well, then everything I do is right" (Allen Sides)
|
|
|
Thread Tools |
|
Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 01:40 AM.
|