HISE Logo Forum
    • Categories
    • Register
    • Login

    Activating/Deactivating a GUI Button via MIDI Keys in HISE?

    Scheduled Pinned Locked Moved General Questions
    12 Posts 2 Posters 434 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
      lijas90
      last edited by

      Hi, I’d like a button to turn on and off when I press certain keys. I tried this in the Script Processor but it doesn’t work. Can anyone help me? Thanks a lot.

      function onNoteOn()
      {
          
          if (Message.getNoteNumber() == 47 || Message.getNoteNumber() == 48)
          {
              local value = btn1.getValue();
              btn1.setValue(1 - value);
          }
      }
      
      d.healeyD 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey @lijas90
        last edited by

        @lijas90 In what way does it not work?

        That code looks good and works here.

        I also made a more refined version for you

        HiseSnippet 812.3ocsUs0aSCCE1tqAQJvDShe.g8TKZZpYq2lPHF8FTAcqhNlPBgl7bbZsZhcUr6fJD+m3mFuwivwIo21l1kJQdHJm6e9b97I8hjTlRIiP3bmLcLCgerU+oB8vFCIbApSSDdSqtDklE4jnp9zwDkh4gv3MdqQA1NKJ942utNIfHnrEpPnSkbJ6C7Ptdg1dG9ddPPahG6Dd3RdW5vNTongLPNAvyFVEQiIzQjAriHF2xXgdGQMDgeg0dtkOv2q79t01qTshG3xpTthmuWU309m6545Uy6fRUYkP3GzxiqkQ80DMSAIstzaZ+gxuIRJvobE+7.lQvE0GpbhZTig7.udyZNJDBms2hV0FIspmY0k6wmqeQK6owFbVDwxMMblaBRt2CHgWBRYSfzVV8oQ7w5EVL34QVcDvDzm.ylkgRhunLJrUCI3gPuaHYDqcDHLOh7UJVbGG3UgWlKGLeTZmQJmW47kRU2woTsuNW6EjHm5SzZovELOKgCX5FxvwRAHje6T6aaxk+DAUykBGo3HolcrHegb+HmcfjRBbDPJ5Bm.X5aRgwgilDdNKJODpcNatuS9QpcgJqgttJunPgb1NvSZE1UwzmRBlvx+7YZFLSSAHE+LmykquueB.tjMyAIRFDXJ80X1Pgito.yKhw8NP+AJ9bGgQ1p7fGb23Azj95RNJEcDb8wiYoxskAdl4q46qxZPoCFC+IEgfq5X1ylormjNFhCIw1Js8ghgug0f9TmlDMYVBfbA4eLKRyMGCbS1EvU9D5nsUSlZjVNN12TV.bxuCk66HrE9O.dmZ93Ww6MtBcGtnI8lDPzqd6yrWJ0.LJVgxan0BEWOc48V2iqjEuwqj2UHtkUOtlN75wXlqAiPy9+AFSWj8DqV99LpdA.yZ09yq6Vqao7eTNQyEC5RzQbyPFtV2GV3SYP0EBVfxLuyXHpIxEMxlNPelvKV3uvSpQWiLN0n6LinPBMRdFMgdaVU9vXM.lDw+JwF9mFH6LmUunOGBatOiRWMUWIv8V2.2ecCrz5FX40MvJqafUW2.qc6AZ9w5alnkgIWaPnt8ZEuMBiaIH.CLlsh9G30MyUG
        

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

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

          @d-healey Ok, now it works. Thanks. However, it only works when I press the physical key on the controller. Is there a way to make the button activate when a MIDI player is playing those notes? To simulate an instrument animation that triggers when the MIDI is played? Thanks.

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

            @lijas90 Have you tested it in a daw? It should work

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

            L 2 Replies Last reply Reply Quote 1
            • L
              lijas90 @d.healey
              last edited by lijas90

              @d-healey

              I’ve tried it and it doesn’t work. Do I need to do it in a Script Processor inside the MIDI Processor in some specific way?

              L 1 Reply Last reply Reply Quote 0
              • L
                lijas90 @lijas90
                last edited by

                @lijas90 Sorry, it does work.😌

                L 1 Reply Last reply Reply Quote 0
                • L
                  lijas90 @lijas90
                  last edited by

                  @lijas90 Thanks David!

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

                    @d-healey How can I make the button activate only while the key is being pressed, and deactivate when the key is released? Thanks.

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

                      @lijas90 In onNoteOn turn the button on, in onNoteOff turn the button off.

                      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
                        lijas90 @d.healey
                        last edited by

                        @d-healey I’ve tried it like this but it doesn’t work; the button only deactivates when pressing it again, not when releasing the key. Thanks, my friend.

                        function onNoteOff()
                        {
                        local n = Message.getNoteNumber();
                           
                           if (ks.contains(n))
                               btn1.setValue(0);
                               
                               
                        
                        }
                        
                        d.healeyD 1 Reply Last reply Reply Quote 0
                        • d.healeyD
                          d.healey @lijas90
                          last edited by

                          @lijas90 Post a snippet so I can see the full code

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

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

                            @d-healey Sorry, it works now. Thanks again, David

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

                            35

                            Online

                            1.9k

                            Users

                            12.5k

                            Topics

                            109.0k

                            Posts