Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 11-17-2021, 04:07 PM   #1
AZpercussion
Human being with feelings
 
Join Date: Oct 2019
Location: Moscow / Tbilisi
Posts: 909
Default az_Smart split items using mouse cursor context

Different split actions in one shortcut.
You can find it on Reapack. SWS and ReaImGui required.

I made this script for those, who like fast mouse-oriented workflow.
By design it should be assigned to keyboard shortcut, not to a mouse modifier.

Compared to other smart split or mouse split actions this script better due to respect for grouping, snapping and consists different actions in one.
Also it selects items after splitting to let you doing anything else immediately, to choose take, for example, or punch in rec if you are in the selected item auto punch mode.

Just use edit cursor to play and rec from it, and split items quicker by mouse cursor.

There is different behaviour depending on mouse context.
(Is mouse on item or not, is there time selection, is mouse on selected item or not, is time selection crossing selected item, is there razor edit area, what half of item is under mouse - top or bottom)

Also there are a lot of options stored in your config. So now you won't lose your settings after updates anymore.


Split at mouse, edit cursor, razor area or time selection:




Use mouse context to switch different options automatically:



As example you can split item with default fades to remove clicks in speech and use split with crossfade for other purposes.

NOTE: I set crossfade by default - on the left, because it preserve attacks untouched, it may be really important for drums editing, as example.

When you split items at edit cursor, you can use mouse position around it to show what side should be selected.

Also something like this is possible:




Optionally you can split at edit cursor instead of mouse one if mouse is close enough to edit cursor:




Additional functionality - Split automation item:




Bonus – punch-in on the fly for selected item auto-punch rec mode:




How to open Options with the same shortcut:







PS: Thanks for the tips:
Ed Kashinsky
BirdBird

Meo-Ada Mespotine

Edgemeal

Last edited by AZpercussion; 02-07-2024 at 03:21 AM.
AZpercussion is offline   Reply With Quote
Old 11-23-2021, 09:11 AM   #2
gapalil001
Human being with feelings
 
gapalil001's Avatar
 
Join Date: May 2016
Location: Kyiv, Ukraine
Posts: 544
Default

such a great scripts! all of these are useful, Thank You a lot!
gapalil001 is offline   Reply With Quote
Old 11-23-2021, 11:00 AM   #3
tonalstates
Human being with feelings
 
tonalstates's Avatar
 
Join Date: Jun 2020
Posts: 656
Default

Great script, thank you!

One question, how would I activate the punch in? I've tried some things and it doesn't seem to work as shown in the gif but I'm pretty shure it's because i'm the one not working and not the script xD thanks!
tonalstates is offline   Reply With Quote
Old 11-23-2021, 11:24 AM   #4
AZpercussion
Human being with feelings
 
Join Date: Oct 2019
Location: Moscow / Tbilisi
Posts: 909
Default

Quote:
Originally Posted by tonalstates View Post
Great script, thank you!

One question, how would I activate the punch in? I've tried some things and it doesn't seem to work as shown in the gif but I'm pretty shure it's because i'm the one not working and not the script xD thanks!
Glad to hear that!

Punch-in is just a bonus if you are using "auto-punch selected items" record mode.
You can click right button on the transport REC button and find this mode. Also you need deselect items on record armed track.
Then hit record and listen what you have recorded, move mouse ahead and when you are ready, when you found punch point, run my script, it will split item under mouse and select right part, which will be rerecorded.
It just helps doing punch on the fly.
AZpercussion is offline   Reply With Quote
Old 11-23-2021, 12:39 PM   #5
tonalstates
Human being with feelings
 
tonalstates's Avatar
 
Join Date: Jun 2020
Posts: 656
Default

Ah! I get it now hahah it's working now, thank you very much for the whole package.
tonalstates is offline   Reply With Quote
Old 11-23-2021, 01:13 PM   #6
Broojacker
Human being with feelings
 
Join Date: Apr 2016
Location: Ukraine
Posts: 49
Default

