Forum
    • Categories
    • Register
    • Login

    How to retrieve settings from ScriptFX in onInit when the plugin starts?

    Scheduled Pinned Locked Moved Scripting
    3 Posts 2 Posters 12 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.
    • J
      jojojojonas
      last edited by

      Hi everyone,

      I've built an FX plugin with a “realtime” and a “long latency” option (Lookahead off/on), which means I can switch between them with a button, and depending on the setting, a different latency is sent to the DAW via Engine.setLatencySamples. That works fine. The default setting is “realtime”.

      Now, if I change a few plugin parameters in the DAW and activate the “latency” mode, save the project, close it, and then reopen it, all plugin parameters load correctly (including the status of the latency button), BUT I can’t access the correct status of the button in the 'onInit' script to send the correct latency to the DAW when loading. This means the plugin always sends the “realtime” latency first, even though “long latency” mode is actually enabled. I’ve already tried using a timer to delay the query, but that doesn’t work either (though the query for the current sample rate does work there):

      const var to = Engine.createTimerObject();
      var timerStop = 0;
      
      to.setTimerCallback(function()
      {
      	if (!timerStop) {
      		getSamplerate(); //Samlplerate request function works
      		if(ScriptFX.getAttribute(ScriptFX.Lookahead)>0) { // THIS DOESNT WORK, but why?
      			Engine.setLatencySamples(lookaheadSmpl);
      		}
      		timerStop = timerStop+1;
      	} else {
      		to.stopTimer();
      	}
      });
      
      to.startTimer(400);
      

      Has anyone an idea? :)

      David HealeyD 1 Reply Last reply Reply Quote 0
      • David HealeyD
        David Healey @jojojojonas
        last edited by David Healey

        @jojojojonas If the controls are set to save in preset then anything you do in on init will be overwriten when the control callback triggers.

        Use the technique described here (in the snippet) for responding to a DAW session load.

        https://docs.hise.dev/tutorials/all/index.html#dynamic-plugin-parameters

        Free HISE Bootcamp Full Course for beginners.
        YouTube Channel - Public HISE tutorials
        My Patreon - HISE tutorials

        J 1 Reply Last reply Reply Quote 0
        • J
          jojojojonas @David Healey
          last edited by

          @David-Healey Ah very nice, thank you! I will give that a try!

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

          19

          Online

          2.3k

          Users

          13.7k

          Topics

          118.9k

          Posts