View Single Post
Old 02-03-2019, 10:38 AM   #27
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 10,263
Default

Quote:
Originally Posted by heda View Post
Hi Justin and schwa, I'll see if I can do more testing on a clean new project and send it to you. This project has three Melodyne instances (not my project) But I have just seen that if I remove the Melodyne plugins, then Undo_EndBlock() is fast again. I also have seen that with more Melodyne instances, the time increases, by 1 second aprox for each molodyne instance.
It is good that if no Melodyne is used, then this doesn't affect users that doesn't have Melodyne.
I'm not sure if this is fully documented (if not we'll add it), but the flag passed to Undo_EndBlock() controls how much of the project needs to be serialized for the undo point. -1 means "everything changed," so everything gets serialized, every track, media item, fx, the timeline, routing, and ARA state. As you've seen, serializing the ARA state may take a while -- this is completely out of REAPER's control, all we can do is ask the plugin for its state.

If you know that your script can only have affected certain parts of the project, you can pass that information as the flag argument to Undo_EndBlock which will make it much more efficient.

UNDO_STATE_ALL -1
UNDO_STATE_TRACKCFG 1 // track/master vol/pan/routing, routing/hwout envelopes too
UNDO_STATE_FX 2 // track/master fx
UNDO_STATE_ITEMS 4 // track items
UNDO_STATE_MISCCFG 8 // loop selection, markers, regions, extensions
UNDO_STATE_FREEZE 16 // freeze state
UNDO_STATE_TRACKENV 32 // non-FX envelopes only
UNDO_STATE_FXENV 64 // FX envelopes, implied by UNDO_STATE_FX too
UNDO_STATE_POOLEDENVS 128 // contents of automation items -- not position, length, rate etc of automation items, which is part of envelope state
UNDO_STATE_FX_ARA 256 // ARA state

So if your script may have affected tracks and media items only but not FX, you could pass flag=5 (1+4) for example. If your script may have affected everything but freeze state, automation items and ARA state, you could pass flag=111 (1+2+4+8+32+64), etc.
schwa is offline   Reply With Quote