I usually used Script: Archie_Item; Split (selected) item(s) under mouse cursor (select right)'Smart.lua as mouse modifier Alt+left click. But sometimes for unknown reasons it don`t work correctly. Thanks for alternative script. Testing...
__________________
soundcloud
Broojacker is offline   Reply With Quote
Old 11-23-2021, 03:08 PM   #7
AZpercussion
Human being with feelings
 
Join Date: Oct 2019
Location: Moscow / Tbilisi
Posts: 909
Default

Quote:
Originally Posted by Broojacker View Post
I usually used Script: Archie_Item; Split (selected) item(s) under mouse cursor (select right)'Smart.lua as mouse modifier Alt+left click. But sometimes for unknown reasons it don`t work correctly. Thanks for alternative script. Testing...
Alt+left click doesn't work correctly (move edit cursor under mouse, I guess) because of this issue: https://forum.cockos.com/showthread.php?t=259821

So that, I assigned my script on S key, which is split by default, but too simple split In addition i got a little more speed. There is no need to press 2 buttons.
AZpercussion is offline   Reply With Quote
Old 11-23-2021, 03:10 PM   #8
AZpercussion
Human being with feelings
 
Join Date: Oct 2019
Location: Moscow / Tbilisi
Posts: 909
Default

Quote:
Originally Posted by tonalstates View Post
Ah! I get it now hahah it's working now, thank you very much for the whole package.
It's just one script, not package
AZpercussion is offline   Reply With Quote
Old 11-23-2021, 04:56 PM   #9
tonalstates
Human being with feelings
 
tonalstates's Avatar
 
Join Date: Jun 2020
Posts: 656
Default

Quote:
Originally Posted by AZpercussion View Post
It's just one script, not package
Oh but it does so much, in a small package <3 Ty
tonalstates is offline   Reply With Quote
Old 05-11-2022, 12:43 PM   #10
tonalstates
Human being with feelings
 
tonalstates's Avatar
 
Join Date: Jun 2020
Posts: 656
Default

Hi, good day! I was wondering if it was possible to add an option to not use the E-cursor to split, as in ignore if no item is under mouse or no time selection. I've found after working on big projects that suddenly my top video item was split up multiple times in different places because of this, maybe by pressing it by accident or missed items, etc

thanks!
tonalstates is offline   Reply With Quote
Old 05-11-2022, 01:29 PM   #11
AZpercussion
Human being with feelings
 
Join Date: Oct 2019
Location: Moscow / Tbilisi
Posts: 909
Default

Yeah, honestly here you should lock your video item. But Reaper still allows to split locked items (facepalm).

I don't want to add anything in current code, because it's rather heavy and ugly-legacy. Somehow I'll rewrite it with more options and graphic interface for them.

So as a workaround for you is temporary changing the code or asking Devs to fix locking.

Try to replace the line number 495
Code:
if TSexist==0 then  --if TS doesn't exist
by this code:
Code:
if TSexist==0 and itemsNUMB ~= -1 then  --if TS doesn't exist and any item selected
AZpercussion is offline   Reply With Quote
Old 05-11-2022, 09:59 PM   #12
tonalstates
Human being with feelings
 
tonalstates's Avatar
 
Join Date: Jun 2020
Posts: 656
Default

Yeah, you're right, it would probably be better if locked items didn't split.. I tried changing the code but now I get a "no time selection" error anytime I run the script over empty arrange space, thanks still, I'll probably keep it the way it is then, just being more careful.
tonalstates is offline   Reply With Quote
Old 10-03-2022, 11:35 AM   #13
BPBaker
Human being with feelings
 
BPBaker's Avatar
 
Join Date: Oct 2013
Location: Brooklyn, NY
Posts: 209
Default

Hi @AZPercussion. I love this script and have been using it as my main splitter. However in recent dev builds, I've noticed that using smart splitting under mouse cursor causes the edit playhead to move a few milliseconds before the split--as if there were a "pre-roll" of sorts. Any thoughts on why that might be? Thanks!
BPBaker is online now   Reply With Quote
Old 10-03-2022, 02:52 PM   #14
AZpercussion
Human being with feelings
 
