Forum

    • Register
    • Login
    • Search
    • Categories

    MIDI keyboard range script?

    General Questions
    5
    14
    341
    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.
    • musictop
      musictop last edited by

      Any help/link/suggestion on how to let users set keyboard range per sampler/synth?

      thanx.

      my website: https://musictop69.wixsite.com/ilirbajri
      orchestools instruments at: https://musictop69.wixsite.com/orchestools

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

        Do you mean allow the user to limit the range of playable keys? Or do you want to change the colour of the keys on the on-screen keyboard?

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

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

          @d-healey to set/limit the range of playable keys.

          thanx.

          my website: https://musictop69.wixsite.com/ilirbajri
          orchestools instruments at: https://musictop69.wixsite.com/orchestools

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

            @musictop You just need an if statement in on note on.

            if (Message.getNoteNumber() < lower_range || Message.getNoteNumber() > upper_range)
                Message.ignoreEvent(true);
            

            You can set the lower/upper values from whatever controls you want on the ui.

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

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

              @d-healey thank you so much David.

              my website: https://musictop69.wixsite.com/ilirbajri
              orchestools instruments at: https://musictop69.wixsite.com/orchestools

              1 Reply Last reply Reply Quote 1
              • meyerkeys
                meyerkeys last edited by

                Hi guys,
                I would like to make UI with 2 flexible split points (for tenor / soprano / piccolo instruments) and on first sight your bit of code is exactly what I was looking for.
                It works great when I replace lower_range and upper_range with numbers, but when assigning a slider to set the ranges from the UI they become just on/off switches (range 0-1 switches at 0.5 ; 0-127 at 1).

                Obviously I would like to set a value between 0 and 127 with a slider in the UI. Any Idea how to make that happen?

                thanks!!

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

                  @meyerkeys Hi
                  You can set the slider ranges in the property editor of your sliders (0-127) (don't forget to set the stepSize to 1)

                  Then first solution:

                  • Create the slider's Script Reference in the onInit callback.
                  • Then in the noteOn callback, you can replace the lower_range variable with myLowRangeSlider.getValue()

                  Second solution:

                  • Keep the const var lower_range variable
                  • Create a callback for your slider in the onInit
                  • In the callback, place lower_range = value;

                  I can't help pressing F5 in the forum...

                  Lindon 1 Reply Last reply Reply Quote 1
                  • Lindon
                    Lindon @ustk last edited by

                    @ustk said in MIDI keyboard range script?:

                    @meyerkeys Hi
                    You can set the slider ranges in the property editor of your sliders (0-127) (don't forget to set the stepSize to 1)

                    Then first solution:

                    • Create the slider's Script Reference in the onInit callback.
                    • Then in the noteOn callback, you can replace the lower_range variable with myLowRangeSlider.getValue()

                    Second solution:

                    • Keep the const var lower_range variable
                    • Create a callback for your slider in the onInit
                    • In the callback, place lower_range = value;

                    'cept it couldnt be

                    const var lower_range

                    it would need to be

                    var lower_range

                    HISE Development for hire.
                    www.channelrobot.com

                    1 Reply Last reply Reply Quote 1
                    • ustk
                      ustk last edited by

                      @Lindon Oups sorry, you're right const shouldn't be here...

                      I can't help pressing F5 in the forum...

                      1 Reply Last reply Reply Quote 0
                      • meyerkeys
                        meyerkeys last edited by

                        Many thanks guys!

                        I wondered about "const" as well but I got it working with both versions.

                        Cheers!

                        Lindon 1 Reply Last reply Reply Quote 0
                        • Lindon
                          Lindon @meyerkeys last edited by

                          @meyerkeys yes the first solution @ustk offered may well work but the second wont as:

                          lower_range = value;

                          means you are assigning a value to a constant - and that wont work. constants get set and can never be changed - theyre, huh, constant...:-)

                          HISE Development for hire.
                          www.channelrobot.com

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

                            If the constant is an object you can change the object's contents.

                            const var foo = [1, 2, 3];
                            
                            foo[1] = 10;
                            
                            Console.print(foo[1]);
                            

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

                            1 Reply Last reply Reply Quote 1
                            • meyerkeys
                              meyerkeys last edited by

                              Thank you guys for staying on this.
                              I kind of wondered about the const or const var thing anyway as David is using const var mostly in his great videos. Can't thank you enough for those btw. 👍
                              So your last post clarifies again. Got it.

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

                                @meyerkeys You can find more information in the doc about the different variables in Hise
                                https://docs.hise.audio/scripting/scripting-in-hise/additions-in-hise.html#const-variables

                                I can't help pressing F5 in the forum...

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

                                10
                                Online

                                1.1k
                                Users

                                7.0k
                                Topics

                                64.6k
                                Posts