HISE Logo Forum
    • Categories
    • Register
    • Login

    Timer callback in multiple scripts

    Scheduled Pinned Locked Moved Scripting
    4 Posts 2 Posters 1.3k 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
      last edited by

      Is it intentional that starting the timer in one script also starts the timer in another script?

      
      <Processor Type="SynthChain" ID="Master Chain" Bypassed="0" Gain="1" Balance="0"
                 VoiceLimit="128" KillFadeTime="20" IconColour="0" packageName=""
                 views="32.rk1bzA...3CC.........HC.FIqL....5xXQ9TEXOvK" currentView="-1">
        <EditorStates BodyShown="0" Visible="1" Solo="0"/>
        <ChildProcessors>
          <Processor Type="MidiProcessorChain" ID="Midi Processor" Bypassed="0">
            <EditorStates BodyShown="1" Visible="1" Solo="0" Folded="0"/>
            <ChildProcessors>
              <Processor Type="ScriptProcessor" ID="Script Processor" Bypassed="0" Script="function onNoteOn()&#10;{&#10;&#9;Synth.startTimer(0.5);&#13;&#10;&#9;&#13;&#10;&#9;if (Message.getNoteNumber() == 60)&#13;&#10;&#9;{&#13;&#10;&#9;&#9;Synth.stopTimer();&#10;&#9;}&#10;}&#10;function onNoteOff()&#10;{&#10;&#9;&#10;}&#10;function onController()&#10;{&#10;&#9;&#10;}&#10;function onTimer()&#10;{&#10;&#9;Console.print(&quot;1&quot;);&#10;}&#10;function onControl(number, value)&#10;{&#10;&#9;&#10;}&#10;">
                <EditorStates BodyShown="1" Visible="1" Solo="0" contentShown="1" onInitOpen="0"
                              onNoteOnOpen="1" onNoteOffOpen="0" onControllerOpen="0" onTimerOpen="0"
                              onControlOpen="0"/>
                <ChildProcessors/>
                <Content/>
              </Processor>
              <Processor Type="ScriptProcessor" ID="Script Processor2" Bypassed="0" Script="function onNoteOn()&#10;{&#10;&#9;&#10;}&#10;function onNoteOff()&#10;{&#10;&#9;&#10;}&#10;function onController()&#10;{&#10;&#9;&#10;}&#10;function onTimer()&#10;{&#10;&#9;Console.print(&quot;2&quot;);&#10;}&#10;function onControl(number, value)&#10;{&#10;&#9;&#10;}&#10;">
                <EditorStates BodyShown="1" Visible="1" Solo="0" contentShown="1" onInitOpen="0"
                              onNoteOnOpen="0" onNoteOffOpen="0" onControllerOpen="0" onTimerOpen="1"
                              onControlOpen="0"/>
                <ChildProcessors/>
                <Content/>
              </Processor>
            </ChildProcessors>
          </Processor>
          <Processor Type="ModulatorChain" ID="GainModulation" Bypassed="0" Intensity="1">
            <EditorStates BodyShown="1" Visible="0" Solo="0" Folded="1"/>
            <ChildProcessors/>
          </Processor>
          <Processor Type="ModulatorChain" ID="PitchModulation" Bypassed="1" Intensity="0">
            <EditorStates BodyShown="1" Visible="0" Solo="0" Folded="1"/>
            <ChildProcessors/>
          </Processor>
          <Processor Type="EffectChain" ID="FX" Bypassed="0">
            <EditorStates BodyShown="1" Visible="0" Solo="0" Folded="1"/>
            <ChildProcessors/>
          </Processor>
        </ChildProcessors>
        <RoutingMatrix NumSourceChannels="2" Channel0="0" Send0="-1" Channel1="1" Send1="-1"/>
        <macro_controls>
          <macro name="Macro 1" value="0" midi_cc="-1"/>
          <macro name="Macro 2" value="0" midi_cc="-1"/>
          <macro name="Macro 3" value="0" midi_cc="-1"/>
          <macro name="Macro 4" value="0" midi_cc="-1"/>
          <macro name="Macro 5" value="0" midi_cc="-1"/>
          <macro name="Macro 6" value="0" midi_cc="-1"/>
          <macro name="Macro 7" value="0" midi_cc="-1"/>
          <macro name="Macro 8" value="0" midi_cc="-1"/>
        </macro_controls>
        <MidiAutomation/>
      </Processor>
      

      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

        Yeah, there is only one timer per sound module. I decided against multiple timers because I didn't need it yet and it reduces the overhead, but I agree it violates the encapsulation principle of the module architecture.

        What's the use case for this? Maybe there is a workaround (if not I could think about something with little overhead).

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

          I have an artificial trill script and an artificial glide script that both use it to trigger notes. I've got a work around though, the scripts have mute buttons, because only one can be active at a time, so I just check it's state in the on timer callback. What's Engine.createTimerObject() for?

          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

            It creates an extra timer but it runs in the message thread, so I would use it for audio stuff, and actually since ScriptPanels also have a timer for animation it became pretty useless - I think I added it before I added timers to the Panels but left it in the code base for some weirder use cases. Somehow the API doc didn't make it in the autocomplete list, but this is the usage:

            const var timer = Engine.createTimerObject();
            
            timer.startTimer(150); // in milliseconds
            timer.callback = function()
            {
            	Console.print("tut");
            	
            };
            
            1 Reply Last reply Reply Quote 1
            • First post
              Last post

            18

            Online

            1.8k

            Users

            12.1k

            Topics

            104.9k

            Posts