Join Date: Oct 2019
Location: Moscow / Tbilisi
Posts: 909
Default

Quote:
Originally Posted by BPBaker View Post
Hi @AZPercussion. I love this script and have been using it as my main splitter. However in recent dev builds, I've noticed that using smart splitting under mouse cursor causes the edit playhead to move a few milliseconds before the split--as if there were a "pre-roll" of sorts. Any thoughts on why that might be? Thanks!
Do you sure that this bug presented only in dev builds? What about release version?
Also, what value has curOffset variable in the user area of code?
Have you grid on?

I noticed some bugs, but it seems different.
AZpercussion is offline   Reply With Quote
Old 10-04-2022, 04:51 PM   #15
BPBaker
Human being with feelings
 
BPBaker's Avatar
 
Join Date: Oct 2013
Location: Brooklyn, NY
Posts: 209
Default

Quote:
Originally Posted by AZpercussion View Post
Do you sure that this bug presented only in dev builds? What about release version?
Also, what value has curOffset variable in the user area of code?
Have you grid on?

I noticed some bugs, but it seems different.
Hmm...Maybe it's not a dev build thing after all. I tried it in the most recent release version and get the same issue with the edit cursor jumping (sometimes right before the split, sometimes not at all if the split is to the right of the playhead).



Maybe it's always been this way and I'm just noticing for the first time now? But I guess with an "under mouse" edit function, I'd expect the edit cursor to always jump to the last split, or simply not jump at all. (I think I prefer having the edit cursor jump to the split when not actively playing, though.) What do you think?
BPBaker is online now   Reply With Quote
Old 10-05-2022, 02:26 AM   #16
AZpercussion
Human being with feelings
 
Join Date: Oct 2019
Location: Moscow / Tbilisi
Posts: 909
Default

Quote:
Originally Posted by BPBaker View Post
Hmm...Maybe it's not a dev build thing after all. I tried it in the most recent release version and get the same issue with the edit cursor jumping (sometimes right before the split, sometimes not at all if the split is to the right of the playhead).

Maybe it's always been this way and I'm just noticing for the first time now? But I guess with an "under mouse" edit function, I'd expect the edit cursor to always jump to the last split, or simply not jump at all. (I think I prefer having the edit cursor jump to the split when not actively playing, though.) What do you think?
Ah, it's not milliseconds, it's one second.
The intention was to give the user some perspective in listening.
This behavior exist several month I think...
Don't you need some pre-roll to hear you edits in context? You split to change a take, move timings, put an fx on a take, create fades...
Similar behavior exist in my Fade tool script.
It just save you extra mouse dragging and click.

But if you whant to switch off this feature, you can look at the user area of script code. You can set moveEditCursor = false or use these settings:
moveEditCursor = true
curOffset = 0
editCurDistance = 0


You have interesting point about moving cursor when stopped only.
For now only recording state is considered.
I have plans to rewrite the script because of couple bugs, feature possibilities and code clarity. I'll include your point into design.

But it's not a close perspective. You can make some changes in code for a while.
There is a function MoveEditCursor on the top of the code.
Just replace it by this:
Code:
function MoveEditCursor(timeTable, EditCurPos)
  if #timeTable > 0 then
    local timepos = math.min(table.unpack(timeTable))
    local playState = reaper.GetPlayStateEx(0)
    
    if moveEditCursor == true
    and (timepos - EditCurPos > editCurDistance or timepos -0.2 <= EditCurPos)
    --^^here small coeff to avoid extra small distance
    and playState == 0 then
      reaper.SetEditCurPos2(0, timepos - curOffset, false, false)
    end
  end
end
AZpercussion is offline   Reply With Quote
Old 10-05-2022, 07:46 AM   #17
BPBaker
Human being with feelings
 
BPBaker's Avatar
 
Join Date: Oct 2013
Location: Brooklyn, NY
Posts: 209
Default

