Old 06-06-2018, 04:05 AM   #1
Sju
Human being with feelings
 
Join Date: Jun 2015
Posts: 685
Default Moving tracks with ReaScript

As far as I can see, there's no simple way to move tracks around with ReaScript. Is this really the case?

There seem to be two workarounds for this: X-Raym script which copies the track to the new position, copies the send envelope (?), and deletes the old one. Other is just cut & pasting the tracks to new positions.

The copy&paste method has a major drawback though: all effects on the pasted track will have to be reloaded into memory, which will be a problem with plugins with big states like samplers for example.

So I guess the only way to achieve this efficiently would be to go poking around in the project state chunk and manually changing the track indices? Has anyone had to do this before?
Sju is offline   Reply With Quote
Old 06-06-2018, 04:16 AM   #2
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

5.90: API: add ReorderSelectedTracks()

Code:
Lua: boolean reaper.ReorderSelectedTracks(integer beforeTrackIdx, integer makePrevFolder)

Moves all selected tracks to immediately above track specified by index beforeTrackIdx, returns false if no tracks were selected. makePrevFolder=0 for normal, 1 = as child of track preceding track specified by beforeTrackIdx, 2 = if track preceding track specified by beforeTrackIdx is last track in folder, extend folder
__________________
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 06-06-2018, 04:27 AM   #3
Sju
Human being with feelings
 
Join Date: Jun 2015
Posts: 685
Default

Oo nice! thanks for the heads-up.

I wish they updated the API docs sometimes...
Sju is offline   Reply With Quote
Old 06-06-2018, 04:39 AM   #4
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

It's updated every time - Help | ReaScript Documentation.

X-Raym's is sometimes a little behind, if you're using that.
__________________
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 06-06-2018, 04:54 AM   #5
Sju
Human being with feelings
 
Join Date: Jun 2015
Posts: 685
Default

Oh I didn't know they included the docs with the install. I was going by the one hosted on reaper.fm. Good to know, thanks.
Sju is offline   Reply With Quote
Old 06-06-2018, 07:43 AM   #6
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

They don't include it... it is generated, based on your own install ! (if you have extension etc)

Quote:
I was going by the one hosted on reaper.fm.
Don't that. It is too obsolete.

Quote:
X-Raym's is sometimes a little behind, if you're using that.
Indeed.


But from a user experience point of view, it is a bit ahead of the generated one :P
X-Raym is offline   Reply With Quote
Old 06-06-2018, 09:36 AM   #7
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

@Sju
Mpl have updated my move track script, if you syc reapack, you should see the new version of these scripts with this API
X-Raym is offline   Reply With Quote
Old 06-06-2018, 03:00 PM   #8
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by X-Raym View Post
But from a user experience point of view, it is a bit ahead of the generated one :P
Absolutely.
nofish is offline   Reply With Quote
Old 06-08-2018, 04:32 AM   #9
Sju
Human being with feelings
 
Join Date: Jun 2015
Posts: 685
Default

Quote:
Originally Posted by X-Raym View Post
@Sju
Mpl have updated my move track script, if you syc reapack, you should see the new version of these scripts with this API
Thanks. I checked out the alphabetic sort. Not exactly my use case but an useful example.
Sju is offline   Reply With Quote
Old 01-17-2019, 10:20 AM   #10
bFooz
Human being with feelings
 
Join Date: Jul 2010
Location: Slovakia
Posts: 2,588
Default

Hi, I tried to use this function in a deferred script and it generates an undo point.

Is this a bug? What tou think? Is there any way around it?
bFooz is offline   Reply With Quote
Old 01-17-2019, 11:31 AM   #11
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

You're changing the project, so it makes sense that it would create an undo point.

One issue with defer scripts is that you can't extend a Undo_BeginBlock section over multiple script loops - I had an FR a while back about giving us a way to do that, don't think it got much attention.
__________________
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
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 12:28 PM.


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