HISE Logo Forum
    • Categories
    • Register
    • Login

    Choke groups

    Scheduled Pinned Locked Moved General Questions
    21 Posts 4 Posters 4.7k 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.
    • L
      ludo
      last edited by

      Hello,

      I'd like to make a very basic drums vst with the ability to stop the open Hi-Hat sound when the the closed Hi-Hat is triggered. Is there a built-in solution or a script is needed?

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

        Hi Ludo,

        this sounds like a perfect task for a little script. Just save the event ids of every MIDI message that triggers a open hi hat and call Synth.noteOffByEventId() whenever a closed Hi Hat is played. If you only allow one open hi hat sound to ring, it gets even easier (then you don't have to keep a list of event IDs around).

        1 Reply Last reply Reply Quote 0
        • L
          ludo
          last edited by

          Thanks for your answer and for your app by the way, it's great!
          Do you think something like that could work?

          var closeHiHatKey = 66;
          var openHiHatKey = 70;
          var evtList = [];
          var evtListLength = 0;
          var groupList = [];
          groupList[0] = closeHiHatKey;
          groupList[1] = openHiHatKey;
          
          function onNoteOn()
          {
          	for (var i = 0; i < groupList.length; i++) {
          		if (Message.getNoteNumber()==groupList[i]) {
          			evtListLength = evtList.length;
          			for (var j = evtListLength; j < 0; j--) {
          				Synth.noteOffByEventId(evtList[j]);	
          				evtList.pop();
            			}
          			evtList.push(Message.getEventId());
          		}
          	}
          }
          function onNoteOff()
          {
          	
          }
          function onController()
          {
          	
          }
          function onTimer()
          {
          	
          }
          function onControl(number, value)
          {
          	
          }
          1 Reply Last reply Reply Quote 0
          • Christoph HartC
            Christoph Hart
            last edited by Christoph Hart

            The onNoteOn callback is a bit too complicated (you don't need to use nested for loops).

            Also, you need to call Message.makeArtificial() for the note on you want to kill later using Synth.noteOffByEventId(). The reason for this is rather complicated but there's an explanation here.

            This script should do what you need. I've added comments where possible:

            // Use const var for constants for improved performance.
            const var closeHiHatKey = 66;
            const var openHiHatKey = 70;
            
            //  An Array is also a constant, even if it will be populated later on
            const var evtList = [];
            
            // make sure it has enough storage to avoid allocation during the noteOn callback
            evtList.reserve(64);
            
            function onNoteOn()
            {
                if(Message.getNoteNumber() == closeHiHatKey)
                {
                    // Always use the for ... in loop if you don't need the index
                    for(eventId in evtList)
                    {
                        // Send the note off command for the given event id
                        Synth.noteOffByEventId(eventId);
                    }
                    
                    // Clear all notes
                    evtList.clear();
                }
                else if (Message.getNoteNumber() == openHiHatKey)
                {
                    // This is necessary because you will kill the note artificially and HISE
                    // can only kill artifical notes for stability reasons
                    Message.makeArtificial();
                    
                    // Add this ID to the list (it'll add the artificial event ID)
                    evtList.push(Message.getEventId());
                }
            }
            function onNoteOff()
            {
                if(Message.getNoteNumber() == openHiHatKey)
                {
                    // We need to ignore the note-off message
                    // for the open hi-hat so it will keep ringing...
                    Message.ignoreEvent(true);
                }
            }
            function onController()
            {
                
            }
            function onTimer()
            {
                
            }
            function onControl(number, value)
            {
                
            }
            
            Dan KorneffD 1 Reply Last reply Reply Quote 0
            • L
              ludo
              last edited by

              Thank you very much, I learned a lot!

              1 Reply Last reply Reply Quote 0
              • L
                ludo
                last edited by

                Hi,
                I'm back with another but related question. I would like to use the one shot option for my instrument but your script doesn't work anymore. Is there a way to make it work?

                Thanks

                Ludovic

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

                  Are you sure? I've just checked and it works here exactly like back in the days.

                  1 Reply Last reply Reply Quote 0
                  • L
                    ludo
                    last edited by

                    Yes I think. I tried a lot of time. When « playback settings / playback » is « normal », it works great but when I switch to « one shot », it looks like the function noteOffByEventId doesn’t cut the sound.

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

                      Yes this is intentional. One shot means „ignore the note off and play the whole sample“.

                      1 Reply Last reply Reply Quote 0
                      • L
                        ludo
                        last edited by

                        Ok, I understand that. This HH things is a very particular case. But as far as I know, several sampler work this way for drums instruments, one shot and choke group. Do you think it would be possible to implement that in Hise? It’s certainly not a high priority but it could be a good feature…

                        1 Reply Last reply Reply Quote 1
                        • Christoph HartC
                          Christoph Hart
                          last edited by

                          The script above already ignores the note off for the open hihat so it should behave like oneshot + choke group.

                          1 Reply Last reply Reply Quote 0
                          • L
                            ludo
                            last edited by

                            Ah Ok! Sorry for my dumb's questions... So I could use Message.ignoreEvent(true) in the onNoteOff() function for the all drum set to emulate the one shot option, that's it?

                            Thanks again for your time

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

                              Yep that should work.

                              1 Reply Last reply Reply Quote 0
                              • Dan KorneffD
                                Dan Korneff
                                last edited by

                                Hey guys,
                                Digging up this old thread. I'm working on a project that needs this function, but I'm unable to make it work. My background had been in Kontakt scripting, so a lot of this looks familiar. I see there are a million different places to add scripts in software. Does each script slot affect only a specific sampler?
                                I've currently separated different instruments of a drum kit into containers, and placed samplers in each container for each instrument. Do I need to place this script in the midi slot of the main project container? or of the container for my hi-hat track?
                                I've tried both with no luck.

                                Dan Korneff - Producer / Mixer / Audio Nerd

                                1 Reply Last reply Reply Quote 0
                                • Dan KorneffD
                                  Dan Korneff @Christoph Hart
                                  last edited by

                                  @christoph-hart Also want to add that I've copied/pasted Cristoph's script above into the project, only changing the notes associated with closeHiHatKey and openHiHatKey.

                                  Dan Korneff - Producer / Mixer / Audio Nerd

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

                                    Still works:

                                    HiseSnippet 1399.3oc4X01ZabDD9NaePsRansjB8i6GJDIHQQJI0oPvDKKYmHRThwxMoPoDVe2b5V7ocut2dxQsj+i8mR9GzNy8tpu5XUZSf1CgP6L6ryy7LyN6d5HsxEhiUZK6qcxxHvx9ScltTZBFFvERqwirrutyDdrAzrLQ6uLhGGCdV11a9XRf81aYk97tGsOOjKcgJQVVuTIbgmIlKLURi16ohvvC4dvIh40l882arqRNTEpRP7roSOqHt6Y7Yvy4zz1vwZg.NO1x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aeapDbd1BW2hhpQZgYAhaGvMLr6QQmhy.HhQaiwO3dlKPuYdIMDaazIPyw3PkznUggTTfg41qpkN.sQE4l0VlR.2BaMEhdHedXK6UOSn0U6LArKGdUISsIpjikByKPBnXbV2mBI8rJyR0EUET0klFLMLsJQMbOlgYXhN7e7HtgSmMkKCmGdNgQPQn8HXAdSjrSp11YDDelQE8A7Buad0t0164n1sKv3T7nvP3.4BHDCx7a4NB74IglRo0A4DkTEEnjB25Wj4XvnEylA55Puw3Yfwfm9TI4F6cLf8BqeoruYumgWlhqQZB9aRE8u5Twkkt9ZmL3xnRJ1+MdOkM++46obrJwfMPmvwB02fu+L1QeJ99At.hDoDO6kde8MnFAYi6QiydAAoWuhWlOWYeZrctx9EJ+f3i4bWs50tYcznZ4OIUBF2xz+7hsclPiY8sRaUmwMywq0+ZWWhruMxNMawcWaKt2Zaw8WaK9101hcVaKdvZaw2cIVPuC0fDiZd1VOKq+.2caPgA
                                    

                                    And yes you can add scripts at different places, which is super useful for encapsulating functionality, so in your case, it should be enough to drop this on the sampler that contains the HiHat samples.

                                    1 Reply Last reply Reply Quote 0
                                    • Dan KorneffD
                                      Dan Korneff
                                      last edited by

                                      @christoph-hart I think I'm counting the keys wrong. I had C1 as 60

                                      Dan Korneff - Producer / Mixer / Audio Nerd

                                      d.healeyD 1 Reply Last reply Reply Quote 0
                                      • Dan KorneffD
                                        Dan Korneff
                                        last edited by

                                        Once you collect the midi note number with Message.getNoteNumber(), how do you display this in the console?

                                        Dan Korneff - Producer / Mixer / Audio Nerd

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

                                          @dustbro C4 is the usual standard for MIDI note 60 although some systems use C3. - https://en.wikipedia.org/wiki/C_(musical_note)#Middle_C

                                          Console.print(Message.getNoteNumber());

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

                                          Dan KorneffD 1 Reply Last reply Reply Quote 1
                                          • Dan KorneffD
                                            Dan Korneff @d.healey
                                            last edited by

                                            @d-healey OMG I'm so stupid... That's what I was doing, but it was returning an "unknown Function" error in the console...
                                            I didn't capitalize the M in message!!

                                            Dan Korneff - Producer / Mixer / Audio Nerd

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

                                            45

                                            Online

                                            1.7k

                                            Users

                                            11.7k

                                            Topics

                                            101.8k

                                            Posts