HISE Logo Forum
    • Categories
    • Register
    • Login

    Prevent Slider Value Going Negative

    Scheduled Pinned Locked Moved General Questions
    7 Posts 3 Posters 346 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.
    • DanHD
      DanH
      last edited by DanH

      My brain is on vacation.... With my weird system of Knobs controlling each other Knob2 ends up having negative values (despite the min value being set to 0). I need to stop the value at 0. Any ideas?!

      If you open the snippet and yank Knob 1 from one side to the other you will see Knob 2's value printed in the console.

      HiseSnippet 1031.3ocsV0raabCDlqr2jH0lfFf9.PjKUBvUP+0j.DDTUKaGnlXG0JWibn.AT6RokvbIWrjxNBsAvOJ4QHG56S68dIuAsCIWYsajprk.pNHryOeC+lgbFxAox.pRISQdkOcVBE48k9CmIzQ8hHLAp+AHuG3eLQoooXmp8mkPTJZHxyamWXT3UdWj82m998IbhHftPEBcljEPeEKloWncP2Wx37iHgzSYw47tS29ARQOIWNE3yN9MPIjfyISnmPLtUxG4cmCCYZY5PMQSUHuc2WFNaXj7Rgy+yXJ1HN0HzDMDBjS8QRdngwFsndQLd3f44sBAQYvhpvNtpvW6eLKjcs9EUiuxZ.u.Q95gWohzamBzq4+E8VAk7xQoccT5g9CCRYI5EVL74K76KfMmwDnrmmJNeQkzk76IAOD55wjyoGkBBWin5iazXOL7WsmUoBT5UZ7EjT7KExQMwOGOG3DptmLNQJ.gpOxZ8Q.hh.ZsV.sVFP60Bn8x.5rV.cL.pvDblfhGOUDnYRAVJrz0.KUxqFLGydPT4So0p7aUJaQWWQ0mYTU0Y.hk0PqEFb9MYtXM725xibp.XkqTFVMkjSqmjx.14hRAedOD80VbMKZFm6Q37QPaP0hohgf4xxSjZ5qEUs4Sk2WA+4lFOdk1xBFmltRyl1yz0ArpXZ7HZZ9powQ3LawFg6b6ZDBb0jbNJE8EL8qSnYxquSFkUTM8zYLDbUaaedPV6yPNKjlhXPPtqushhrjO+bLzsFbqBfu5u+o+ZC.2t3JW6W+yM.bmUP6eo+ADMwL9HqP.EmDZplY1C7NfdALK1MLor+AT04ZYBr2b8wOnpci0p2g7789HrbyLe7Ijsneqw2xg+Oli+G81L7sM3yR3qF2c10BeXV2MINcb7328r7X0w3ttXb+rX7JxHJ2Fh64a+tYNtfxGmqHcujEpiLqvaJgPQT1jHsQpJXUSeG7MyRCbSbfa+VYGkfa8MJWqD9xHVPDlovvj.LQgcSelOxo1d3QS03rXP3J4mEnNyCDZSRoVKkRt8paLcdg+oQ.WSx3zhz.F.JwB5DhlcA0oSUGi6iujHzXlFClUvwPLQiaTGdZvRW6AW3JCmxI5h2Bad5QlAXhTgq9LWuITL8r78FavUyMV6Uy2VJ9P+ALcPzp4XoUvQns8+CNl8fl66e33wz.8BBtq+QuYae8xMr7+rbplIlbLQmxLMZmLMdH7lt.Jr5BAkqLmdJYZ8cxMLxlJvPpHzJ7OvuLiMMxdYFaN2HJlDjJe67S8Pw6dVM.mD1WKVFd1JHiWZ7NBECuf6sAAEC0R.ass.aus.6rs.+tsE3i2VfOYaA9zaFn4A1+vTsL101fPGO3P68ZddGJHvIP6oUz+B7XSHt.
      

      DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
      https://dhplugins.com/ | https://dcbreaks.com/
      London, UK

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

        You can cap it using Math.max()

        Knob2.setValue(Math.max(component.get("min"), Knob4.getValue() - Knob3.getValue()));

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

        clevername27C DanHD 2 Replies Last reply Reply Quote 1
        • clevername27C
          clevername27 @d.healey
          last edited by

          @d-healey Does that stop the slider from moving?

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

            @clevername27 Not in Dan's scenario because this goes in the callback for Knob1

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

            clevername27C 1 Reply Last reply Reply Quote 1
            • clevername27C
              clevername27 @d.healey
              last edited by clevername27

              @d-healey Understood - thank you. I think what I'm asking would simply be done in my own paint routine for knob. (Maybe I could stash the limits into the tooltip or something. If it was Panel, I could just use the data extension.);

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

                @clevername27 Why not use LAF instead of a panel?

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

                1 Reply Last reply Reply Quote 0
                • DanHD
                  DanH @d.healey
                  last edited by

                  @d-healey said in Prevent Slider Value Going Negative:

                  You can cap it using Math.max()

                  Knob2.setValue(Math.max(component.get("min"), Knob4.getValue() - Knob3.getValue()));

                  Ah yes, great idea! Thank you!

                  DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                  https://dhplugins.com/ | https://dcbreaks.com/
                  London, UK

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

                  32

                  Online

                  1.7k

                  Users

                  11.8k

                  Topics

                  102.7k

                  Posts