HISE Logo Forum
    • Categories
    • Register
    • Login

    Undo/Redo with Randomization?

    Scheduled Pinned Locked Moved Scripting
    undoredosamplermetaparameter
    7 Posts 2 Posters 533 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • trillbillyT
      trillbilly
      last edited by

      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?

      clevername27C 1 Reply Last reply Reply Quote 1
      • clevername27C
        clevername27 @trillbilly
        last edited by

        @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.

        trillbillyT 2 Replies Last reply Reply Quote 0
        • trillbillyT
          trillbilly @clevername27
          last edited by

          @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 out setValueWithUndo, 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.

          1 Reply Last reply Reply Quote 0
          • trillbillyT
            trillbilly @clevername27
            last edited by

            @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?

            clevername27C 1 Reply Last reply Reply Quote 1
            • clevername27C
              clevername27 @trillbilly
              last edited by

              @trillbilly I don't, I'm sorry.

              trillbillyT 1 Reply Last reply Reply Quote 0
              • trillbillyT
                trillbilly @clevername27
                last edited by

                @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.

                1 Reply Last reply Reply Quote 0
                • trillbillyT
                  trillbilly
                  last edited by

                  Just giving a bump. Any help is appreciated.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post

                  50

                  Online

                  1.7k

                  Users

                  11.7k

                  Topics

                  102.1k

                  Posts