Undo/Redo with Randomization?
-
Hey Gang,
I've got a randomization button for sequencers (6) and sample selection (6).
It seems the plugin does not recognize that the Steps, Velocity, Stride and Time have been changed if I used the random button as it does not recall anything when undo it pressed. However, if I also set the UndoManager to ENABLE on the Random Button, then when I click undo, it randomizes the sequencer again rather than recall the parameters. Changing the Steps, Velocity, etc manually on the UI works as it should with undo/redo.
Using the random button with the Sample Selection poses the same issue. It does not recognize that the sample has been changed unless I have the Random Sample button UndoManager enabled. Again, when you click undo, instead of showing you the previous step it randomizes the sample again. This is loading Sample Maps via a view port into the sampler.
I have the correct "metaparameter" settings.
Where am I going wrong with the undo/redo action?
-
@trillbilly There is support in the API for managing the undo/redo buffer, yourself (including on a per-component basis). Take a look and see if that solves it.
-
@clevername27 I was attempting to see if
performUndoAction
was it but I couldn't figure it out from the article in the documentation. I'll also check outsetValueWithUndo
, thanks for pointing that out.I'll just be in trial and error mode until I get somewhere. God help me...
Best and thanks again.
-
@clevername27 So I've tried this in the Callback of the Randomize Button. I've also tried placing it in the Callback of the Undo Button.
Engine.performUndoAction({ "obj": Stepsknb1, // the object that will be modified "newValue": [Math.randInt(0, 16)], // the new state "oldValue": Stepsknb1.clone() // the old state (we need to clone it or it will not keep the old values) }, function(isUndo) { this.obj.clear(); // pick the values from the old or new state for(v in isUndo ? this.oldValue : this.newValue) this.obj.push(v); }); // new state Console.print(trace(myList)); Engine.undo(); // old state Console.print(trace(myList)); Engine.redo(); // new state Console.print(trace(myList));
It recalls the number of times the Randomize Button was pressed, but does not recall the correct settings for the Steps knob. Instead, it just randomizes the number again.
Do you know where I'm going wrong?
-
@trillbilly I don't, I'm sorry.
-
@clevername27 no biggie, thanks for getting me going. I do think this is it, just not sure how to get there. I'll keep chugging away.
-
Just giving a bump. Any help is appreciated.