Check if event is active

  • 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

  • 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.

  • 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.

  • 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.

  • 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?

  • 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.

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

Log in to reply