HISE Logo Forum
    • Categories
    • Register
    • Login

    how to make a simple note hold toggle?

    Scheduled Pinned Locked Moved Scripting
    11 Posts 3 Posters 1.6k 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 @AxiomCrux
      last edited by d.healey

      @macromachines All of the built in scripts are available on github (they're in a C++ script but can easily be translated to HISE script).

      What do you want to do exactly when you say a simple note hold toggle?

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

      1 Reply Last reply Reply Quote 0
      • AxiomCruxA
        AxiomCrux
        last edited by

        @d-healey the C++ scripts sound somewhat useful. My point was if they were provided in the same format as the editable scripts, they could function as examples / templates.

        by Note Hold Toggle, I mean a switch that would disable note off events coming through.. essentially like a sustain pedal connected to a toggle button. Absynth has a feature like this and I use it all the time for sound designing.

        http://www.axiom-crux.net

        1 Reply Last reply Reply Quote 0
        • AxiomCruxA
          AxiomCrux
          last edited by

          I found this thread that might be helpful, but I cant figure out how to paste the snippet code :
          https://forum.hise.audio/topic/243/mouse-modifier-to-click-keyboard-and-sustain-a-note

          http://www.axiom-crux.net

          1 Reply Last reply Reply Quote 0
          • AxiomCruxA
            AxiomCrux
            last edited by

            Ok found this thread :
            https://forum.hise.audio/topic/231/zero-effort-sustain-controller

            looks like Message.ignoreEvent(true); inside the onNoteOff function is what I was looking for.

            http://www.axiom-crux.net

            1 Reply Last reply Reply Quote 0
            • AxiomCruxA
              AxiomCrux
              last edited by

              Though is there maybe a way to bind a toggle button to the internal MIDI sustain handling?

              http://www.axiom-crux.net

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

                Yes the ignoreEvent function is what you need. By bind to the internal MIDI sustain handling I assume you mean you want the sustain pedal to turn this feature on or off? If so just use the Synth.isSustainPedalDown() function in the on note off callback. You can also disable the default sustain pedal behavior in the on controller callback using ignoreEvent.

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

                1 Reply Last reply Reply Quote 0
                • AxiomCruxA
                  AxiomCrux
                  last edited by

                  @d-healey said in how to make a simple note hold toggle?:

                  Synth.isSustainPedalDown()

                  Cool, thats useful. So my initial thought that Synth was a general API class was correct.. I tried to see if there was some info on it in the API doc and I thought maybe it was specific to the synthesized waveform generators when I saw that there was also a Sampler class in the API.

                  Actually I was asking how I might bind an interface button to turn on and off the sustain pedal.

                  http://www.axiom-crux.net

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

                    Actually I was asking how I might bind an interface button to turn on and off the sustain pedal.

                    inline function toggleSustain(component, value)
                    {
                        Synth.sendController(64, value ? 127 : 0);
                    }
                    
                    SustainToggleButton.setControlCallback(toggleSustain);
                    
                    AxiomCruxA 1 Reply Last reply Reply Quote 0
                    • AxiomCruxA
                      AxiomCrux @Christoph Hart
                      last edited by

                      @christoph-hart Thank you :D . I am curious, is the component input meant to be used in functions or is it only used by the callback definition to pass the component object internally?

                      http://www.axiom-crux.net

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

                        Of course you can use it in the function itself, just be cautious that you don't create cyclic references by doing something stupid :)

                        This parameter gets incredibly handy when you use one callback function for multiple controls:

                        
                        const var buttons = [];
                        for(i = 0; i < 128; i++)
                        {
                           buttons.push(Content.getComponent("button" + i);
                        }
                        
                        inline function printMyIndex(component, value)
                        {
                            local index = buttons.indexOf(component);
                            Console.print("You clicked button " + index);
                        };
                        
                        for(b in buttons) 
                            b.setControlCallback(printMyIndex);
                        

                        I've been using this paradigm in literally every project I am working on since it heavily reduces boilerplate code. Although it comes with a slight performance overhead because it needs to look up the index in the array, so if it's a time critical function, better code it manually...

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

                        20

                        Online

                        1.7k

                        Users

                        11.8k

                        Topics

                        102.3k

                        Posts