Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Feature Requests

Reply
 
Thread Tools Display Modes
Old 11-26-2021, 04:25 PM   #1
MonkeyBars
Human being with feelings
 
MonkeyBars's Avatar
 
Join Date: Feb 2016
Location: Hollyweird
Posts: 2,637
Default [FIXED] ReaScript API: GetSetProjectData_String for storing script state

Currently, there is nowhere to save custom script data outside the tracks in a project whose deltas are registered by the Undo History. Project ExtState, Project Info, Project Info Strings, and Master Track P_EXT are all outside the Undo History.

Many scripts need to track their special data's state in the project that updates along with the users' actions. Doing so in a hidden dummy track or item is a sloppy workaround prone to disastrous errors when users clean up their projects.

I propose a simple GetSetProjectData_String function that works like the rest of the GetSet functions, offering P_EXT and any other interesting parameters the Reaper devs deem may be useful to devs.

Last edited by MonkeyBars; 12-23-2021 at 07:37 AM.
MonkeyBars is offline   Reply With Quote
Old 11-27-2021, 01:55 AM   #2
MonkeyBars
Human being with feelings
 
MonkeyBars's Avatar
 
Join Date: Feb 2016
Location: Hollyweird
Posts: 2,637
Default

Found a decent workaround to store P_EXT values in the Master Track Tempo Envelope. It doesn't appear possible to deactivate it, so it seems like the perfect permanent place to store project data whose changes you want picked up by undo points.

Last edited by MonkeyBars; 12-04-2021 at 02:14 PM.
MonkeyBars is offline   Reply With Quote
Old 11-27-2021, 04:03 AM   #3
FeedTheCat
Human being with feelings
 
FeedTheCat's Avatar
 
Join Date: May 2019
Location: Berlin
Posts: 2,205
Default

+1

Quote:
Originally Posted by MonkeyBars View Post
Found a decent workaround to store P_EXT values in the Master Track Tempo Envelope. I doesn't appear possible to deactivate it, so it seems like the perfect permanent place to store project data whose changes you want picked up by undo points.
What a nice find! I'll definitely try this, sounds like a great workaround.
__________________
Featured scripts: REAPER Update UtilityLil ChordboxGridbox/Adaptive gridMX TunerRS5K LinkMIDI Editor Magic Donate💝: PayPal|ko-fi
FeedTheCat is offline   Reply With Quote
Old 11-30-2021, 11:54 PM   #4
MonkeyBars
Human being with feelings
 
MonkeyBars's Avatar
 
Join Date: Feb 2016
Location: Hollyweird
Posts: 2,637
Default

You're welcome, FTC! So glad the legendary dev of Update Utility can use this little finding!

I have been testing it and this solution appears to have solved the undo bugs that plagued my project before.
MonkeyBars is offline   Reply With Quote
Old 12-02-2021, 04:54 AM   #5
FeedTheCat
Human being with feelings
 
FeedTheCat's Avatar
 
Join Date: May 2019
Location: Berlin
Posts: 2,205
Default

Quote:
Originally Posted by MonkeyBars View Post
You're welcome, FTC! So glad the legendary dev of Update Utility can use this little finding!

I have been testing it and this solution appears to have solved the undo bugs that plagued my project before.
Haha, not sure about my legend status This workaround seems to be really solid so far. I tried some stuff to break it (clearing the tempo envelope etc.) but I haven't found any downsides so far.
__________________
Featured scripts: REAPER Update UtilityLil ChordboxGridbox/Adaptive gridMX TunerRS5K LinkMIDI Editor Magic Donate💝: PayPal|ko-fi
FeedTheCat is offline   Reply With Quote
Old 12-04-2021, 01:09 PM   #6
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

Why not using ProjExtState? This sounds like tge thing you asked for?
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 12-04-2021, 02:13 PM   #7
MonkeyBars
Human being with feelings
 
MonkeyBars's Avatar
 
Join Date: Feb 2016
Location: Hollyweird
Posts: 2,637
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
Why not using ProjExtState? This sounds like tge thing you asked for?
Please read OP carefully
MonkeyBars is offline   Reply With Quote
Old 12-05-2021, 01:48 PM   #8
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

And the undo-functions don't create an undo-point either? Like putting it between
https://mespotin.uber.space/Ultrasch...ndo_BeginBlock
and
https://mespotin.uber.space/Ultrasch...#Undo_EndBlock
?

If not, I'd rather consider this a bug.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 12-05-2021, 02:15 PM   #9
MonkeyBars
Human being with feelings
 
MonkeyBars's Avatar
 
Join Date: Feb 2016
Location: Hollyweird
Posts: 2,637
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
And the undo-functions don't create an undo-point either?.
No they do not
MonkeyBars is offline   Reply With Quote
Old 12-06-2021, 11:15 AM   #10
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

Found that too. I think, this should be considered as either a bug or oversight, as using the undo-functions for this should be the way to go for all the functions you mentioned.
Especially as they change the project.

So in my opinion, I wouldn't want to have another function, but have the functions you mentioned being supportable using the Undo-functions.

I might have an idea, that I'll check. Maybe a workaround is possible but I need to test it out first...
Basically something like, running a function, that changes track-selection, which is undo-function-compatible, might include changes to ProjExtStates too, when both done within the undo-functions.

I'll test it tonight to see, if my idea works or if it's rubbish.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 12-06-2021, 11:22 AM   #11
MonkeyBars
Human being with feelings
 
