HISE Logo Forum
    • Categories
    • Register
    • Login

    New callback: onLoaded

    Scheduled Pinned Locked Moved Feature Requests
    13 Posts 3 Posters 1.1k 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.
    • d.healeyD
      d.healey @Lindon
      last edited by d.healey

      @Lindon add a panel, call it postInit or some other suitable name. Use it's callback function for all your postInit needs, don't use the generic onConrol callback for it.

      Libre Wave - Freedom respecting instruments and effects
      My Patreon - HISE tutorials
      YouTube Channel - Public HISE tutorials

      LindonL 1 Reply Last reply Reply Quote 0
      • LindonL
        Lindon @d.healey
        last edited by Lindon

        @d-healey Dave that sounds ideal - so if I say;

        inline function onPostInitControl(component, value)
        {
        	//this executes AFTER eveyone is loaded...
        };
        
        Content.getComponent("PostInit").setControlCallback(onPostInitControl);
        

        I cna put all my post -init logic in here? and every widget will have its initalised value?

        How do I fire this function?

        or maybe its setLoadingCallback ?

        But in any case...I'm very very confused.

        I want my plugin to recall the values I entered in it - and its not doing that....

        I start my plug in and it shows me 4 labels, holding these values:

        11111,22222,33333,44444

        I over type these with 99,88,77,66

        and close my plugin.

        I delete the plugin from my DAW, I reload it and the numbers are back at:

        11111,22222,33333,44444

        SO my plugin is NOT saving its internal state....

        HISE Development for hire.
        www.channelrobot.com

        d.healeyD 1 Reply Last reply Reply Quote 0
        • d.healeyD
          d.healey @Lindon
          last edited by d.healey

          I cna put all my post -init logic in here? and every widget will have its initalised value?

          Yes

          How do I fire this function?

          It's just a callback function like any other so will fire automatically after on init completes as long as its saveInPreset property is true.

          SO my plugin is NOT saving its internal state.

          You have to save the default preset in order for it to load with a different initial state. This is the same with Kontakt's widgets too (except Kontakt instruments only have 1 preset), you always get the last saved state when adding a new instance of the plugin.

          Libre Wave - Freedom respecting instruments and effects
          My Patreon - HISE tutorials
          YouTube Channel - Public HISE tutorials

          LindonL 1 Reply Last reply Reply Quote 0
          • LindonL
            Lindon @d.healey
            last edited by

            @d-healey OK great.....

            "You have to save the default preset in order for it to load with a different initial state. This is the same with Kontakt's widgets too (except Kontakt instruments only have 1 preset), you always get the last saved state when adding a new instance of the plugin."

            BUT:

            I've tried to do this and it doesnt do it, I overwrite the labels wiht 99,88,77,66 and press a button - and in the buttons callback I say this;

            Engine.saveUserPreset("Factory/Xylophone/Init");

            -- I am assuming here that I am saving the preset? is this not right? Beacuase when I delete my plugin from the DAW and reload it the numbers are back at 1111,2222,3333,444

            When you say "You have to save the default preset " can you show me how you would do that in a script?

            HISE Development for hire.
            www.channelrobot.com

            d.healeyD 1 Reply Last reply Reply Quote 0
            • d.healeyD
              d.healey @Lindon
              last edited by

              @Lindon The savePreset function doesn't work - it has been mentioned a few times to @Christoph-Hart - currently it only works via the preset browser. However you can still use the storeAllControlsAsPreset function.

              Libre Wave - Freedom respecting instruments and effects
              My Patreon - HISE tutorials
              YouTube Channel - Public HISE tutorials

              LindonL 1 Reply Last reply Reply Quote 0
              • LindonL
                Lindon @d.healey
                last edited by Lindon

                @d-healey Great!

                Whats the actual format of this call? (whats all this Automation stuff?)

                Is it:

                Content.storeAllControlsAsPreset("default",""); <-- well its not this cause I just tried and no change

                or perhaps:

                Content.storeAllControlsAsPreset("Factory/Xylophone/Init","");

                or something I've missed off - the in-line documentation is not at all clear(as usual)

                HISE Development for hire.
                www.channelrobot.com

                1 Reply Last reply Reply Quote 0
                • d.healeyD
                  d.healey
                  last edited by

                  Content.storeAllControlsAsPreset("A", false)

                  Content.restoreAllControlsFromPreset("A")

                  This is what I used in my A/B comparison attempt.

                  Libre Wave - Freedom respecting instruments and effects
                  My Patreon - HISE tutorials
                  YouTube Channel - Public HISE tutorials

                  LindonL 1 Reply Last reply Reply Quote 0
                  • LindonL
                    Lindon @d.healey
                    last edited by

                    @d-healey Okaaaay...

                    these look like asynchronous calls? Are they? and if so how do i know when they are complete?

                    HISE Development for hire.
                    www.channelrobot.com

                    d.healeyD 1 Reply Last reply Reply Quote 0
                    • d.healeyD
                      d.healey @Lindon
                      last edited by d.healey

                      @Lindon As far as I can tell they work the same was as the regular save/load presets (I think these functions exist for creating custom preset browsers). So once the load is completed the onControl callbacks are triggered.

                      Libre Wave - Freedom respecting instruments and effects
                      My Patreon - HISE tutorials
                      YouTube Channel - Public HISE tutorials

                      1 Reply Last reply Reply Quote 0
                      • Christoph HartC
                        Christoph Hart
                        last edited by

                        A simple solution is this:

                        
                        inline function onLoaded()
                        {
                            // Whatever you do here, it is guaranteed that every control
                            // is initialised correctly.
                            Console.print("onLoaded");
                        }
                        
                        
                        // Grab a reference to the panel
                        const var onLoadedPanel = Content.getComponent("onLoadedPanel");
                        
                        // Makes it fire its control callback at user preset loading et al.
                        onLoadedPanel.set("saveInPreset", true);
                        
                        // Nothing to see, move on...
                        onLoadedPanel.set("visible", false);
                        
                        
                        inline function ononLoadedPanelControl(component, value)
                        {
                            // If this control is not the last one in the list,
                            // make sure to leave enough room by deferring the execution.
                            component.startTimer(500);
                        };
                        
                        onLoadedPanel.setControlCallback(ononLoadedPanelControl);
                        
                        // We use the inbuilt timer functionality for asynchronous execution
                        onLoadedPanel.setTimerCallback(function()
                        {
                            onLoaded();
                            this.stopTimer();
                        });
                        

                        But again, all your problems are coming from hacking the user preset system for your authorisation method, which will have all kinds of weird side effects (eg. if people share your user presets, they bake their authorisation code into the user preset etc). The only proper solution is to use the upcoming and infamous Engine.saveAppDataFile(jsonObject, "MyFile.js") and Engine.loadAppDataFile("MyFile.js"), which I am going to implement now so that you don't have to fish in the dark any longer :)

                        1 Reply Last reply Reply Quote 4
                        • LindonL
                          Lindon
                          last edited by

                          please please please make at least the loadAppDataFile return a success/failure code....

                          HISE Development for hire.
                          www.channelrobot.com

                          1 Reply Last reply Reply Quote 0
                          • Christoph HartC
                            Christoph Hart
                            last edited by

                            Your wishes have been heard:

                            Link Preview Image
                            - make `Engine.loadFromJSON()` return undefined instead of throwing a… · christophhart/HISE@4c8930b

                            The open source framework for sample based instruments - - make `Engine.loadFromJSON()` return undefined instead of throwing a… · christophhart/HISE@4c8930b

                            favicon

                            GitHub (github.com)

                            BTW, I am working on a full example of implementing a copy protection scheme like you described. I'll put it into the tutorial repo in a few minutes.

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

                            43

                            Online

                            1.7k

                            Users

                            11.7k

                            Topics

                            102.0k

                            Posts