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

Reply
 
Thread Tools Display Modes
Old 10-15-2018, 01:29 PM   #1
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default Script: Smart fill gaps by stretching item tails

How's that for a mouthful?

From the wild and wacky brain of Robert Randolph, this one is for editing drum tracks and that sort of thing. Split some items, snap them to the grid, and then let this script try to intelligently fill in any gaps you've left.

It uses a combination of RMS and a couple of max/min lengths to split and stretch the "tails" of your items while leaving the transient alone.



Available now at a ReaPack near you.
__________________
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

Last edited by Lokasenna; 10-16-2018 at 05:41 AM.
Lokasenna is offline   Reply With Quote
Old 10-15-2018, 07:59 PM   #2
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Holy Moles! That kicks ass!!! That's great for splitting -> quantizing -> filling the gaps, thanks Loka!
__________________
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 10-15-2018, 08:25 PM   #3
JamesPeters
Human being with feelings
 
Join Date: Aug 2011
Location: Near a big lake
Posts: 3,943
Default

Looking forward to trying this next time I record!

I found a bit of a bug after running the script the first time. I set a toolbar button to run the script (at the top of the window), and it seems the script opens the windows where the mouse cursor was...cutting off the top of the window and making me unable to click the toolbar buttons (or any of the menu) beneath the window.

Last edited by JamesPeters; 10-18-2018 at 01:07 PM.
JamesPeters is offline   Reply With Quote
Old 10-15-2018, 11:14 PM   #4
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,597
Default

Awesome!
Sexan is offline   Reply With Quote
Old 10-16-2018, 05:15 AM   #5
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Originally Posted by JamesPeters View Post
Looking forward to trying this next time I record!

I found a bit of a bug after running the script the first time. I set a toolbar button to run the script (at the top of the window), and it seems the script opens the windows where the mouse cursor was...cutting off the top of the window and making me unable to click the toolbar buttons (or any of the menu) beneath the window.
Cheers, fixing.
__________________
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 10-16-2018, 05:27 AM   #6
Robert Randolph
Human being with feelings
 
Robert Randolph's Avatar
 
Join Date: Apr 2017
Location: St. Petersburg, FL
Posts: 880
Default

I like how the OP conveniently forgets that I came up with this idea :P

(Script is also awesome btw)
Robert Randolph is offline   Reply With Quote
Old 10-16-2018, 05:40 AM   #7
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Originally Posted by Robert Randolph View Post
I like how the OP conveniently forgets that I came up with this idea :P

(Script is also awesome btw)
I actually had that typed out in an edit but it apparently didn't get saved. :/
__________________
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 10-16-2018, 05:43 AM   #8
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,597
Default

does that mean I am the inventor of this?
https://forum.cockos.com/showpost.ph...1&postcount=11
makers keepers (just kidding)

Anyway off to some drum editing!!!
Sexan is offline   Reply With Quote
Old 10-16-2018, 05:45 AM   #9
BenK-msx
Human being with feelings
 
BenK-msx's Avatar
 
Join Date: Jun 2008
Location: Whales, UK
Posts: 6,009
Default

Long ago I had a macro for doing similar thing v basically for healing clicks glitches pops etc
- will check this out as can be pretty seamless technique.

Edit: ah man 2010!
Not bad for a macro bodger, can't script for toffey, kudos to those that do.

https://forum.cockos.com/showpost.ph...9&postcount=39

__________________
JS Super8 Looper Template & intro | BCF2000 uber info Thread | Who killed the Lounge?

Last edited by BenK-msx; 10-16-2018 at 05:55 AM.
BenK-msx is offline   Reply With Quote
Old 10-16-2018, 05:46 AM   #10
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