MonkeyBars's Avatar
 
Join Date: Feb 2016
Location: Hollyweird
Posts: 2,637
Default

Very interesting, but actually imo it's desirable to have both data types (persistent and undo-compatible) available to script devs for varied use cases.
MonkeyBars is offline   Reply With Quote
Old 12-06-2021, 11:28 AM   #12
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

Well that would be easy:

Persistent, use the functions as of yet.

Undoable, put the function inside Undo_BeginBlock and Undo_EndBlock.

That way, you can decide yourself between persistent and undoable.

Especially, if you use different ids, like different section-key-combinations in ProjExtState, it should be easy to differentiate between undoable ProjExtStates and persistent ones.

Unless I missed something.

Haven't thought it through with the other functions, though, so I don't know, if they wouldn't work like that per design.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 12-07-2021, 11:36 AM   #13
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

No luck with my workaround idea as I couldn't trigger an undo-point for ProjExtStates, only for P_EXT on regular tracks.
But after thinking about it a little further, keeping the current behavior could be the better idea,
as some scripts might have functions like SetProjExtState inside of Undo_BeginBlock and Undo_EndBlock
under the assumption, that it never creates undo points. So they would break or at least behave
unexpected, if out of a sudden, undo would be supported for ProjExtStates.

But, I made another interesting find.

From your OP, I assume, that you tried to use P_EXT on the master-track to trigger an undo-point, just as it
does on normal tracks, but it doesn't.
The reason for this behavior is: P_EXT isn't supported on the master track itself in the first place, only
on envelopes of the master track(like in your workaround), from what I saw. The GetSetMediaTrackInfo_String is
confusing in that case, as it returns true when trying to set P_EXT on master track, even if it doesn't create
it and should return false instead.

So, I would propose something, that might help you get your wished behavior without hacks but with undo and a reliable data-location:
adding P_EXT support for the master track itself.

This would have several benefits:

1) The master track can't be deleted so all its P_EXTs are safe
2) P_EXT on other tracks already support UNDO-blocks optionally, so adding that to the master track is basically a
continuation of the P_EXT-behavior of regular tracks.
3) as this is a feature added, it will not break existing scripts, as no script expects P_EXT to work on master track, and
even if it did, it should know, that P_EXT could be made undoable using undo-functions and act accordingly.
If it doesn't, it should be considered a buggy script.
4) We don't need yet another function to store data into the project but rather use existing concepts and structures.
Which is also easier for scripters, who could be confused, why two functions, who basically do the same, exist, and
which one to use.

So adding P_EXT-support on the master-track could be your solution and might be easier to implement for the devs.
Unless the devs already considered the option and decided against it due some issues, back when they added P_EXT.

BTW: thanks for bringing this up. Will add to my API-docs the information surrounding the potential undo-problems,
so the information doesn't get lost in the forum's old-threads-nirvana.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 12-07-2021, 12:09 PM   #14
MonkeyBars
Human being with feelings
 
MonkeyBars's Avatar
 
Join Date: Feb 2016
Location: Hollyweird
Posts: 2,637
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
The reason for this behavior is: P_EXT isn't supported on the master track itself in the first place, only
on envelopes of the master track(like in your workaround), from what I saw. The GetSetMediaTrackInfo_String is
confusing in that case, as it returns true when trying to set P_EXT on master track, even if it doesn't create
it and should return false instead.
Thanks so much for your extensive research!

However, what you report here is not what I found. Master Track P_EXT works just fine for me, but is outside the undo system – unlike its envelopes (which does make sense to me actually – of course all envelopes need to live in the undo system). I reported this here: https://forum.cockos.com/showpost.ph...7&postcount=30
MonkeyBars is offline   Reply With Quote
Old 12-08-2021, 08:13 AM   #15
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

Hmm, that's odd.

Is it still available when you save, close and reopen the project?

If yes, then P_EXT isn't stored in projectfiles in the render-queue(which I used for my experiments) and would explain, why I observed something different.

But yeah, if it is, undo-capabilities for the master-track's P_EXT should be added then.
Especially for usecases like yours and consistency in behavior.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 12-08-2021, 08:42 AM   #16
MonkeyBars
Human being with feelings
 
MonkeyBars's Avatar
 
Join Date: Feb 2016
Location: Hollyweird
Posts: 2,637
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
Is it still available when you save, close and reopen the project?
Ah that's a good point – very thorough! Confirmed that Master Track P_EXT does NOT save with the project. That's very strange to me – so is all P_EXT only available per project load??

I just tested the master tempo envelope P_EXT as well and it's GONE on project reload. That's a bug for sure imo.

Regular track P_EXT DOES save on project reload.

Bug report: https://forum.cockos.com/showthread.php?p=2504245

Last edited by MonkeyBars; 12-08-2021 at 08:51 AM.
MonkeyBars is offline   Reply With Quote
Old 12-08-2021, 12:38 PM   #17
MonkeyBars
Human being with feelings
 
MonkeyBars's Avatar
 
Join Date: Feb 2016
Location: Hollyweird
Posts: 2,637
Default

Update: This bug is already fixed in the current prerelease, 6.42+1107! What a crazy coincidence
MonkeyBars is offline   Reply With Quote
Old 12-08-2021, 01:46 PM   #18
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

Nice.

Had the bugreport just finished XD
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine 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:23 PM.


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