HISE Logo Forum
    • Categories
    • Register
    • Login

    Load preset after init

    Scheduled Pinned Locked Moved General Questions
    12 Posts 4 Posters 374 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.
    • ustkU
      ustk
      last edited by ustk

      I have a specific case where I need to load a preset after init. (which in fact acts as an automatic preference recall with each session)

      I'm currently using a timer and it works great but I can't prevent myself to see it as a cheesy workaround since you see the controls recalling after a delay...

      Is there a callback of some sort that can trigger once init has done his job to load a preset in time?

      Well after all, using a preset for a pref file might not be the best solution around but I tried my own system in the past and it gave me headaches, while it's very easy to implement with a preset, especially now with a broadcaster

      Can't help pressing F5 in the forum...

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

        Is there a callback of some sort that can trigger once init has done his job to load a preset in time?

        Control callbacks triggers after on init.

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

        ustkU 1 Reply Last reply Reply Quote 1
        • ustkU
          ustk @d.healey
          last edited by ustk

          @d-healey Yeah I was thinking about using a hidden component with saveInPreset enabled so it can trigger its CB.
          I just hoped for a "made for this situation" solution :)

          I tried by just calling it in an inline function, but it appears the loading happens too soon and just don't load.
          Though I thought functions would trigger only once everything is initialised and ready, right?

          EDIT: a component CB would load the preset in loop anyway because you need the component to save in the same preset it is calling... Or maybe with a flag...

          Can't help pressing F5 in the forum...

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

            Why do you need to load a preset after on init?

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

            ustkU 2 Replies Last reply Reply Quote 0
            • ustkU
              ustk @d.healey
              last edited by

              @d-healey First post, twice today, 3 = brownies point 😛

              It's not an audio plugin but it has to act like a standard application. So I use the preset as a pref file that needs to be loaded next time automatically. (I have a setting to remember preferences or not, so it loads either the "last pref preset" or a factory one)

              Can't help pressing F5 in the forum...

              1 Reply Last reply Reply Quote 1
              • Matt_SFM
                Matt_SF @ustk
                last edited by Matt_SF

                @ustk a preset handler seems to work :

                const presetHandler = Engine.createUserPresetHandler();
                
                presetHandler.setPostCallback(function(presetFile)
                {
                	 Panel1.showControl(true);
                });
                
                Engine.loadUserPreset("YourPreset.preset");
                
                HiseSnippet 1200.3ocsV0saaaCElxIJs1aYsEXO.D9JE.OC61trgLTrD6XuYrjTiX2tALLDvHQaQDIRCRp3XTjaFF106AXuD6Ma2sKyNTTVxNwIK0.SWXKd9gmOdz24bXeovmpTBIxo7vYSnHmO0cvLtNrcHgwQ8ND47YtGSTZpDaE0Z1DhRQCPNNa7cFANk2Dk972eaKRDg6SKDgPuWv7oGwhY5Bo82+GXQQcIAzgr3Er9062yWvaKhDI.d1vsAZBw+BxX5IDiYkbQNa0IfoExAZhlpPNa1RDLaPnXJ2Z+6YJ14QTyhlnAvFYE2UDEXPrQJpcHKJn+7ysBA6R+hrvF1rvm6dLKfkKuHa77TE3BOVLe3TZY3swRvq48AuU.ImEfzlVH8B2A9R1DcgFCd9D2db3iyHBj1WDJVaQkNqjaaAXAWWOlbAsqDVj6g2tMZTCC+ry2ToBj5UZ7kDItOgSiZheCdtmio51h3IBNrvqpUcUvG6a0UvIzXpTD4MhDonEa2DIUQ0eOgGDALn2f6vGy3z59RJjgdmhJ6unAdFGWxk5vq8EJcaRTz4.YvaTB2WyDbOqYcYQzcp7gJkwq.KZYhAJWa10r.GIHAEg0q5Izo3l0s6k4DkejfvBex0mJRzfeEgcbZzFaLvRT8r+opOMjoMgCTFHISOHhMlSCFRuBByvPlBqnzXEVKvSExKv6sS0ZXMH2jcOR3ShZIR3AJuF6TCW0GxzRZP04ved7wB9IBM8sbuTbT45J3aqZznUpKKojlkWgZSkn7gbzimDeNUVCXHQIzbCA54xb9sdbbdeK0ZACE7dbl9sSnYqe3hVTF2Dd6c8NjnIlhlLYfcSnRMy.GmCoWBcfrkPkcOjptPKl.MSxIzPMjNql2VzzEHIvG8wCAtEhAH3YtKJpI5JjiqyeBQdl4kscxAiMJOy0xtZIESApF57wyaoUdKvo+wzpCnJwER+qa9iaVV5KyLN8I83U52J49gJXbUSJa.4RZqDsVvqtG1PyqMWSmqlP3J3Km5.ErUIwFKRKJyMIMwJWs6FFj5N6I7A1Z9RpJDCbNS8yd3lMxc5fffUGhSobnc9p0cHMhpuGccIWJjPFxLiXQcYHqGbpCnsDR3rszQ9jjXahv.9lohrq+QVfN7T36p.T7yfbLtQ8WcqmZejxAw+RZLNhozG.s4xyMYQn1p9K2KKxNULsOIH.HbOV+FPIR+vVDosIhwMqhiExr74s0Tvgtsl4Y56nsx0noljlg1+6.sOjxFGpMq10IsjLuj5I1RpsmOyxzUMsV5ot1Nrlhn4y8C1eVwhg6eOg3WAkWNuYhyFn6NgDlMKBRhH5kGXatkRlBntXoojlIg.uQOawaw7QLEuwCNE+wBwW31mo8CWMFKsBLB859+.iY28Ya2NiFQ80E.bS2t+z5dQm+ivaGvN9XhVxL8Ugp0AP+OeJDcNPTTlO8kLjK65Fl0lLv.JOHcwMvSlxll0NYJaNWIJl3KEm4amiYtc0SSk.XhmdwxxvMbg03lnzYafetMp2.ECWz6Leeyw+KfQPq1mWtF97p0vmWuF97kqgO6tF97UqgOe8C5i4N1GjnEw1xAPP+NoSAcb5vI.yJkEh9W.nixHQ
                

                Just give this snippet a correct preset name
                Edit : and hide the panel 😛

                Develop branch
                Win10 & VS17 / Ventura & Xcode 14. 3

                ustkU 2 Replies Last reply Reply Quote 2
                • ustkU
                  ustk @d.healey
                  last edited by

                  @d-healey Tried with a CB and a flag not to load in loop => crash

                  
                  // NOT WORKING
                  reg isPresetLoaded = false;
                  
                  inline function onButton1Control(component, value)
                  {
                  	if (!isPresetLoaded)
                  	{
                  		if (rememberSettings)
                  			Engine.loadUserPreset("user.preset");
                  		else
                  			Engine.loadUserPreset("factory.preset");
                  			
                  		isPresetLoaded = true;
                  	}
                  };
                  Content.getComponent("Button1").setControlCallback(onButton1Control);
                  
                  
                  

                  Can't help pressing F5 in the forum...

                  1 Reply Last reply Reply Quote 0
                  • ustkU
                    ustk @Matt_SF
                    last edited by

                    @Matt_SF Thanks! trying..

                    Can't help pressing F5 in the forum...

                    1 Reply Last reply Reply Quote 0
                    • ustkU
                      ustk @Matt_SF
                      last edited by ustk

                      @Matt_SF Nope in fact this can't help because it's the preset loading itself that causes me troubles, not the fact I want to do something after...

                      Ok so my test is showing that the preset loads during init, and then is replaced by the saved state of the interface.
                      In fact it's even creating a weird behaviour, blending both the preset and the current state...

                      Steps to reproduce:

                      • btn 1 ON
                      • save XML
                      • btn1 OFF, btn 2 ON
                      • save preset
                      • Close/restart Hise and load XML

                      => Strange result, the preset shows first with no current preset, then the XML state shows with the current preset
                      It's inverted. (the inversion of the current preset name doesn't shock me though, because it's normal it's not done loading...

                      Interface: LOADING PRESET
                      Interface: BTN 1 => 0.0             // In fact the preset
                      Interface: BTN 2 => 1.0 
                      Interface: BTN 1 => 1.0 New Preset  // In fact the saved state
                      Interface: BTN 2 => 0.0 New Preset
                      

                      Weirder, after it's done, both buttons are ON on the interface...

                      HiseSnippet 1182.3ocsW01aaaCDlxIrX1qacEX66B9SNXYF1JoI8ErM+dgwRbLhS6ZQwPGiDsMQjHMnnhqQQ919Ise.8mz9GrcTT1R1wIHwXgeHx7dg2yc7tiW5KEtzvPgDYk+rYSnHqGiGLiqF2bLgwQcagr9A7QBhWeIMjppOTQkc4LEpwrIjvPpGxxZqWqE0J+1n30+7qMH9DtKMkDB8VAykdDK.zbA0909MlueGhG8LVPFo2uVWWAuovWDAvZKbEzDh6EjQzdDsX4vHqG01ioDxAJhhFhr1tgva1fwhobi7ukExN2mp2TEM.NHC4NBeOMh0TQMGy7AuJw8CQvozOMXrkIX783iYdrEzSCJeWLC6TMxFOrxsL71ZI3UMK7pjAdqARVYfz1FH8T7.WIahJkiFOeMtKGtZFRfvdVnXjEk6uygaJ.I3pxAjKncjvlE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4fMPmC2.cd9spi9+SodjRDXJG.B8aG+xqkUaNAxrhyBQ+GvLm58g
                      

                      I know this has a logical explanation and is the reason behind the necessity of exporting projects with default preset loaded already. Still, having a CB that triggers once everything is ready would be very useful in some situations

                      Can't help pressing F5 in the forum...

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

                        @ustk Do your preferences have to be stored in a preset? Why not use a json file and load that in a post init control callback?

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

                        lalalandsynthL ustkU 2 Replies Last reply Reply Quote 0
                        • lalalandsynthL
                          lalalandsynth @d.healey
                          last edited by

                          @d-healey following

                          https://lalalandaudio.com/

                          https://lalalandsynth.com/

                          https://www.facebook.com/lalalandsynth

                          https://www.facebook.com/lalalandsynth

                          1 Reply Last reply Reply Quote 0
                          • ustkU
                            ustk @d.healey
                            last edited by

                            @d-healey I tried a json and it was usable but a pain to get it to work smoothly… the preset thing is absolutely easy especially when using a broadcaster. I might have do give another go with my own pref file

                            Can't help pressing F5 in the forum...

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

                            12

                            Online

                            1.7k

                            Users

                            11.8k

                            Topics

                            102.7k

                            Posts