HISE Logo Forum
    • Categories
    • Register
    • Login

    Adding a second action to a button

    Scheduled Pinned Locked Moved General Questions
    14 Posts 4 Posters 113 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.
    • pcs800P
      pcs800
      last edited by

      I have a button which enables/disables the compressor in my project.
      It was reuested that I add a makeup gain to the compressor, so I just added a simplegain to it. The problem is that the simplegain does not get enabled/disabled with the button.
      Can I use code to assign that second action to the button?
      comp btn.png

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

        @pcs800 said in Adding a second action to a button:

        Can I use code to assign that second action to the button?

        Yes, for this you need to use a control callback.

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

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

          @d-healey Such as this?

          // Assign this script to the control callback of the compToggle button

          const compressor = Synth.getEffect("Dynamics1");
          const gain = Synth.getEffect("simplegain1");

          inline function oncompToggleControl(component, value)
          {
          // This sets the compressor enabled state (already mapped in HISE)
          compressor.setAttribute(0, value); // Attribute 0 is usually "Enabled" or "Bypass", double check

          // Now also toggle the gain module
          gain.setAttribute(0, value); // Again, Attribute 0 is usually Bypass/Enabled
          

          }

          // Attach the control callback to the button
          const compToggle = Content.getComponent("compToggle");
          compToggle.setControlCallback(oncompToggleControl);

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

            @pcs800 This smells like AI? It's pretty close actually.

            Don't use magic numbers, like attribute 0. Use the built in constants instead - you can find these by right-clicking on the module's header and selecting Dump parameter IDs and values.

            However for changing the bypass state you don't use setAttribute. Instead use setBypassed.

            @pcs800 said in Adding a second action to a button:

            (already mapped in HISE)

            You can have either processor/parameter ID or a control callback, not both. So in your case you need to remove the assignment in the interface designer and do it all through the control callback.

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

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

              @d-healey Yes Ai is what I am using to try teaching myself and getting code. The problem with it, is it usually gives wrong answers for an hour until i provide enough error feedback for it to get something right.

              pcs800P 1 Reply Last reply Reply Quote 0
              • pcs800P
                pcs800 @pcs800
                last edited by pcs800

                @pcs800
                Doing the parameter dump, I see this.
                2025-05-18_091909.png

                So I would use:
                {
                // This sets the compressor enabled state (already mapped in HISE)
                compressor.ssetBypassed(0, value);

                // Now also toggle the gain module
                gain.setBypassed(0.00, value);
                }
                ?

                pcs800P Christoph HartC d.healeyD 3 Replies Last reply Reply Quote 0
                • pcs800P
                  pcs800 @pcs800
                  last edited by

                  @pcs800 Or
                  gain.setBypassed("Gain", 0.00); ?

                  1 Reply Last reply Reply Quote 0
                  • Christoph HartC
                    Christoph Hart @pcs800
                    last edited by

                    @pcs800 please don‘t post AI code here - it poisons the code quality in the forum.

                    You can obviously use AI for yourself but typing something into ChatGPT and then paste in here here for DaveGPT to correct it is super lazy.

                    pcs800P 1 Reply Last reply Reply Quote 0
                    • pcs800P
                      pcs800 @Christoph Hart
                      last edited by

                      @Christoph-Hart
                      I'm just trying to learn without bothering everyone here too much

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

                        @pcs800 said in Adding a second action to a button:

                        I'm just trying to learn without bothering everyone here too much

                        AI is not a good teacher. A good teacher will tell you when you made a mistake, but with AI you have to tell it when it made a mistake - but that makes you the teacher...

                        AI is great for improving your workflow once you're able to spot and correct its mistakes. It can also guide you down a path of investigation so that you have some idea of which part of the documentation you need to be reading.

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

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

                          @pcs800 said in Adding a second action to a button:

                          Doing the parameter dump, I see this.

                          This is only useful for setAttribute. As I say you don't need to use this function for this task and should use setBypassed instead. The documentation in the API browser should help you here, it just takes one parameter.

                          59800617-5c41-4cec-9581-ebf4684fa0c4-image.png

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

                          pcs800P 1 Reply Last reply Reply Quote 0
                          • A
                            aaronventure
                            last edited by

                            HISE will remain outside of AI scope for some time because there's just not enough training data out there, and it's not entirely code-based.

                            However if you're adamant on using it, you NEED to feed the docs into the context.

                            RAG is not very good here.

                            Instead, I recommend you use the Context7 MCP, so you'll need to use an AI tool that lets you use MCP tools.

                            The IDE-based ones all do, but so does Claude Desktop (as Anthropic were the ones to come up with the protocol), which is much nicer to work with in this particular case because you can set up projects with custom instructions and knowledge. Get Claude Desktop, create a project, describe what you're doing, and in the project instructions explicitly mention you're working in HISE and that it should use Context7 to always get the docs because there's not enough training data. Update the project knowledge as you go along and as you learn which stuff makes the LLM trip up.

                            It would be better to use it to chat about HISE, sampling, VI paradigms and DSP using Context7 as a doc tool for HISE instead of letting it write your code, as a big part of the HISE dev workflow is not really code-based. So I'm not encouraging it, but if you're gonna do it anyway, no one can stop you, so I'm letting you know about the best way to do it that I've found, and actually getting something useful and concurrent out of it.

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

                              @d-healey
                              I've got it working now, thanks

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

                                @pcs800 Nice!

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

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

                                21

                                Online

                                1.7k

                                Users

                                11.8k

                                Topics

                                102.6k

                                Posts