HISE Logo Forum
    • Categories
    • Register
    • Login

    Check if event is active

    Scheduled Pinned Locked Moved Feature Requests
    7 Posts 2 Posters 1.4k 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

      Could we have a function to check if a given eventID has been turned off? Occasionally I'm getting a situation where another script has already turned off a note and I get this warning NoteOff with ID2077 wasn't found

      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 Christoph Hart

        Yeah sure. Although I'd recommend checking the design if this is really necessary - normally a script should know whether the event exists or not. There is a useful programming paradigm called RAII which basically means that the creator of something should take responsibility over its ownership and delete it when its no longer in use. It's extremely popular in languages like C++ but also applies to events: if a script creates an artificial note on, it should also always create a corresponding note off at some time.

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

          Thanks, I'll check out RAII. Basically I have three scripts - Legato, Glide, and Trill. Only one can be active at a time but I want to pass the currently held note, either artificial or real depending on the current process in the script, to one of the other scripts.

          So a user can play legato between two notes and while holding the last note switch to glide and the glide script will pick up the last legato note and that will become the first note of the glide. The issue is the three scripts are sharing note IDs. What I need to do is improve the interscript communication I think.

          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

            You know there are global variables that can be accessed from every script?

            global x = 5; 
            
            Console.print(x); // is accessible from every script.
            

            This is extremely helpful for all inter script communication stuff - I am using it regularly to control scripted fx modules from the main interface. If you store the event IDs in a global variable, you don't have to do your house-keeping twice.

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

              Yes I'm using the Globals object :) however I've only been updating it when the active script is changed. Is there any performance penalty when writing/reading from the globals object within the note callbacks?

              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

                Writing global x = 5 is actually just a shortcut to Globals.x = 5. And it is exactly as fast as using the standard var type (though not as fast as reg or const). However if it improves the design, go for it and don't care about the performance.

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

                  Brilliant, I shall do as you suggest and I think it will solve the issue.

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

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

                  47

                  Online

                  1.7k

                  Users

                  11.7k

                  Topics

                  101.8k

                  Posts