HISE Logo Forum
    • Categories
    • Register
    • Login

    Creating a velocity limiting knob, can someone show me how this should look?

    Scheduled Pinned Locked Moved Scripting
    9 Posts 3 Posters 208 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
      LozPetts
      last edited by

      Hey all,

      I'm trying to create a knob that as you turn it down will limit the maximum velocity that gets fed into my sampler. I'm trying to use message.setVelocity like so:

      message.setVelocity(range, 1 - 127)

      But I'm not sure how to:
      A. use this to limit the velocity depending on the value of the knob.
      B. Tie this to a knob, I understand this shouldn't be used in the interface script, would you put this in a control callback or in onNoteon in the MIDI script processor?

      Has anyone got an example of this so I can see how/where it would be used?

      Thanks all!

      ustkU 1 Reply Last reply Reply Quote 0
      • ustkU
        ustk @LozPetts
        last edited by

        @LozPetts What you need is:

        • a midi script processor in the sampler.
        • add a knob to this script processor's interface, and set its max property to 127, step to 1, etc...
        • add a knob to the main interface, and set its max property to 127, step to 1, etc...
        • link the interface's knob to the midi script proc' knob, either via the properties panel or by script.
        • In the sampler's midi script onInit, reference the knob like const var maxVelKnb = Content.getComponent("maxVelKnb");
        • in the onNoteOn callback, set the velocity using Math.min()

        I leave to you what two parameters to put inside Math.min().
        Hint: it'll be something about the knob and the current message velocity 😉

        Can't help pressing F5 in the forum...

        L 1 Reply Last reply Reply Quote 1
        • L
          LozPetts @ustk
          last edited by

          @ustk You absolute star, thanks for that! This is where I am, I think I might be pretty close but I'm getting 'Unknown Function "min"' errors, which seems odd consider HISE filled it in for me so I KNOW the function is written correctly at least.

          function onNoteOn()
          {
          math.min(message.getVelocity(), MaxVelKnob(getValue()));
          Console.print("Velocity: " + Message.getVelocity());
          };
          
          

          I'm using math.min to compare the two numbers (the velocity played and the velocity stated by the knob), and pick the lowest one. Then (as I've only loaded in one sample across the keyboard as I haven't had the sample session yet), I've got it to print the velocity so I can confirm it's working.

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

            @LozPetts Whenever you get a unknown function error it means either the thing on the left side of the . doesn't have a function with that name, or the thing on the left side of the . doesn't exist. In your case it's the latter - check your spelling (HISE script is case sensitive).

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

            L 1 Reply Last reply Reply Quote 0
            • L
              LozPetts @d.healey
              last edited by

              @d-healey D'oh. Thank you!
              That's got it printing the velocity okay, no more errors - still not limiting the velocity when I play with my knob though...

              d.healeyD ustkU 2 Replies Last reply Reply Quote 0
              • d.healeyD
                d.healey @LozPetts
                last edited by d.healey

                @LozPetts said in Creating a velocity limiting knob, can someone show me how this should look?:

                play with my knob though

                :face_with_raised_eyebrow:

                I don't see in your script where you're changing the velocity.

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

                L 1 Reply Last reply Reply Quote 1
                • ustkU
                  ustk @LozPetts
                  last edited by ustk

                  @LozPetts like @d-healey says, and adding that:

                  MaxVelKnob(getValue())
                  

                  is not how to get the value, but you’re close:
                  https://docs.hise.audio/scripting/scripting-api/scriptslider/index.html#getvalue

                  Can't help pressing F5 in the forum...

                  1 Reply Last reply Reply Quote 1
                  • L
                    LozPetts @d.healey
                    last edited by

                    @d-healey That would help. Face palmed pretty hard there.

                    Just in case it helps anyone in future!

                    function onNoteOn()
                    {
                    //Velocity Limiter Knob
                    Message.setVelocity(Math.min(Message.getVelocity(), MaxVelKnob.getValue())); 
                    Console.print("Velocity: " + Message.getVelocity());
                    };
                     
                    
                    L 1 Reply Last reply Reply Quote 1
                    • L
                      LozPetts @LozPetts
                      last edited by

                      @LozPetts PS you both rock - thank you so much for your help.

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

                      30

                      Online

                      1.7k

                      Users

                      11.8k

                      Topics

                      102.3k

                      Posts