HISE Logo Forum
    • Categories
    • Register
    • Login

    Making button flash upon mouseclick AND midi note

    Scheduled Pinned Locked Moved General Questions
    24 Posts 5 Posters 592 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.
    • ulrikU
      ulrik @Morphoice
      last edited by

      @Morphoice this is a way to do it with panels (I think it's difficult to achieve same result using buttons)
      I had an old script used for indicating when certain key where pressed I just changed som small things so it would look like in your picture.

      All the panels share the same paint routine and the animation is just a timer inside the paint routine, which fades the hit

      Take look and see if you can use something of it.

      drumpad.gif

      HiseSnippet 1332.3ocwX8tSiaDDeMfudIsmTup9.rJex4DMxl7GS5U5ADfB5N3hHzSmD5tSK1qi2hytQ1a.hpPpuJ8S80nOH8gnuAzYsMINArZqgSIRKgc1Y182LyuchG2MT3PihDgHsxmLdHEo8U58Fyk9c7ILN5fcPZei9dAjHeFuOdmvQCFRbQaOdHIJh5hzzV9mT5oUZET7m+9UaSBHbG5TQHz6DLG5aXCXxoR6t4qYAA6QbomvFjQ6Fadfif2QDHFAXZYcSzPhy4j9ziHJ0VRGsO.Fj1KzMa1hRsq645RpW2sUqVsWuci1VDOyFjyrZ0twZMrWacaOj1S10kIEg8jDIMBosx1B2w87EWxSNf2whXmEPUSrP8fSNQ7dh.WkKpjh53yBb6davJBA6R2ogtkSBceq9gLW1D4SCgec7B3oVjM.pszrva4YfmUV3YlAd2Cjzx.oURfzy064DxFJmthBOeo9AbIMzi.4orPIQWzR+9J5cDfFbYsAjyo6EBSlXgQCSyUwvep9xxkgbUjDejPROf6xbHfeDg2.eq08oxsBB5HFLTvg4QFUlQ0JvVjrCbPbOHkCfDL+zVvIzxBFqAi5vnALZBiVvvFFqCi1qhsA8rA8rA8rA8rA8ra9gI.q6wvt4Mh6HYBtQ+pk+0xk5WKhJSHXFReVjBjFUXR5fDgUpBnBzxC3mGKFwARvwTGIg2OfNwf2HbHAaqVMxvrJ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acOs 15.3.1, Xcode 16.2
      http://musikboden.se

      MorphoiceM 2 Replies Last reply Reply Quote 1
      • MorphoiceM
        Morphoice @ulrik
        last edited by

        @ulrik brilliant! I think this should have helped me to understand the principle and see the benefit over using buttons. I'll have a go about implementing this now and report back! thank you all so much.

        https://instagram.com/morphoice - 80s inspired Synthwave Music, Arcade & Gameboy homebrew!

        1 Reply Last reply Reply Quote 0
        • MorphoiceM
          Morphoice @ulrik
          last edited by Morphoice

          @ulrik works like a charm with Midi!

          I'm trying to add a mouse click event to the panels too

          for (d in drumPads) {
          	d.setPaintRoutine(PR);
          	d.setMouseCallback(onDrumPadClick);
          }
          
          inline function onDrumPadClick(event)
          {
          	//Console.print(event);
          	
          	if (event.clicked==1) {
          		Synth.playNote(36, 127);
          		drumPads[0].data.alpha = 1;
          		drumPads[0].changed();
          	} 
          };
          

          this works for the first sound, but how do I get the index of the pad clicked inside the mouse event callback function? it doesn't pass the component only the event, if I understood the documentation correctly. I could give em all a seperate callback function but that would be bad practice, wouldnt it?

          https://instagram.com/morphoice - 80s inspired Synthwave Music, Arcade & Gameboy homebrew!

          LindonL ulrikU 2 Replies Last reply Reply Quote 0
          • LindonL
            Lindon @Morphoice
            last edited by

            @Morphoice said in Making button flash upon mouseclick AND midi note:

            but how do I get the index of the pad clicked inside the mouse event callback function? it doesn't pass the component only the event, if I understood the documentation correctly. I could give em all a seperate callback function but that would be bad practice, wouldnt it?

            you have the x and y position for the mouse click - use that to work out which pad was clicked in your panel.

            HISE Development for hire.
            www.channelrobot.com

            MorphoiceM 1 Reply Last reply Reply Quote 0
            • ulrikU
              ulrik @Morphoice
              last edited by

              @Morphoice In this example I use

              index = AllPanels.indexOf(this);
              

              inside the mouseCallback

              drumpad.gif

              HiseSnippet 1766.3oc2YstaaaCEVJIpa1ccncnXX+TvX+PtHy0x2j85xZRbRZCZbhQbZ2.JZKXjns4hLolDcRLFJvdJ1yydD1iReC1NTT1VJwpq0KIvcAPMkGdt7wy4ijRmz1mYiCBX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onI3uw1NoqtjgklWCKOuFVYdMr57ZXs40Pq40v5+6FJtDZigb1.4VSEkVs2NrKuppaSQ.KObGgx+.bSQgEN
              

              Hise Develop branch
              MacOs 15.3.1, Xcode 16.2
              http://musikboden.se

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

                @Lindon so you mean Content.getComponentUnderMouse should work?

                https://instagram.com/morphoice - 80s inspired Synthwave Music, Arcade & Gameboy homebrew!

                LindonL 1 Reply Last reply Reply Quote 0
                • MorphoiceM
                  Morphoice @ulrik
                  last edited by

                  @ulrik brilliant. I swear I tried the same approach before but hadn't set up everything right so it didnt work. Now it does. Thanks so much!

                  https://instagram.com/morphoice - 80s inspired Synthwave Music, Arcade & Gameboy homebrew!

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

                    @Morphoice said in Making button flash upon mouseclick AND midi note:

                    @Lindon so you mean Content.getComponentUnderMouse should work?

                    Sorry I was assuming you were using a single panel and drawing the "button" on to it - seems you are using multiple panels...

                    HISE Development for hire.
                    www.channelrobot.com

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

                      @Lindon yes sir but the x/y might actually be a useful tip for calculating the click position on the panel and from there maybe get a velocity value

                      https://instagram.com/morphoice - 80s inspired Synthwave Music, Arcade & Gameboy homebrew!

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

                        @Morphoice said in Making button flash upon mouseclick AND midi note:

                        @Lindon yes sir but the x/y might actually be a useful tip for calculating the click position on the panel and from there maybe get a velocity value

                        yes that would work - remember the Y value increases the further down the screen you go, so you velocity calc might be:

                        (panel height - y position)/(panel height/127)

                        for a full range solution...

                        HISE Development for hire.
                        www.channelrobot.com

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

                        15

                        Online

                        1.7k

                        Users

                        11.9k

                        Topics

                        103.2k

                        Posts