Quote:
Originally Posted by AZpercussion View Post
The intention was to give the user some perspective in listening....Don't you need some pre-roll to hear you edits in context?
Ah, okay good to know it is intentional. I see your point and that is useful in many cases. Perhaps I'll have a think about whether I would actually prefer not to have a pre-roll. Honestly, this hasn't gotten in the way of my workflow--it's just something I noticed while making small edits zoomed in and figured was a bug. But I see it's actually feature!

Thanks for pointing out where to modify the code so I can experiment with what feels best for my workflow--very helpful for people like me who are better at editing scripts than reading/writing them. ;-)
BPBaker is online now   Reply With Quote
Old 10-05-2022, 08:18 AM   #18
AZpercussion
Human being with feelings
 
Join Date: Oct 2019
Location: Moscow / Tbilisi
Posts: 909
Default

Glad to be helpful
AZpercussion is offline   Reply With Quote
Old 10-06-2022, 12:00 AM   #19
hans
Human being with feelings
 
Join Date: Aug 2020
Posts: 276
Default

Started to use this script recently! It's working as expected.
Just one thought.

When there is a time selection over an item, it splits the item on both sides within time selection even if I have the mouse cursor hoovering over another item far from the selected area.

When I want to split the item at mouse cursor, I'm accidentally splitting other items within time selections. This creates a lot of ctrl-z moments for me , since time selection are frequently being created when I left drag on tracks and items. I then have to reach for my shortcut to clear time selection areas a lot.

An idea would be to only split the item within time selection when mouse cursor is inside the time selection area.
This would make splitting at time selection happen lot less unintentionally.

I feel I have to clear time selection so often to have a smooth workflow with this.

Maybe this idea will upset people already used to the script, and I'm not sure I'm right about this.

Other than that, great idea and thanks for the script!

Last edited by hans; 10-06-2022 at 12:11 AM.
hans is offline   Reply With Quote
Old 10-06-2022, 04:27 AM   #20
AZpercussion
Human being with feelings
 
Join Date: Oct 2019
Location: Moscow / Tbilisi
Posts: 909
Default

Hello, Hans!
I tried to replicate this and for me the script works well.
Look:



Do you shure you have the latest version?
But, honestly, it was that way all the time...
AZpercussion is offline   Reply With Quote
Old 10-06-2022, 05:44 AM   #21
hans
Human being with feelings
 
Join Date: Aug 2020
Posts: 276
Default

Hi AZpercussion!

Thanks.

Sorry, Now I get it. lol.
hans is offline   Reply With Quote
Old 07-10-2023, 12:43 PM   #22
MonkeyBars
Human being with feelings
 
MonkeyBars's Avatar
 
Join Date: Feb 2016
Location: Hollyweird
Posts: 2,630
Default

But what is your repo URL??
MonkeyBars is offline   Reply With Quote
Old 07-11-2023, 01:14 AM   #23
AZpercussion
Human being with feelings
 
Join Date: Oct 2019
Location: Moscow / Tbilisi
Posts: 909
Default

I upload my scripts via Reapack service directly into default Reateam repository.
AZpercussion is offline   Reply With Quote
Old 07-11-2023, 10:15 AM   #24
MonkeyBars
Human being with feelings
 
MonkeyBars's Avatar
 
Join Date: Feb 2016
Location: Hollyweird
Posts: 2,630
Default

ah cool found it. how does one get accepted to the ReaTeam repo
MonkeyBars is offline   Reply With Quote
Old 07-11-2023, 03:10 PM   #25
AZpercussion
Human being with feelings
 
Join Date: Oct 2019
Location: Moscow / Tbilisi
Posts: 909
Default

Quote:
Originally Posted by MonkeyBars View Post
ah cool found it. how does one get accepted to the ReaTeam repo
You can use this service: https://reapack.com/upload
But as I understand there are limitations compared to you own repository, particularly you can only make a request for upload and need to wait for it.
AZpercussion is offline   Reply With Quote
Old 10-31-2023, 07:23 PM   #26
tonalstates
Human being with feelings
 
