HISE Logo Forum
    • Categories
    • Register
    • Login

    setKeyPressCallback() how to?

    Scheduled Pinned Locked Moved Scripting
    8 Posts 4 Posters 384 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.
    • toxonicT
      toxonic
      last edited by toxonic

      Can somone please enlight me how to use the setKeyPressCallback()? :-)
      Thanks in advance!

      EDIT: Or is there a way, to control a set of buttons via keyboard?

      Matt_SFM 1 Reply Last reply Reply Quote 0
      • Matt_SFM
        Matt_SF @toxonic
        last edited by Matt_SF

        @toxonic you can simply use button.setValue() into the on Note and noteOff CB

        Edit : or a array of buttons of course

        Develop branch
        Win10 & VS17 / Ventura & Xcode 14. 3

        toxonicT 1 Reply Last reply Reply Quote 1
        • toxonicT
          toxonic @Matt_SF
          last edited by

          @Matt_SF Oh, i missunderstood that, i thought about using the computer keyboard to trigger buttons. But when i overthink it, it'd be quite useless, since you wouldn't be abel to trigger more than one button simultanously.

          S 1 Reply Last reply Reply Quote 0
          • S
            Sounddiy @toxonic
            last edited by

            @toxonic Your question interested me because I am looking for a way to trigger button via keypress.
            I would like to change button's value via specific "on note on" and "on note off" like this :

            OnNoteOn :

            //this doesn't work
            const var Button15 = Content.getComponent("Button15");
            const var Button16 = Content.getComponent("Button16");
            
            
            function onNoteOn(48)
            {
            	Button15.setValue(1);
            }
            
            function onNoteOn(49)
            {
            	Button16.setValue(1);
            }
            
            d.healeyD 1 Reply Last reply Reply Quote 0
            • d.healeyD
              d.healey @Sounddiy
              last edited by d.healey

              @Sounddiy

              You just need to use an if statement.

              You can't add more onNoteOn callbacks, there can be only one (per script)! And it doesn't take any parameters.

              In your one and only onNoteOn callback you can do this.

              if (Message.getNoteNumber() == 48)
              {
                  Button15.setValue(1);
              }
              

              Remember to defer this script, you don't want your UI messing with your real-time stuff.

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

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

                @d-healey ok, thank you david.
                It works.

                So I need to add "Synth.deferCallbacks(true);" at the top of the onNoteOn and onNoteOff script?

                thanks

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

                  @Sounddiy

                  at the top of the onNoteOn and onNoteOff script?

                  Both of those callbacks are in a single script, go have a look in your project's scripts folder and you'll see the file which you can open in a text editor.

                  You should place the deferCallbacks call in on init. This will defer all of the MIDI callbacks in that script.

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

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

                    @d-healey Ok thanks david.
                    it's much clearer for me

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

                    13

                    Online

                    1.7k

                    Users

                    11.8k

                    Topics

                    102.4k

                    Posts