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

Reply
 
Thread Tools Display Modes
Old 09-17-2013, 10:36 AM   #41
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,891
Default

Quote:
Originally Posted by spk77 View Post
Tested with v4.401 and v.4.53pre4 - undo point is added in v4.401, but not in v.4.53pre4. There have been undo-related updates lately.
I'm on 4.52. I guess something got broken?
IXix is offline   Reply With Quote
Old 09-17-2013, 10:45 AM   #42
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by IXix View Post
I'm on 4.52. I guess something got broken?
I think something happened around v4.5:

from v4.5 changelog :
Code:
Undo: extensive optimizations and improvements
Undo: avoid excessive state loading when undoing changes to track order/counts
Undo: better reuse of undo buffers when changing track order/counts
Undo: improved memory use, scan for common blocks in history when adding states
Undo: incrementally updated RPP-UNDO files, can make for much faster save of undo history
spk77 is offline   Reply With Quote
Old 09-17-2013, 10:57 AM   #43
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,891
Default

Quote:
Originally Posted by spk77 View Post
I think something happened around v4.5
Is normal ReaScript undo (ie. not "with undoable") working for you? I'm never sure if I'm just doing something wrong.
IXix is offline   Reply With Quote
Old 09-17-2013, 12:15 PM   #44
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by IXix View Post
Is normal ReaScript undo (ie. not "with undoable") working for you? I'm never sure if I'm just doing something wrong.
No, it seems to be broken, at least when changing FX parameter values from a script. (Changing manually adds an undo point):



Code:
from reaper_python import *
import random

RPR_Undo_BeginBlock2(0)
firstTrack = RPR_GetTrack(0, 0)
value = random.uniform(0, 0.5)
RPR_TrackFX_SetParam(firstTrack, 0, 0, value)
##RPR_Undo_OnStateChange2(0, "undo name")
RPR_Undo_EndBlock2(0, "undo point name", -1)

I don't know - I always use "-1" for RPR_Undo_EndBlock2(). Sometimes I have to add "RPR_Undo_OnStateChange2(0, "undo name")" to get rid of the extra "ReaScript: run" -point.

Last edited by spk77; 09-17-2013 at 12:24 PM.
spk77 is offline   Reply With Quote
Old 09-17-2013, 12:43 PM   #45
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Almost working in 4.401 - except the random "ReaScript: run" -points:

spk77 is offline   Reply With Quote
Old 09-19-2013, 12:11 PM   #46
Jeffos
Mortal
 
Jeffos's Avatar
 
Join Date: Dec 2008
Location: France
Posts: 1,969
Default

API vs Undo system: I can confirm something went wrong around v4.5, and not only for ReaScript. ATM, most of undo points set by the SWS extension are broken for ex (!)
v4.51, Win XP - everything OK with the same reaper_sws.dll in REAPER v4.402. it's a bit like states are "remembered" but no no undo point is actually set (so you need to make a sel change or something to get it after you run the said actions, etc.)
Repro example: "cut take" & "paste take" S&M actions.
EDIT: let's make a BR!

Quote:
Originally Posted by spk77 View Post
except the random "ReaScript: run" -points:
that's where I left the thread...
I don't understand that either, it should be up to the reascripter to create (or not) an undo point, no? it works like that is C, fortunately!

Last edited by Jeffos; 09-19-2013 at 12:17 PM.
Jeffos is offline   Reply With Quote
Old 09-19-2013, 12:15 PM   #47
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,891
Default

Quote:
Originally Posted by Jeffos View Post
ATM, most of undo points set by the SWS extension are broken for ex (!)
Ouch! I assume you'll be raising the matter with the devs then?
IXix is offline   Reply With Quote
Old 09-19-2013, 02:02 PM   #48
Jeffos
Mortal
 
Jeffos's Avatar
 
Join Date: Dec 2008
Location: France
Posts: 1,969
Default

