HISE Logo Forum
    • Categories
    • Register
    • Login

    1 Knob for several value

    Scheduled Pinned Locked Moved General Questions
    17 Posts 2 Posters 602 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.
    • Y
      yall
      last edited by

      hello, I would like that my knob can give exact values ​​on a simple equalizer.
      I created this code which compiles but remains stuck on the last values.
      Is there something I missed? thx

      HiseSnippet 1031.3ocuVEsaaaCEkxNrqVctnsne.B4IGfr.ojzrBLLT23XOXzkTmY2h8VGsDULgoHUknxhWP9B1y66Y6o8Irui8GrcIkTjbqQpmAVkgADu2yg5buj2K4nDoOMMUlfrZMYQLEY8k3wKDpY8lQXBzvSPVODeJIUQSbxMc7hXRZJM.YY076zFrZsEx772u3XBmH7oUlPn2JY9zumEwTUVG08ULNe.IfNgEUC8gcG5KE8jbYFnmlXWTLweN4B5YDMrFXj085GvTxjwJhhlhr15XYvhwyj+rHG+aYorobpdfGZLLQ4lGH4AZEqsh5MiwCFUF2oHXVFUkEZlmEdJ9TV.6V6UYiGYb3Twnd9vpwcIOuOs7bWk7rpIusxk2iwi8SXwpJOZs8.7PArPERfkf5xJGKpwu0.2SBHDp8hHyoCRfA2xnyQtt657LW2c9l11ssgEhTkykjDm9m67sNl8D6cAU0OLj5q5rc+y2VCrB1qDxod.xxu.fsmLJVJfAc113c67oV+iI3LA0ILS3qXRgiTXPnImH4c7KYtKL27L5NssutscKVXGW3Umhmqc.a8OeuTp5kJUBaZlh1AFOHg99cc12DIstA9mS0asod3GRc+0l5QKQUy8f0l6yuk6MEIp6LYpmkhDVOBmOEpU5rbdrJe21tVp9Loh9ZQmcru1tk8M1NenqvvU5qXR4zjU5VWKmbWD6HxhlRSJWRKABapWtp4AqWUiedtoFPoXnfodcLsXb8x9xntzqK51fstopXrtUSnsBXUl93xVTwZmt.t.N.UYJeeXQ46XNKflfXfF+BrYgCYxM0afhdyvSHJR4z.yH7UhoIJlNWYcB8RnAadWgV3SnoyUxXC1hsKPG8O4G8JjE1Z.7sVne4OgWRUKzY76Y.fhXAAb5HYJSuhVqi+uCGLDOl8K.TL1aOW.ont3iHWUM79cSyBCYWY5jGx3QoPEP7vHnAOx5I32jRcBngjLtxIcNLOPGh4zfIRCdzG2DDZEKCx3D0x8m0GJU3PK15MB0M6DPPrn9gV+GZZ6t1mortx8w3QLk+rUq2FqPuv9f+u0awQfsw485qD6V3A+3m4y6rK2Y2KK4RZ+2Wni9mujNNKKZ.iCGjkp2+ZAgywDQfaQV6OV7qdc0F7pRiSLF1uvvOEF9WuPa3fkuMiH3vJCOp6fAS5KHP.kG7MWN3atdA+Jx8+fLSwDWbJApGzkhP3LFtBjOER8BAkahpF5VJ4ic0i0RZL0DkXq+AdJb5UlBzN8Jc9Y4aDQ7SjuyOuYmdk79FKPbKLWfqEbSRXrysc4vXWSOi.16780qqekGBsZN6uAbNXC3b3Fv4Ya.mi1.Ne8Fv442IG8cYeYlRFk26ALLpu4zFKqZ6zQ+KPvux7F
      
      1 Reply Last reply Reply Quote 0
      • 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 the combo box are 0 1 2 and 3? for the different lines?

              HiseSnippet 1042.3ocuVEtaaaCDlx1rqVcoHAn+uB9WJ.YFxoocEXXntVQtvnKoNyYAa+piVhNlHRjtRTYwqn.6UYOB8kn8MXOG6MX6HkjkbpqSlAVc.BDu6938cGOdGGFK7oIIhXjQySmOihL9Z7n4b4T2oDFGM3Pjw8wGQRjzXqLQ8lOijjPCPFF0egRfQyFH8u+9Y8HgDtOsTDBclf4S+AVDSVJcX2WxBC6SBnmxhpX8AcG3K3thPQJvm5XGzLh+EjyoGSTlUCiLtiW.SJhGIIRZBxnQOQv7QSE+FOy9yXIrwgT0hNnQvFkItuHLPwXkTj6TVXvvh3NAA6xvxrP8rrvCvGwBXKjWlM1VqvpDQ07gQs0QuN2L8bVE8LpPuFYzaG7H+X1LYoFE2tGd.GNnlPfifpzJyVTs+rF1U.VvksiHWP6GCKVfv9INN6Y8XGmc+tsLK9CNNRjVWRhs7Nw56szUFsOmJ8lLg5Ksa4cRKk4kl8RtXbGvxB+.15JhlI3vB6VZssJbPIJ2deVHt8ZURHFOjwoVSR49RlfaAEK8TvhEg19EX1C1xvT5taY91sLalw8yHgfGVXhxGCjznSoWIsUaeSuSZmPkOWJiYiSkTaXc+X5a1KCaFCdm9+edZp1gb13RBCGC0t1UX35BCch4Fhj0Sf7T6p4P0sWQiJd9Xgj9Jt8tlu0ro46LsttpISVot7MKjFuR0p60wqCnMOMZLMtHBKLDJvW9Fz8tc2f7yxIULTvGvYxWMilutZKfhntPqCZQvVUTYLVUpNzVgYkh9zqvn7yL3xbsbyASk5qx2O+p7nPV.MFw.N9UX8AFRmapzLsK55f2NGLTHLVzSbkFdCrauqic6tneZvgDIQ0OImM.CmQikLUd13P5kPi5rtKMwGRStPJlooadIFPqajvWgLvF8A2MW8wGfOfAGyFw9c.FF2osCJhbUIota2HherXQPsC9Xg0QUEgp396bSgr16uuv6VvGZugMTtiAW2STjeeGyCbLepiYGG3n5SasBM3EAogD4xc8Ui5xU.ExK0dU0BkmvjyqNJ7+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

                                      16

                                      Online

                                      1.7k

                                      Users

                                      11.8k

                                      Topics

                                      102.6k

                                      Posts