Old 06-20-2021, 08:56 PM   #1
Fergler
Human being with feelings
 
Fergler's Avatar
 
Join Date: Jan 2014
Posts: 4,609
Default Where's a 'how to' for GetTrackStateChunk

Reascript API tells me nothing and I can't find anything on the forums or google searches.

I can't figure out what I'm supposed to do with this function, but it seems to be the answer to all things 'is this track x or not'. o.o
__________________
Check out my hip-hop, funk-rock band Theatre Crisp
Fergler is offline   Reply With Quote
Old 06-21-2021, 12:58 AM   #2
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: Apr 2020
Location: Leipzig
Posts: 2,632
Default

Working with Statechunks is fiddly, so the easiest way to work with them is to use Ultraschall-Api for this.
In Ultraschall-Api, I have added tons of functions, that allow passing a statechunk as parameter to get and to set the values in there.

For instance, if you want to get and set the current trackheight of a TrackStateChunk, you can use GetTrackHeightState and SetTrackHeightState:
https://mespotin.uber.space/Ultrasch...ackHeightState
https://mespotin.uber.space/Ultrasch...ackHeightState

You get a TrackStateChunk with reaper.GetTrackStateChunk and you can commit a TrackStateChunk back into a track with reaper.SetTrackStateChunk.

The functions of Ultraschall-Api who probably support TrackStateChunks begin with GetTrackXXX and SetTrackXXX, where XXX is the name of the state.
Look in the functionindex in the docs for Track Management -> Get Track States and Set Track States for a list of them.

https://mespotin.uber.space/Ultrasch...Functions.html

If you have a specific statechunk-entry you want to get/set, you can also look for the statechunk-entry's name in the docs, for instance TRACKHEIGHT to find the functions, who deal with the TRACKHEIGHT-statechunk-entry.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper
Off for some time. Bugreports&Docs notes please do here:https://github.com/Ultraschall/ultra...-reaper/issues - Donate, if you wish
Meo-Ada Mespotine is offline   Reply With Quote
Old 06-21-2021, 03:11 AM   #3
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 7,612
Default

There are actually quite some scriprs and threads about Track Chunk,
it is just a way to get ALL the tracks infos and its items in a string format for quick search/replace/manipulation, if more regular reascript API function doesnt exists or would be too slows for some reason.


It is well documented: https://github.com/ReaTeam/Doc/blob/...%20Definitions


Take inspiration from existing scriprs shared via reapack for eg.



The question is more... what are you trying to achieve ?
X-Raym is offline   Reply With Quote
Old 06-21-2021, 09:06 PM   #4
Fergler
Human being with feelings
 
Fergler's Avatar
 
Join Date: Jan 2014
Posts: 4,609
Default

There were only 6 forum threads before mine and they were all very specific questions about how it works, but not how to use it. The ultraschall-api looks to be the most intelligent, thank you!

I would not have known what to look for to find the state chunk list on GitHub

Looking to do actions to tracks which have a certain record arm state and pass some other conditions.
__________________
Check out my hip-hop, funk-rock band Theatre Crisp
Fergler is offline   Reply With Quote
Old 06-21-2021, 10:47 PM   #5
Fergler
Human being with feelings
 
Fergler's Avatar
 
Join Date: Jan 2014
Posts: 4,609
Default

Using something like GetTrackRecState, how do I return all the variables and not just the first one?

Similarly, how can I use SetTrackRecState without setting all the variables?
__________________
Check out my hip-hop, funk-rock band Theatre Crisp
Fergler is offline   Reply With Quote
Old 06-22-2021, 02:55 AM   #6
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 7,612
Default

Using the forum native search function, you will surely got more threads speaking about this, though indeed most of them are very specific :


https://forum.cockos.com/search.php?searchid=15403459






If you only need track property check, Track Chunk will be overkill, as this cna be several MB long, where property are oftenjust few bytes.


Simply use : GetMediaTrackInfo_Value(track, param) function.

Track state will be "I_RECARM" property.
X-Raym is offline   Reply With Quote
Old 06-22-2021, 03:42 AM   #7
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: Apr 2020
Location: Leipzig
Posts: 2,632
Default

Quote:
Originally Posted by Fergler View Post
Using something like GetTrackRecState, how do I return all the variables and not just the first one?

Similarly, how can I use SetTrackRecState without setting all the variables?
You put more variables before it:
A, B, C, D, E = functionname()

In statechunks, you always need to set all of them, if you want to change one value, so the functions work the same.
So you always need to use the get-function first, then change the value in need, then setting them again with the set-function.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper
Off for some time. Bugreports&Docs notes please do here:https://github.com/Ultraschall/ultra...-reaper/issues - Donate, if you wish

Last edited by Meo-Ada Mespotine; 06-22-2021 at 03:49 AM.
Meo-Ada Mespotine is offline   Reply With Quote
Old 06-22-2021, 02:51 PM   #8
Fergler
Human being with feelings
 
Fergler's Avatar
 
Join Date: Jan 2014
Posts: 4,609
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
You put more variables before it:
A, B, C, D, E = functionname()

In statechunks, you always need to set all of them, if you want to change one value, so the functions work the same.
So you always need to use the get-function first, then change the value in need, then setting them again with the set-function.
That makes sense, thank you so much. Script is getting closer to reality now.
__________________
Check out my hip-hop, funk-rock band Theatre Crisp
Fergler 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:05 PM.


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