Old 08-13-2018, 11:34 AM   #1
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default 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.
Thonex is offline   Reply With Quote
Old 08-13-2018, 11:42 AM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Nice idea ! :P
X-Raym is offline   Reply With Quote
Old 08-13-2018, 11:45 AM   #3
vanhaze
Human being with feelings
 
vanhaze's Avatar
 
Join Date: Jul 2012
Location: Netherlands
Posts: 5,247
Default

This is incredibly useful !
Reminds of same kind of functionality in Logic Pro X, using it's Scissors Tool while CMD key.

Thank you !!
__________________
Macbook Pro INTEL | Reaper, always latest version | OSX Ventura | Presonus Studio 24c
My Reaper Tips&Tricks YouTube Channel: https://www.youtube.com/user/vanhaze2000/playlists
vanhaze is offline   Reply With Quote
Old 08-13-2018, 11:51 AM   #4
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

Quote:
Originally Posted by X-Raym View Post
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.
Thonex is offline   Reply With Quote
Old 08-13-2018, 11:56 AM   #5
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

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.
Thonex is offline   Reply With Quote
Old 08-13-2018, 11:58 AM   #6
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

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)
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 08-13-2018, 12:03 PM   #7
vanhaze
Human being with feelings
 
vanhaze's Avatar
 
Join Date: Jul 2012
Location: Netherlands
Posts: 5,247
Default

Quote:
Originally Posted by Thonex View Post
Edited the code... removed an unnecessary line of code (Continue = 1). That was a vestige of a previous version.

All cleaned up now.
Thanks !!
__________________
Macbook Pro INTEL | Reaper, always latest version | OSX Ventura | Presonus Studio 24c
My Reaper Tips&Tricks YouTube Channel: https://www.youtube.com/user/vanhaze2000/playlists
vanhaze is offline   Reply With Quote
Old 08-13-2018, 12:07 PM   #8
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

Quote:
Originally Posted by Lokasenna View Post
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.
Thonex is offline   Reply With Quote
Old 08-13-2018, 12:10 PM   #9
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

I seem to have made something similar: https://forum.cockos.com/showthread.php?t=150708

(not exactly the same as your script, though )
spk77 is offline   Reply With Quote
Old 08-13-2018, 12:18 PM   #10
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

Quote:
Originally Posted by Lokasenna View Post
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.
Thonex is offline   Reply With Quote
Old 08-13-2018, 12:20 PM   #11
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Awesome Andrew! I had this on my todo list
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 08-13-2018, 12:20 PM   #12
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

@spk77
I knew I saw that before ! ^^
It isn't in reapack so I missed it :P



@Thonex
Even better:


https://github.com/ReaTeam/ReaScript...it%20items.lua
X-Raym is offline   Reply With Quote
Old 08-13-2018, 12:21 PM   #13
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

Quote:
Originally Posted by spk77 View Post
I seem to have made something similar: https://forum.cockos.com/showthread.php?t=150708

(not exactly the same as your script, though )
@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.
Thonex is offline   Reply With Quote
Old 08-13-2018, 12:23 PM   #14
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

@Thonex
BWT, you definitly have to consider GitHub and Reapack now :P Escpeially if you have to update your scripts.
X-Raym is offline   Reply With Quote
Old 08-13-2018, 12:28 PM   #15
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

Quote:
Originally Posted by X-Raym View Post
@Thonex
BWT, you definitly have to consider GitHub and Reapack now :P Escpeially if you have to update your scripts.
Thanks X-Raym,

I got the ok from cfillion... I already set up a GitHub account... and will start migrating scripts that could be useful to others. Just need to read up on his instructions for and checklists for proper integration.
__________________
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.
Thonex is offline   Reply With Quote
Old 08-13-2018, 12:36 PM   #16
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

Side note: I have to say that I'm very impressed with Reaper's maths. I tested this on a 2000 measure part... cutting every measure based on 1 measure time length... and the 2000th cut was perfectly on ... 1.000.

I mean... I shouldn't really be surprised... maths is maths... but I thought doing cuts based on time base derived from bar snap might yield small rounding errors. Maybe if I tried more tests at odd BPMs.
__________________
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.
Thonex is offline   Reply With Quote
Old 08-13-2018, 05:02 PM   #17
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

That was indeed pretty elementary math :P
X-Raym is offline   Reply With Quote
Old 08-13-2018, 10:13 PM   #18
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