tonalstates's Avatar
 
Join Date: Jun 2020
Posts: 656
Default

Hi, is it me or this stopped working on new fixed lanes? Im on latest Official and Dev versions. Thanks!
tonalstates is offline   Reply With Quote
Old 11-01-2023, 07:56 AM   #27
AZpercussion
Human being with feelings
 
Join Date: Oct 2019
Location: Moscow / Tbilisi
Posts: 909
Default

Hi! It should work. It has been working with fixed lanes for about two years. Can I see a gif?
AZpercussion is offline   Reply With Quote
Old 11-01-2023, 09:05 AM   #28
tonalstates
Human being with feelings
 
tonalstates's Avatar
 
Join Date: Jun 2020
Posts: 656
Default

Sure, no prob. I'm out at work but at night I'll upload it. Thank you.
tonalstates is offline   Reply With Quote
Old 11-01-2023, 05:56 PM   #29
tonalstates
Human being with feelings
 
tonalstates's Avatar
 
Join Date: Jun 2020
Posts: 656
Default

Yup, I opened reaper and now it works hahaha typical anyway, what I was experiencing was that the split wasn't happening under the mouse only where the edit cursor was and it only seemed to happen on lanes.. But again, it's working now so it was probably something else haha Thank you still!
tonalstates is offline   Reply With Quote
Old 11-02-2023, 02:07 PM   #30
AZpercussion
Human being with feelings
 
Join Date: Oct 2019
Location: Moscow / Tbilisi
Posts: 909
Default

Haha, good to know! Honestly, I had stumbled with some strange behavior from time to time with different Reaper features. Very rare, but it was. Restarting helped, though.
AZpercussion is offline   Reply With Quote
Old 11-02-2023, 10:24 PM   #31
tonalstates
Human being with feelings
 
tonalstates's Avatar
 
Join Date: Jun 2020
Posts: 656
Default

Ha! found it, it's a weird interacting between track spacers, seems to me like maybe either the script is not taking them into account or something

tonalstates is offline   Reply With Quote
Old 11-03-2023, 03:23 AM   #32
AZpercussion
Human being with feelings
 
Join Date: Oct 2019
Location: Moscow / Tbilisi
Posts: 909
Default

Quote:
Originally Posted by tonalstates View Post
Ha! found it, it's a weird interacting between track spacers, seems to me like maybe either the script is not taking them into account or something
Ah, thanks, I got it. It's an SWS bug, and it become bigger with track spacers. I should push a workaround, obviously. I'll try to manage it next week.
AZpercussion is offline   Reply With Quote
Old 11-03-2023, 06:17 AM   #33
AZpercussion
Human being with feelings
 
Join Date: Oct 2019
Location: Moscow / Tbilisi
Posts: 909
Default

SWS guys have already fixed this. You can download the latest build of sws, it's a level deeper than pre-release, lol
https://github.com/reaper-oss/sws/pu...ent-1782573658
AZpercussion is offline   Reply With Quote
Old 11-03-2023, 08:46 AM   #34
tonalstates
Human being with feelings
 
tonalstates's Avatar
 
Join Date: Jun 2020
Posts: 656
Default

Awesome, I'll try it out and see. Thank you!
tonalstates is offline   Reply With Quote
Old 12-20-2023, 05:21 PM   #35
abnegative
Human being with feelings
 
Join Date: Sep 2022
Posts: 222
Default

AZpercussion,

Thank you so much for this!

I was changing up some mouse modifiers literally yesterday to account for the lack of a "smart-split" function. I ended up settling for making razor edits also select time, and then mapping the 'S' shortcut to time selection splits instead of edit cursor splits.

Then today I found your script, and now I have the ideal solution where I can use 'S' for all my splits (and I can revert back to razor edits not also selecting time).

These little things matter so much when it comes to remaining in a creative state.
abnegative is offline   Reply With Quote
Old 12-22-2023, 11:44 AM   #36
AZpercussion
Human being with feelings
 
Join Date: Oct 2019
Location: Moscow / Tbilisi
Posts: 909
Default

