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

Reply
 
Thread Tools Display Modes
Old 06-14-2015, 01:41 PM   #1
loopa
Human being with feelings
 
Join Date: Jul 2014
Posts: 207
Default Load/Save Track state including FX with GetSetTrackState()

Hi! I want to do an A/B-script for a track or an FX. So I need to load/save Track state including any FX (in it's entirety).

I see one could use RPR_GetSetTrackState() in python for this.

I wonder, does this API function still have a data size limit on how large strings it can handle? And is it a good fit for this?

If EEL works better, I can use that too. Or as a last resort, C++, but I'd rather avoid it to save time.

Cheers,
Loops

Last edited by loopa; 06-14-2015 at 02:03 PM.
loopa is offline   Reply With Quote
Old 06-14-2015, 02:59 PM   #2
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Posts: 2,436
Default

Quote:
Originally Posted by loopa View Post
I wonder, does this API function still have a data size limit on how large strings it can handle? And is it a good fit for this?
Not if you use SWS API - with SWS installed, search the API documentation for WDL_FastString
Breeder is offline   Reply With Quote
Old 06-15-2015, 01:42 AM   #3
loopa
Human being with feelings
 
Join Date: Jul 2014
Posts: 207
Default

Thanks Breeder,

I'm gonna check it out! Is that C++ though? I'd love if possible to do in Python or EEL? (Or Lua?)

Cheers,
Loopas
loopa is offline   Reply With Quote
Old 06-15-2015, 01:53 AM   #4
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Posts: 2,436
Default

Quote:
Originally Posted by loopa View Post
Thanks Breeder,

I'm gonna check it out! Is that C++ though? I'd love if possible to do in Python or EEL? (Or Lua?)

Cheers,
Loopas
Nope, ReaScript...it just wraps WDL_FastString which you can then manipulate with SWS API. It definetly works in python, haven't tried with other ReaScript flavors.
Breeder is offline   Reply With Quote
Old 06-15-2015, 01:12 PM   #5
loopa
Human being with feelings
 
Join Date: Jul 2014
Posts: 207
Default

Hi again, sorry im a bit confused.

Should i then use this API-function to get the state?:

SNM_GetSetObjectState()

?
loopa is offline   Reply With Quote
Old 06-15-2015, 01:30 PM   #6
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Posts: 2,436
Default

Quote:
Originally Posted by loopa View Post
Hi again, sorry im a bit confused.

Should i then use this API-function to get the state?:

SNM_GetSetObjectState()

?
Yes!

Here's one my old scripts I used to toggle layouts using python and SNM chunk API
Code:
from reaper_python import *
from sws_python import *
import re

# If third layout is found, Layout1 gets applied
Layout1Name = '12 -- FX Rack'
Layout2Name = ''
Layout1Cmd  = 41703	# Layout: apply custom layout #08
Layout2Cmd  = 41697 # Layout: apply custom layout #02


def GetTrackChunk (track):
    fs = SNM_CreateFastString("")
    SNM_GetSetObjectState(track, fs, 0, 0)
    chunk = SNM_GetFastString(fs)
    SNM_DeleteFastString(fs)
    if chunk:
        return chunk
    else:
        return ''

def GetLayout (track, mcp):
	chunk = GetTrackChunk(track)
	input = re.findall("LAYOUTS.*",chunk)
	if len(input) == 0:
		return ''
	else:
		mode = 1 if mcp == False else 2
		layout = (input[0].split(" \""))[mode]
		layout = layout[0:-1] # Remove " from the end of the string
		return layout

def SwitchLayouts (track, mcp):
	layout = GetLayout(track, mcp)
	cmd = 0
	if len(layout) == 0: # no layout set
		cmd = Layout1Cmd
	else:
		cmd = Layout2Cmd if layout == Layout1Name else Layout1Cmd
	RPR_Main_OnCommand(cmd, 0)

if (RPR_CountTracks(0)):
	SwitchLayouts(RPR_GetSelectedTrack(0, 0), True)
But ever since I exported additional SWS API, I've rewritten it for Lua so I don't know if it still works - it did with REAPER v4
Breeder is offline   Reply With Quote
Old 06-16-2015, 03:17 AM   #7
loopa
Human being with feelings
 
Join Date: Jul 2014
Posts: 207
Default

Nice! It worked perfectly to save/load track state!

I'm need to save/load only 1 FX of the track. Is it safe to extract/inject only the state string data for a single FX into the trach chunk? Seems to be the only way right?

Or this that perhaps frowned upon?

Thank you so much for all the help, btw!

Here's link to the other thread just in case:
http://forum.cockos.com/showthread.p...43#post1535243

Last edited by loopa; 06-16-2015 at 03:55 AM.
loopa is offline   Reply With Quote
Old 06-16-2015, 03:30 AM   #8
loopa
Human being with feelings
 
Join Date: Jul 2014
Posts: 207
Default

Hi again! I'll post this as a new question (extract/inject plugin data into track chunk) in the Forum since I think it's different from the OP
loopa is offline   Reply With Quote
Old 08-31-2016, 01:07 PM   #9
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 633
Default

Quote:
Originally Posted by Breeder View Post
Yes!

Here's one my old scripts I used to toggle layouts using python and SNM chunk API
Code:
from reaper_python import *
from sws_python import *
...
if (RPR_CountTracks(0)):
	SwitchLayouts(RPR_GetSelectedTrack(0, 0), True)
But ever since I exported additional SWS API, I've rewritten it for Lua so I don't know if it still works - it did with REAPER v4
Do you have that LUA code? If I don't get my API request to load/save FXB's, I'm thinking I could compromise and load track state... a lot less flexible, but I think it would work.
__________________
eric moon
Very Stable Genius
https://gogolab.com/
woodslanding 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 06:18 AM.


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