For testing purposes, I imported a drum loop into Reaper. The original tempo is 100 BPM.
I split it on the transients, afterwards, I set the timebase to beat positions only.
Then I change the BPM to 120 and the "desired" gaps appear.
Now, when I run the script, nothing happens. Are the gaps too big?
__________________
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 10-16-2018, 05:50 AM   #11
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Originally Posted by Sexan View Post
does that mean I am the inventor of this?
https://forum.cockos.com/showpost.ph...1&postcount=11
makers keepers (just kidding)

Anyway off to some drum editing!!!
brb, find/replacing all instances of the word "menu" in that script with "Sexan".
__________________
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 10-16-2018, 05:53 AM   #12
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Originally Posted by _Stevie_ View Post
For testing purposes, I imported a drum loop into Reaper. The original tempo is 100 BPM.
I split it on the transients, afterwards, I set the timebase to beat positions only.
Then I change the BPM to 120 and the "desired" gaps appear.
Now, when I run the script, nothing happens. Are the gaps too big?
Nothing happens at all?

- If you enable "Place markers when no split point is found" it should drop a bunch of them telling you why it didn't do anything for each item.

- It is possible for a gap to be too big, depending on your settings - if the final stretched rate of the split item would be less than "min. stretch rate" it will skip it rather than dragging your audio out that far.
__________________
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 10-16-2018, 06:16 AM   #13
Robert Randolph
Human being with feelings
 
Robert Randolph's Avatar
 
Join Date: Apr 2017
Location: St. Petersburg, FL
Posts: 880
Default

Quote:
Originally Posted by Sexan View Post
does that mean I am the inventor of this?
https://forum.cockos.com/showpost.ph...1&postcount=11
makers keepers (just kidding)

Anyway off to some drum editing!!!
Yes! I think we can all agree that Sexan > Lokasenna
Robert Randolph is offline   Reply With Quote
Old 10-16-2018, 06:19 AM   #14
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

brb, PMing a mod to change my name to LokaSexan.
__________________
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 10-16-2018, 06:22 AM   #15
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,597
Default

it was just a joke (not sure since internet is a very special place,if its get that way): I cant even use reaper without that majestic script
Sexan is offline   Reply With Quote
Old 10-16-2018, 06:33 AM   #16
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

@Loka

Here's the workflow:

__________________
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 10-16-2018, 06:50 AM   #17
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

I forgot, there's a maximum gap of 0.1s to avoid stretching items across intentional empty spaces. It's hardcoded at the moment - line 41, "local next_item_distance = 0.1" if you want to try adjusting it.

Will look at making it an adjustable setting.

If that doesn't end up being the problem, would you mind sending me that project to look at?
__________________
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 10-16-2018, 07:23 AM   #18
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Sure, no problem at all. I will send you the link via PM!
It's basically just a drum loop I dropped into Reaper.
__________________
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 10-16-2018, 09:02 AM   #19
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Hm, strange, I set the value up to 1 (also tried 0.2, 0.3, etc...) and the same thing happens. Only a red marker gets placed at the end of the items.

But maybe I'm doing something substantially wrong...?
__________________
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

Last edited by _Stevie_; 10-16-2018 at 09:07 AM.
_Stevie_ is offline   Reply With Quote
Old 10-16-2018, 09:24 AM   #20
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Sorry, I was a little cocky. Looks like it's giving up on those items for some reason that I didn't catch with the red markers. Working on it.
__________________
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 10-16-2018, 09:26 AM   #21
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

All good man, I really thought the error is in front of the screen (me)
__________________
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 10-16-2018, 11:03 AM   #22
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Updating. I believe it's fixed.
__________________
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 10-16-2018, 12:16 PM   #23
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Awesome, seems to work! Only the debug output is still enabled
__________________
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 10-16-2018, 12:21 PM   #24
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Yeah, I saw that. Fixed. :P
__________________
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 10-16-2018, 12:35 PM   #25
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Thanks!

There's one thing I wonder in your GIF. There, the transients are kept intact and the tail is stretched. However, that doesn't happen here. Here, the item remains the same, but instead little snippets are inserted into the gaps.
__________________
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 10-16-2018, 02:22 PM   #26
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