Glad to hear that!
I'm slowly working on a huge update for this script.
More options, stored in config, bug fixes, some new features, etc.
It's tricky to abandon native split action, but I have to do that and I see the light in the end. I hope that New Year hollidays will help me finish.
AZpercussion is offline   Reply With Quote
Old 01-04-2024, 08:45 PM   #37
abnegative
Human being with feelings
 
Join Date: Sep 2022
Posts: 222
Default smart_split.lua - Modified version

I personally only needed a subset of the functionality this script offers, and I refuse to use SWS... so I'm sharing my modified version here for anyone in the same boat.

I removed the SWS dependency, and I simplified the split logic to only split at razor-edit edges xor the edit cursor.

Edit: I forgot to mention -- I disabled global split at edit cursor (target media items must be explicitly selected).
Attached Files
File Type: lua smart_split.lua (15.6 KB, 18 views)
abnegative is offline   Reply With Quote
Old 01-05-2024, 02:54 AM   #38
AZpercussion
Human being with feelings
 
Join Date: Oct 2019
Location: Moscow / Tbilisi
Posts: 909
Default smart_split.lua - Modified version

Hi, abnegative! Why do you refuse to use SWS?
So many users use it as native part of Reaper so it's often means if you use Reaper you use SWS.
Yes, sometimes there something is broken, but for the most part there are a lot of actions and API functions which can not be substitute by native ones.

Quote:
I forgot to mention -- I disabled global split at edit cursor (target media items must be explicitly selected).
Saying about this there is an option in Preferences -> Editing Behavior
"If no items are selected, some split/trim/delete actions affect all items at the edit cursor".
My script respects this option and I working on that the locked items will not splitted.
Also it's a good idea to make an option that switches off global split at all.
AZpercussion is offline   Reply With Quote
Old 01-06-2024, 03:43 PM   #39
abnegative
Human being with feelings
 
Join Date: Sep 2022
Posts: 222
Default

Quote:
Why do you refuse to use SWS?
It's just my own personal philosophy: If it is possible/practical to achieve a desired result without adding a new dependency, then I go that route. I like to minimize dependencies, regardless of how lightweight they may be. Also, I prefer not to see SWS menu options that I will never use. In 1.5 years of using REAPER I haven't had a need that I couldn't resolve without using SWS. I don't even have the ReaPack extension installed. The only extension I use is imgui because it allows me to use Sexan's Paranormal FX Router.

Quote:
Saying about this there is an option in Preferences -> Editing Behavior
"If no items are selected, some split/trim/delete actions affect all items at the edit cursor".
I didn't realize this, thanks! By the way, we'd say "speaking" instead of "saying" here.

Quote:
My script respects this option and I working on that the locked items will not splitted.
I'll be back to grab the new logic when you get this working.

Quote:
Also it's a good idea to make an option that switches off global split at all.
I completely agree with you. I didn't do this initially because I made the change for my own needs and then later decided to share.
abnegative is offline   Reply With Quote
Old 02-05-2024, 06:34 AM   #40
AZpercussion
Human being with feelings
 
Join Date: Oct 2019
Location: Moscow / Tbilisi
Posts: 909
Default

Quote:
Originally Posted by abnegative View Post
By the way, we'd say "speaking" instead of "saying" here.
Thanks for the tip!


Quote:
Originally Posted by abnegative View Post
I'll be back to grab the new logic when you get this working.
And... I have it done, eventually! But it still needs a couple of SWS functions, there is no alternative.

It was really huge journey to rewrite this script. There are a lot of options in it which are interact each other and around 40 behavior variants. Some corner cases works better than native Reaper actions!

And finally, it respects locked items, ahahah, after years!

It wouldn't so tricky if we would have more wide API regarding item grouping.
And, honestly, item grouping seems legacy feature now, when we have track razor/media grouping, but if I decided to make a multipurpose script it have to work correct.

So, I'll change the description in the first post here and it will come on Reapack soon.
AZpercussion 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 10:12 AM.


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