HISE Logo Forum
    • Categories
    • Register
    • Login

    best way to kill all voices?

    Scheduled Pinned Locked Moved General Questions
    6 Posts 4 Posters 368 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.
    • ulrikU
      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 15.3.1, Xcode 16.2
      http://musikboden.se

      Christoph HartC griffinboyG 2 Replies Last reply Reply Quote 0
      • Christoph HartC
        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.

        ulrikU 1 Reply Last reply Reply Quote 1
        • ulrikU
          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 15.3.1, Xcode 16.2
          http://musikboden.se

          1 Reply Last reply Reply Quote 0
          • griffinboyG
            griffinboy @ulrik
            last edited by griffinboy

            @ulrik

            Recently had to do this myself and took a moment to figure it out, hence,
            leaving this additional example here.

            
            // Spawn a background task to hard-stop all voices
             const var bt = Engine.createBackgroundTask("KillAllVoicesTask");
            
            
            // Call this to kill voices
            inline function killAllVoices()
            {
            
                    bt.killVoicesAndCall(function()
                    {
                        // nothing
                    });
            }
            
            d.healeyD 1 Reply Last reply Reply Quote 0
            • d.healeyD
              d.healey @griffinboy
              last edited by d.healey

              @griffinboy Why have you put it in an inline function?

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

              griffinboyG 1 Reply Last reply Reply Quote 0
              • griffinboyG
                griffinboy @d.healey
                last edited by

                @d-healey

                Probably because I'm a fool and I didn't get how to call it in the natural state 😅

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

                47

                Online

                1.7k

                Users

                11.7k

                Topics

                101.8k

                Posts