Quote:
Originally Posted by X-Raym View Post
That was indeed pretty elementary math :P
LOL... I tried to make it even simpler but I couldn't. I guess technically I don't even need the math.floor() function since the result is only used as a counter limit.

Just glad it works
__________________
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.
Thonex is offline   Reply With Quote
Old 08-14-2018, 06:30 AM   #19
Macc
Human being with feelings
 
Join Date: Feb 2017
Posts: 76
Default

Cubase's best feature (kind of) - thank you!
Macc is offline   Reply With Quote
Old 08-14-2018, 11:54 AM   #20
vanhaze
Human being with feelings
 
vanhaze's Avatar
 
Join Date: Jul 2012
Location: Netherlands
Posts: 5,247
Default

So i made a Custom Action, using this great script from Thonex.
It's useable for creating equal Splits of a mouse pointed Item, based on the set Grid.

Workflow:
Point your mouse over an Item, near to a Gridline.
Execute the Custom Action.

Outcome:
The "first" split in the mousepointed Item will be snapped to the set Grid value.
The other "following" Splits will ofcourse split the Item in equal lengths, thanks to Thonex's Script ofcourse, but the Splits will also obey the set Grid.

Example:
You have set Grid to 1 measure.
Point your mouse over an Item, near a measure gridline.
Execute the Custom Action.
The mousepointed Item will be split into equal parts of X measures, where X is determined by the distance between Item' left edge and the pointed measure gridline.


This Custom Action is really useful if you are doing gridbased stuff.

Download Custom Action here:
https://www.dropbox.com/s/xy5yzy62hm...perKeyMap?dl=0

Beware: ReaPack must be installed and me2beats repository URL must be added to Reapack.
Repository URL me2beats:
https://github.com/me2beats/reapack/...ster/index.xml
__________________
Macbook Pro INTEL | Reaper, always latest version | OSX Ventura | Presonus Studio 24c
My Reaper Tips&Tricks YouTube Channel: https://www.youtube.com/user/vanhaze2000/playlists
vanhaze is offline   Reply With Quote
Old 08-14-2018, 12:08 PM   #21
hopi
Human being with feelings
 
hopi's Avatar
 
Join Date: Oct 2008
Location: Right Hear
Posts: 15,618
Default

nice and handy script... thank you for sharing it!
__________________
...should be fixed for the next build... http://tinyurl.com/cr7o7yl
https://soundcloud.com/hopikiva
hopi is offline   Reply With Quote
Old 08-14-2018, 12:42 PM   #22
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

@vanhaze

Nice one!! Glad you are using it!
__________________
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.
Thonex is offline   Reply With Quote
Old 08-14-2018, 02:50 PM   #23
vanhaze
Human being with feelings
 
vanhaze's Avatar
 
Join Date: Jul 2012
Location: Netherlands
Posts: 5,247
Default

Yes, it's just great !
__________________
Macbook Pro INTEL | Reaper, always latest version | OSX Ventura | Presonus Studio 24c
My Reaper Tips&Tricks YouTube Channel: https://www.youtube.com/user/vanhaze2000/playlists
vanhaze is offline   Reply With Quote
Old 08-14-2018, 04:16 PM   #24
zookthespook
Human being with feelings
 
Join Date: Mar 2015
Location: India Mumbai
Posts: 816
Default

I have been sorely missing this edit function since the time I abandoned cubase.
Thank you for doing this

Regards
Zook
zookthespook is offline   Reply With Quote
Old 08-16-2018, 01:28 PM   #25
Vagelis
Human being with feelings
 
Vagelis's Avatar
 
Join Date: Oct 2017
Location: Larisa, Greece
Posts: 3,795
Default

Very useful script,thanks!
Vagelis is offline   Reply With Quote
Old 09-16-2018, 11:02 AM   #26
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

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.
Thonex is offline   Reply With Quote
Old 02-22-2019, 04:51 AM   #27
Vagelis
Human being with feelings
 
Vagelis's Avatar
 
Join Date: Oct 2017
Location: Larisa, Greece
Posts: 3,795
Default

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.
Vagelis is offline   Reply With Quote
Old 02-27-2019, 07:56 AM   #28
beingmf
Human being with feelings
 
beingmf's Avatar
 
Join Date: Jul 2007
Location: Jazz City
Posts: 5,065
Default

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)
beingmf 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 04:07 AM.


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