=> BR: http://forum.cockos.com/project.php?issueid=4934
Quote:
Originally Posted by IXix View Post
Ouch! I assume you'll be raising the matter with the devs then?
Yes, hot, will do (although I'm not sure Justin or Schwa read my mails anymore lateky, and have no actual prOof Christophe reads/writes or even understands French )
Jeffos is offline   Reply With Quote
Old 04-12-2014, 04:33 PM   #49
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

So was it fixed?
Jeffos, as you're now a part of main developement could you pleease look at this?

Thanks!
Viente is offline   Reply With Quote
Old 04-12-2014, 06:47 PM   #50
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 2,583
Default

Quote:
Originally Posted by Jeffos View Post
=> BR: http://forum.cockos.com/project.php?issueid=4934
Yes, hot, will do (although I'm not sure Justin or Schwa read my mails anymore lateky, and have no actual prOof Christophe reads/writes or even understands French )
This is the one and only thing that annoys me about Cockos: there is no 'priority channel' for trusted developers, experienced beta testers or professional users to communicate with Justin/John/Christophe.
__________________
Puzzle Factory Sound Studios, London [Website] [Instagram]
[AMD 5800X, 32Gb RAM, Win10x64, NVidia GTX1080ti, UAD2-OCTO, FireFaceUCX, REAPER x64]
[Feature request: More details in Undo History]
daxliniere is offline   Reply With Quote
Old 04-16-2014, 06:17 AM   #51
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

I'm still getting 2 undo points...
Is there a reliable known way to consolidate all undo points?
Viente is offline   Reply With Quote
Old 04-16-2014, 06:23 AM   #52
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 2,583
Default

There was for Python.
__________________
Puzzle Factory Sound Studios, London [Website] [Instagram]
[AMD 5800X, 32Gb RAM, Win10x64, NVidia GTX1080ti, UAD2-OCTO, FireFaceUCX, REAPER x64]
[Feature request: More details in Undo History]
daxliniere is offline   Reply With Quote
Old 04-16-2014, 06:25 AM   #53
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

Quote:
Originally Posted by daxliniere View Post
There was for Python.
Which one? Could you share please? So far nothing works for me...
Viente is offline   Reply With Quote
Old 04-16-2014, 06:30 AM   #54
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 2,583
Default

I can't remember who wrote this one (Tim, Breeder or spk77 I think), but it's not the standard one that you see all the time.

Here's an example from my split tool:


Code:
from reaper_python import *
from contextlib import contextmanager

@contextmanager
def undoable(message):
    RPR_Undo_BeginBlock2(0)
    try:
        yield
    finally:
        RPR_Undo_EndBlock2(0,message,-1)


with undoable('Split item(s)'):
    SelectItemUnderCursor = 40528
    DeselectItems = 40289
    MoveCursor = 40513
    SplitItems = RPR_NamedCommandLookup('_SWS_AWSPLITXFADELEFT')
    SelectPreviousItem = RPR_NamedCommandLookup('_SWS_SELPREVITEM2')
    CrossfadeToTimeSel = 40916


    selItems = RPR_CountSelectedMediaItems(0)
    timeSel = RPR_GetSet_LoopTimeRange2(0, 0, 0, 0, 0, 0)[3] != RPR_GetSet_LoopTimeRange2(0, 0, 0, 0, 0, 0)[4]

    RPR_Main_OnCommand(MoveCursor, 0)

    if (selItems==0):
      RPR_Main_OnCommand(SelectItemUnderCursor, 0)
      RPR_Main_OnCommand(SplitItems, 0)
      if (timeSel!=0):
        RPR_Main_OnCommand(SelectPreviousItem, 0)
        RPR_Main_OnCommand(CrossfadeToTimeSel, 0)
      RPR_Main_OnCommand(DeselectItems, 0)

    if (selItems!=0):
      RPR_Main_OnCommand(SplitItems, 0)
      if (timeSel!=0):
        RPR_Main_OnCommand(SelectPreviousItem, 0)
        RPR_Main_OnCommand(CrossfadeToTimeSel, 0)
As you can see, you just insert your py code as you would in any script, but indented.


For the less experienced users reading this, just insert your standard script under with undoable('Split item(s)'): and be sure to indent your whole script one level.
__________________
Puzzle Factory Sound Studios, London [Website] [Instagram]
[AMD 5800X, 32Gb RAM, Win10x64, NVidia GTX1080ti, UAD2-OCTO, FireFaceUCX, REAPER x64]
[Feature request: More details in Undo History]
daxliniere is offline   Reply With Quote
Old 04-16-2014, 06:36 AM   #55
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

Thanks but it doesn't work

Still 2 undo points...
Viente is offline   Reply With Quote
Old 04-16-2014, 06:38 AM   #56
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 2,583
Default

Really?? Weird.. I could swear it did. Maybe something's been broken again, the undo system for scripts has always been pretty unreliable.

I wish we could get a straight answer from Justin about exactly how to use it.
__________________
Puzzle Factory Sound Studios, London [Website] [Instagram]
[AMD 5800X, 32Gb RAM, Win10x64, NVidia GTX1080ti, UAD2-OCTO, FireFaceUCX, REAPER x64]
[Feature request: More details in Undo History]
daxliniere is offline   Reply With Quote
Old 04-16-2014, 06:40 AM   #57
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

Quote:
Originally Posted by daxliniere View Post
Really?? Weird.. I could swear it did. Maybe something's been broken again, the undo system for scripts has always been pretty unreliable.

I wish we could get a straight answer from Justin about exactly how to use it.
Yes, unfortunately. I'm on Windows 8.1 64bit, Python 3.4.0

Please somebody give us a hand! Undo is absolutely critical workflow process...
Viente is offline   Reply With Quote
Old 04-16-2014, 06:43 AM   #58
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 2,583
Default

Quote:
Originally Posted by Viente View Post
Undo is absolutely critical workflow process...
Only if you make mistakes all the time/as part of your workflow. :P

Just kidding, I'm totally with you on this.
__________________
Puzzle Factory Sound Studios, London [Website] [Instagram]
[AMD 5800X, 32Gb RAM, Win10x64, NVidia GTX1080ti, UAD2-OCTO, FireFaceUCX, REAPER x64]
[Feature request: More details in Undo History]
daxliniere is offline   Reply With Quote
Old 04-16-2014, 06:44 AM   #59
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

Quote:
Originally Posted by daxliniere View Post
Only if you make mistakes all the time/as part of your workflow. :P

Just kidding, I'm totally with you on this.
Undo is not only for fixing mistakes Trying different things and experiment, then go back if needed is essential

You know this
Viente is offline   Reply With Quote
Old 04-16-2014, 06:50 AM   #60
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Posts: 2,436
Default

Quote:
Originally Posted by daxliniere View Post
I can't remember who wrote this one (Tim, Breeder or spk77 I think), but it's not the standard one that you see all the time.

That would be Tim and spk77

Viente, are you seeing things like
Code:
- Undo point name created by script
- ReaScript: Run
I can confirm that. It seems Reaper will always create an additional undo point when running ReaScript :/
Breeder is offline   Reply With Quote
Old 04-16-2014, 06:52 AM   #61
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

Yes...this is sad
Viente is offline   Reply With Quote
Old 04-16-2014, 06:55 AM   #62
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

THe only solution so far is to put script inside custom action...which add clutter
Viente is offline   Reply With Quote
Old 09-03-2014, 12:02 AM   #63
miche
Human being with feelings
 
miche's Avatar
 
Join Date: Jan 2009
Posts: 559
Default

Quote:
Originally Posted by Viente View Post
THe only solution so far is to put script inside custom action...which add clutter
Shameless threaddigger!

I have just tested this workaround and it INSANELY speeds up my reascripts (especially when the project contains loads and loads of grouped items). It's good to have this workaround.

You have just saved me a few hours a month, Viente!
miche is offline   Reply With Quote
Old 09-03-2014, 03:22 AM   #64
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Posts: 2,436
Default

Guys, I think this is fixed in latest version
Breeder is offline   Reply With Quote
Old 12-27-2014, 06:35 AM   #65
Jeffos
Mortal
 
Jeffos's Avatar
 
Join Date: Dec 2008
Location: France
Posts: 1,969
Default

^ yes, the double undo point bug has been fixed some versions ago.

Now, just an update about the other "issue": the famous "ReaScript: Run" undo point (automatically created unless you create your own one), which would also mean that scripts can't turn off undo... In fact, they can! but it is not documented ATM (will do). So, if you don't want any undo point to be created the recommended way is to defer things. I mean like (EEL):
Code:
  ShowConsoleMsg("Yo");
^ this will create a dummy undo point "ReaScript: Run" (*)

Code:
function run() 
(
  ShowConsoleMsg("Yo");
);
defer("run();");
^ this script won't create any undo point.

___

(*) I can confirm things are marked as dirty and an undo point is automatically created (UNDO_STATE_ALL).
We know this is both a convenience (no need to deal with undo within scripts, safer vs bad scripts, etc), or just like my example above, an inconvenience (wtf-undo-point that undoes nothing, uselessly mark projects as dirty, slight performance penalty for good scripts, etc) but since many scripts rely on this behavior now, we'll have to stick with it (not to break them).

Anyway, you have the choice now
Jeffos is offline   Reply With Quote
Old 12-27-2014, 06:55 AM   #66
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 2,583
Default

Thanks a bunch, Jeffos.
__________________
Puzzle Factory Sound Studios, London [Website] [Instagram]
[AMD 5800X, 32Gb RAM, Win10x64, NVidia GTX1080ti, UAD2-OCTO, FireFaceUCX, REAPER x64]
[Feature request: More details in Undo History]
daxliniere is offline   Reply With Quote
Old 05-20-2015, 01:34 AM   #67
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Posts: 2,436
Default

Quote:
Originally Posted by Jeffos View Post
^ yes, the double undo point bug has been fixed some versions ago.

Now, just an update about the other "issue": the famous "ReaScript: Run" undo point (automatically created unless you create your own one), which would also mean that scripts can't turn off undo... In fact, they can! but it is not documented ATM (will do). So, if you don't want any undo point to be created the recommended way is to defer things. I mean like (EEL):
Code:
  ShowConsoleMsg("Yo");
^ this will create a dummy undo point "ReaScript: Run" (*)

Code:
function run() 
(
  ShowConsoleMsg("Yo");
);
defer("run();");
^ this script won't create any undo point.

___

(*) I can confirm things are marked as dirty and an undo point is automatically created (UNDO_STATE_ALL).
We know this is both a convenience (no need to deal with undo within scripts, safer vs bad scripts, etc), or just like my example above, an inconvenience (wtf-undo-point that undoes nothing, uselessly mark projects as dirty, slight performance penalty for good scripts, etc) but since many scripts rely on this behavior now, we'll have to stick with it (not to break them).

Anyway, you have the choice now
Jeffos, there's just one small corner case concerning this. If you use scripts that defer things from cycle action or macros, the order of execution gets messed up (because when the script is called, the real "meat" of it gets deferred to next timer call)
My guess is, we should simply call things immediately when script is executed, and then defer some kind of empty function instead to overcome this. Haven't tested it though, but I guess it should work.

edit: yep, it works.

I do it like this (Main() being the function that executes whatever the script is doing):

EEL:
Code:
Main();
function NoUndoPoint ()(abs(0)); // Makes sure there is no necessary undo point created, see more
defer("NoUndoPoint()");          // here: http://forum.cockos.com/showpost.php?p=1523953&postcount=67
Lua:
Code:
Main()
function NoUndoPoint () end -- Makes sure there is no necessary undo point created, see more
reaper.defer(NoUndoPoint)   -- here: http://forum.cockos.com/showpost.php?p=1523953&postcount=67
Python:
Code:
Main()
def NoUndoPoint (): pass   # Makes sure there is no necessary undo point created, see more
RPR_defer("NoUndoPoint()") # here: http://forum.cockos.com/showpost.php?p=1523953&postcount=67

Last edited by Breeder; 05-20-2015 at 02:31 AM.
Breeder is offline   Reply With Quote
Old 05-22-2015, 12:07 PM   #68
Samelot
Human being with feelings
 
Join Date: Oct 2013
Posts: 77
Default

Does this mean we can now make scripts that don't create any undo points?


Quote:
Originally Posted by Breeder View Post
Jeffos, there's just one small corner case concerning this. If you use scripts that defer things from cycle action or macros, the order of execution gets messed up (because when the script is called, the real "meat" of it gets deferred to next timer call)
My guess is, we should simply call things immediately when script is executed, and then defer some kind of empty function instead to overcome this. Haven't tested it though, but I guess it should work.

edit: yep, it works.

I do it like this (Main() being the function that executes whatever the script is doing):

EEL:
Code:
Main();
function NoUndoPoint ()(abs(0)); // Makes sure there is no necessary undo point created, see more
defer("NoUndoPoint()");          // here: http://forum.cockos.com/showpost.php?p=1523953&postcount=67
Lua:
Code:
Main()
function NoUndoPoint () end -- Makes sure there is no necessary undo point created, see more
reaper.defer(NoUndoPoint)   -- here: http://forum.cockos.com/showpost.php?p=1523953&postcount=67
Python:
Code:
Main()
def NoUndoPoint (): pass   # Makes sure there is no necessary undo point created, see more
RPR_defer("NoUndoPoint()") # here: http://forum.cockos.com/showpost.php?p=1523953&postcount=67
Samelot is offline   Reply With Quote
Old 04-07-2016, 12:30 PM   #69
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 7,268
Default

is there a way to erase latest undo block from undo history?

for example let's say I do something like this:
Code:
reaper.Undo_BeginBlock()
reaper.TrackFX_SetPreset() -- creates Change FX preset undo point that I don't need.
reaper.Undo_EndBlock("my undo block", -1)
then I want to erase "my undo block" from undo history without doing Undo. I really need it to not flood the undo history with unnecessary undo points.
heda 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 09:48 AM.


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