HISE Logo Forum
    • Categories
    • Register
    • Login

    MIDI keyboard range script?

    Scheduled Pinned Locked Moved General Questions
    19 Posts 6 Posters 1.1k 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
      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

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

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

        thanx.

        my website: https://musictop69.wixsite.com/ilirbajri
        https://musictop69.wixsite.com/creatools
        https://musictop69.wixsite.com/orchestools

        d.healeyD 1 Reply Last reply Reply Quote 0
        • d.healeyD
          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

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

            @d-healey thank you so much David.

            my website: https://musictop69.wixsite.com/ilirbajri
            https://musictop69.wixsite.com/creatools
            https://musictop69.wixsite.com/orchestools

            1 Reply Last reply Reply Quote 1
            • meyerkeysM
              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!!

              ustkU 1 Reply Last reply Reply Quote 0
              • ustkU
                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;

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

                LindonL 1 Reply Last reply Reply Quote 1
                • LindonL
                  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
                  • ustkU
                    ustk
                    last edited by

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

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

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

                      Many thanks guys!

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

                      Cheers!

                      LindonL 1 Reply Last reply Reply Quote 0
                      • LindonL
                        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.healeyD 1 Reply Last reply Reply Quote 0
                        • d.healeyD
                          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
                          • meyerkeysM
                            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.

                            ustkU 1 Reply Last reply Reply Quote 0
                            • ustkU
                              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

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

                              B 1 Reply Last reply Reply Quote 0
                              • B
                                Ben Catman @ustk
                                last edited by

                                Guys sorry for reviving this old topic,

                                I have two Sampler, and one Synth Group, and with the script above i can set the note range for all of them. No problem here - but how can i control my samplers seperately. So that i can set a range for Sampler1, 2 and my Synth Group?

                                Thanks so much
                                best
                                Ben

                                LindonL 1 Reply Last reply Reply Quote 0
                                • LindonL
                                  Lindon @Ben Catman
                                  last edited by

                                  @Ben-Catman put the script in three separate script processors one in each sound source.

                                  HISE Development for hire.
                                  www.channelrobot.com

                                  B 1 Reply Last reply Reply Quote 0
                                  • B
                                    Ben Catman @Lindon
                                    last edited by Ben Catman

                                    @Lindon

                                    so you mean i move everything, including the oninit part to the script processor? because in the script processor it cant get my slider value. so how can i cross reference that?

                                    LindonL 1 Reply Last reply Reply Quote 0
                                    • LindonL
                                      Lindon @Ben Catman
                                      last edited by Lindon

                                      @Ben-Catman create a slider in your script processor and change that from your UI

                                      start like this in the script processor on init

                                       const var LowRange = Content.addKnob("LowRange", 10, 0);
                                       LowRange.setRange(0, 126, 1);
                                       const var HighRange= Content.addKnob("HighRange",180, 0);
                                       HighRange.setRange(1, 127, 1);
                                      

                                      HISE Development for hire.
                                      www.channelrobot.com

                                      B 1 Reply Last reply Reply Quote 0
                                      • B
                                        Ben Catman @Lindon
                                        last edited by

                                        @Lindon
                                        Got it, got it.

                                        Guys, you are AMAZING!

                                        Thx so much!!!!

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

                                        14

                                        Online

                                        1.7k

                                        Users

                                        11.8k

                                        Topics

                                        103.1k

                                        Posts