If you're still using the project you sent me, the items all have bits of the next transient at the end so it's finding a "correct" point to split there.
__________________
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 10-16-2018, 04:26 PM   #27
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Hmm, thought the same, but then I removed the trailing transients and the result is the same:
__________________
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 10-16-2018, 06:45 PM   #28
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

I'm pretty sure the script doesn't (currently) take item volume into account, so is it possible that the original item actually does have content at -47dB there?
__________________
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 10-16-2018, 06:48 PM   #29
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Err, sorry, forgot to reset the threshold. However, it's still the same when set to the default value. If you still have the project:

1. shorten the trailing transients as seen in my GIF
2. apply the script

It should give you the same result.
__________________
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 10-16-2018, 06:52 PM   #30
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Hmm... looks like my fix for the previous issue broke something else. Which sucks, because I still don't know what was causing the previous issue.
__________________
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 10-16-2018, 06:53 PM   #31
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Awww, I'm sorry, I should just have kept my mouth :O
__________________
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 10-16-2018, 08:21 PM   #32
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Updated.

It was an issue with finding split points for multichannel audio - all of my original testing was in mono so I didn't catch it. It appears to work fine now.
__________________
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 10-17-2018, 05:12 AM   #33
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

The stretching works now! But not for all items.



I also had to lower the threshold a lot.
__________________
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

Last edited by _Stevie_; 10-17-2018 at 06:57 AM.
_Stevie_ is offline   Reply With Quote
Old 10-17-2018, 08:49 AM   #34
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

- Your items are pretty quiet, so with a higher threshold it's probably not finding a place to split before it hits the "protect left" value and gives up. I can make the slider go lower if that would help.

- I'm seeing a couple of items in your test project that it doesn't like, for some reason. If I select everything, it skips them, but selecting those items specifically seems to work fine... I have no idea why.

- If you turn on both of the marker options, is every item at least ending up with a marker now? The previous version was failing and not even doing that much.
__________________
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 10-17-2018, 01:58 PM   #35
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Found the issue...

I had to change to "frames" and set RMS window to 0. Now all items are caught.
Is frames more precise than ms?
__________________
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 10-17-2018, 02:03 PM   #36
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

It shouldn't be, especially if the RMS is 0 because that's going to just end up being peak detection. Good to know though, maybe my RMS code is broken.
__________________
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 10-17-2018, 02:12 PM   #37
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Just FYI, there's also some ReaScript RMS functions:
https://www.extremraym.com/cloud/rea...ItemAverageRMS

RMS window can't be set via ReaScript currently though, so probably not that helpful for your use case anyway.
nofish is offline   Reply With Quote
Old 10-17-2018, 06:48 PM   #38
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

The problem is that I actually have to look through the item for the last position where the RMS is higher than __ dB. I have it looking through each channel, sample by sample, and then keeping a rolling average of the last 200ms or whatever worth of samples to calculate an RMS with.

I think it must be messing up splitting the samples for each channel, but I'm not sure how or why. I might just have it sum the channels or average them instead...
__________________
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 10-20-2018, 08:00 AM   #39
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Alrighty, I rewrote a bunch of the audio code and it appears to be playing nicely with everything now. Here's a version for testing if anybody has a few minutes. It should work on both mono and stereo items:

https://dl.dropboxusercontent.com/s/...em%20tails.lua
__________________
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 10-20-2018, 08:08 AM   #40
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Wooop!!! Just tested with my drum loop project. Worked perfectly on the first try,
congrats!
So you changed the RMS code or even more audio stuff?

Edit: the transient area seems much bigger now? This results in a way more natural sound.
Only the tail is stretched.
__________________
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

Last edited by _Stevie_; 10-20-2018 at 08:18 AM.
_Stevie_ 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 04:03 PM.


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