Forum

    • Register
    • Login
    • Search
    • Categories

    best way to kill all voices?

    General Questions
    2
    3
    156
    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.
    • ulrik
      ulrik last edited by

      I'm using add/remove Modulators a lot in a project
      What is the best way to kill all voices before adding/removing a modulator?
      I use AllNotesOff but it could still be voices fading out

      Hise Develop branch
      MacOs 12.4, Xcode 13.0
      http://musikboden.se

      Christoph Hart 1 Reply Last reply Reply Quote 0
      • Christoph Hart
        Christoph Hart @ulrik last edited by

        @ulrik I've added a function to the BackgroundTask object that kills all voices and then calls a function on the sample loading thread. This logic is used by almost every heavyweight operation (loading sample maps, user presets, etc), and it figures out whether to execute the function synchronously or not (eg. if you call it from a user preset loading callback, it will be executed synchronously because all notes are already killed and it will be called from the sample loading thread already).

        const var bt = Engine.createBackgroundTask("MyTask");
        
        bt.killVoicesAndCall(function()
        {
        	Console.print("I'm on the sample loading thread");
        	
        	// Uncomment this to verify that the stacktrace is on 
        	// the sample loading thread (only in Debug mode obviously)
        	//Console.breakInDebugger();
        });
        

        Be aware that there is no thread synchronisation so if you are trying to access common data on another scripting callback you might end up with race conditions, but this might be a use case where using this construct makes sense.

        ulrik 1 Reply Last reply Reply Quote 1
        • ulrik
          ulrik @Christoph Hart last edited by

          @Christoph-Hart said in best way to kill all voices?:

          This logic is used by almost every heavyweight operation (loading sample maps, user presets, etc)

          Is this performed also if I dynamically change/remove/add a modulator on, effects etc?
          And what about changing modulator in the MacroModulatorSource module, will it also kick in?

          Hise Develop branch
          MacOs 12.4, Xcode 13.0
          http://musikboden.se

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

          18
          Online

          741
          Users

          5.4k
          Topics

          50.4k
          Posts