HISE Logo Forum
    • Categories
    • Register
    • Login

    1 Knob for several value

    Scheduled Pinned Locked Moved General Questions
    17 Posts 2 Posters 605 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 d.healey

      I see what you were thinking, but I see why it's not working. Can you tell me why this won't work?

      	if(0)
              { 
      	EQ.setAttribute(EQ.Freq, 20);
      	}
      	
      	if(1)
              { 
      	EQ.setAttribute(EQ.Freq, 40);
      	}
      	
      	if(2)
              { 
      	EQ.setAttribute(EQ.Freq, 60);
      	}
      	
              if(3)
              { 
      	EQ.setAttribute(EQ.Freq, 80);
      	}
      

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

      1 Reply Last reply Reply Quote 0
      • Y
        yall
        last edited by

        @d-healey said in 1 Knob for several value:

        mais je vois pourquoi cela ne fonctionne pas. Pouvez-vous me

        if(Knob1 == 0)
        if(Knob1 == 1)
        .....
        .... ?
        I'm going to get carried away again ^^

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

          @yall

          I'm going to get carried away again ^^

          Hopefully :)

          if(Knob1 == 0)
          if(Knob1 == 1)

          This would (almost) work, but this isn't what you wrote.

          An if statement is always performing a comparison and checking if the value is true (true in this case means not 0).

          So what you wrote

          if (0) will be false
          if (1) will be true
          if (2) will be true
          etc.

          You need to write a comparison instead of just writing a value.

          For example you can take the knob's value which is passed into the callback as the value argument.

          if (value == 0) {}
          if (value == 1) {}
          if (value == 2) {}
          

          Another way you could do this is with a switch statement, and another way is to store the values you want to set in an array and use the knob's value as the array index.

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

          1 Reply Last reply Reply Quote 0
          • Y
            yall
            last edited by

            ah yes I understood, however how now to control the combo box from the knob?
            the values ​​of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vjyqNJ7+vn.ma8jpaKc2AOjI8mtZ9VaE7UUX9+LeyGrtENa1QIYaf6+yegmhZVTm6lFeI06M47v6jk3wwoQ8Ygv3wDUQjADN8H7.m7r1e7wG1tqRPmxz3unEretfecxj+5YJAOZ42HwCNn5Ey98O0iSf.JK3qubvW+1E7qH2+ihTIie9QDXll5Z.DNifGV4SgTOmSC0QUMUyor0Np0JJMhpiRrw+.+xU1oHEnT1oP4WDen6Q7Z+rNBpSx6pk.wMW+rvlXcKCqE8KwXGUmF3YZu12Wct9McPnUiY+M.yi1.LGrAXd7Ff4Ia.lucCv7z0hQ8B4mmJEQY8d.AC8zydLLpToi9W.FpRVgA
            
            1 Reply Last reply Reply Quote 0
            • d.healeyD
              d.healey
              last edited by

              Did you try setting the combobox's value from the knob's callback?

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

              1 Reply Last reply Reply Quote 0
              • Y
                yall
                last edited by

                I tried CB.setValue (1);
                CB.changed ();
                but I am sure it is a beautiful mistake.

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

                  @yall

                  tried CB.setValue (1);

                  Do you want the combobox's value to always be 1?

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

                  1 Reply Last reply Reply Quote 0
                  • Y
                    yall
                    last edited by

                    what did you have against the number 1? ^^
                    no it obviously has to change but I admit that I don't know

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

                      @yall Do you want it to change to the knob's value?

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

                      1 Reply Last reply Reply Quote 0
                      • Y
                        yall
                        last edited by

                        inline function onKnob1Control(component, value)
                        {
                        if(value == 0)
                        {
                        CB.setValue(1);
                        }

                         if(value == 1)
                            { 
                        CB.setValue(2);
                        }
                        

                        };

                        Content.getComponent("Knob1").setControlCallback(onKnob1Control);

                        i understand i know

                        1 Reply Last reply Reply Quote 0
                        • Y
                          yall
                          last edited by

                          @d-healey
                          I just got there, I didn't put the .changed
                          thank you .
                          you won 1 week of vacation with me in the south of France (facing the sea;))

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

                            Well done!

                            I'll show you a slightly more efficient way that will only use one line in the callback

                            CB.setValue(value + 1);

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

                            1 Reply Last reply Reply Quote 0
                            • Y
                              yall
                              last edited by

                              @d-healey said in 1 Knob for several value:

                              CB.setValue(value + 1);

                              i will try now

                              1 Reply Last reply Reply Quote 0
                              • Y
                                yall
                                last edited by

                                even simpler. yet these are things that I see often, I understand them but I don't have the reflex to apply them correctly.

                                thanks a lot

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

                                  @yall said in 1 Knob for several value:

                                  I don't have the reflex to apply them correctly.

                                  It just takes practice. Read lots of code and write lots of code and you'll pick these things up.

                                  One tip, if you find you are writing the same thing multiple times then there is probably a more efficient solution.

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

                                  1 Reply Last reply Reply Quote 0
                                  • Y
                                    yall
                                    last edited by

                                    @d-healey yes I try more and more to write the codes with what I learn rather than doing stupid copy paste. I am creating a github to host my projects in order to sell them with the open license and I will send you all of this. you will surely be surprised for a little beginner Like me ^^

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

                                    9

                                    Online

                                    1.7k

                                    Users

                                    11.8k

                                    Topics

                                    103.2k

                                    Posts