HISE Logo Forum
    • Categories
    • Register
    • Login

    Syntax for Setting and Getting Array Data From a Panel

    Scheduled Pinned Locked Moved Scripting
    26 Posts 5 Posters 987 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 @aaronventure
      last edited by

      @aaronventure I set up a condition, if the panels value is not an "object", I set the min and max value in the its callback like this

      inline function onRangeSliderControl(component, value)
      {
      	if (typeof value != "object")
      		component.setValue({"min": component.get("min"), "max": component.get("max")});
      };
      
      Content.getComponent("RangeSlider").setControlCallback(onRangeSliderControl);
      

      You can take a look how I usually do it in the snippet below.

      HiseSnippet 1494.3ocsW02SaaDF2FvaKYqSqR6u1ecKSZxoDLgVVaEcrx6crwKQjttNUUUcXew9FN2EYeI.pkOK66T+jrO.SZ644N63KPnBgVif.2yq+dd67i6jICY44xLG2ZO+7ALG2uvq64BUxlITtvY2sbb+RuinhXFoaJOhk4rw4Cn44rHGW2YeFJias4bze96mtAMkJBYUjbbdgjGx1i2mqpn1YsekmltCMh8bdeKoWdscCkhMkoxg.dl0qsy.Z3IzX1ATTrY7bb+jsi3JYVWEUwxcbmaCYz4cSjmJLx+BdN+3TFdXImtfgLj2QlFgHFo5rYBOMpSYbm6.VoSUVXVSV3q81mGwGSuJa7UZFjJMryGtyLI7lcB3sjM7ZaAuo.IWKHMmAR20qaXFefphChmO2aWghk0iBocanXj0Yl+4S81TBRHTA8omv1ICNLVC+G1tcKB7UymTu9hKV6n0O3YaS5t2tas8QjNqev16Uaga1m5PgKWQzcJcNhrJo2PQnhKE9wMq+150FQyHTfrJgmGDyT6ICooaHGJhx8QuWyHRetvRH+Fv4FHWMO5YSxidllWgpirX9BZ5PleohY512U0FXAzE1t6k.C5qt+qWTK087GE.DW.90xsSQF5YExTuVbPNSYZZ8qP2wwFRMZhFJNnGzweDFurniXgJvPoL+WAYe3Gz132O30KtL7OE4Ca6Z9S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FgVjOFXr3EDti2185AWRUAv4714kebda.GycywvSPx3P806fg86BsBgLv6Bn8EmrcmAmAMmaimwLPWlHRe.6XJXtDd1sf4RkLgNmvL4aBMSt3qf7YZJ.lD529pl293YxRkSqddv.oSe3sgdSXHF9K.WKLcct+sPmGbKzY4agN+vsPmGdKz4Q2Bcd7GTG7EQWeHrVoYb.HzYa8cittaKnPmktKz4+PbII4v
      

      rangeslider.gif

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

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

        @ulrik what‘s the benefit of using the min / max properties? I usually just call setValue with an array of two numbers and call it a day.

        ulrikU A 2 Replies Last reply Reply Quote 0
        • ulrikU
          ulrik @Christoph Hart
          last edited by

          @Christoph-Hart that I'm using an object instead of an array? I guess it's just old habits

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

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

            @ulrik Isn't accessing an object property slower?

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

              @aaronventure I've never thought about that, maybe you're right.

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

              1 Reply Last reply Reply Quote 0
              • A
                aaronventure @Christoph Hart
                last edited by

                @Christoph-Hart how to set an array, then? How to specify which element I'm setting? setValue only expects one parameter.

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

                  @aaronventure that parameter can be an array or an object (the only illegal type is string because that can cause weird number conversion issues).

                  ulrikU A 2 Replies Last reply Reply Quote 0
                  • ulrikU
                    ulrik @Christoph Hart
                    last edited by

                    @Christoph-Hart @aaronventure Would this be a better implementation?
                    I store the min, max and range properties at init (so no more looking at properties at runtime)

                    HiseSnippet 1600.3ocsWstSabDEdWfsJ1sQpQp+p+Z59ip0EXw1gP.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aEVbF6tbxATYOe5YYFK+7vOpAd9VhZjKZBqy0Uy2e2dIVSqsZaXtG09WEC8fYmSGplybmidt.7Fm7LISK7qxMzKyOVTui0HITQVtdLeAH5vESRubNXNIDyuJhX9k1qQJtBHBY98GjHfAdtF5fr3pFiwZj1nqgSXjbAyK+jcPsOSqCP13Vz33yf6p8J3+n6pVkKhAaGWIPRDFFiXJMI1Kn.PyoqiUUJpz.bsWRW8jjuCRAIm8GvAct4r3X7JD7RAX+M1G5hYUtZ0RcnWNAcfrtRmx4yJpH+nxCsHpboRyVnSfeqxW5QyqkpfGLyIpgv7md83bjNuifE1rYIwL+AoX5RYS4ghqduJn4P.4DyvOfDo93MUrcbZYRAdUJxH0bXhjcjvSE9qdcUxmKpa2IJK2awrzIJF6vK89LzSLr+YrTyjOpHz1yM6kx4t6kxrUu.c.xPwDwdBt7nALwc0.nUdTE66JGUfpRUWWOsnqKpfEawCwYLhkVJTaY+FmeoyQGVvap6WeLuoY855gETmwSLl4r7KTSrxRvWmdsk0ut21vgOEnA.F.1ArTIGiC1ayFAsTq6Irhy1rrykICT5lyGft3eXX+xxVu+80uxbvE3s.kSvWuGiG0ynE9eZ8x1UvlPWtwJMZ1b4UV1BnbIWTP7.79sNagWTjMG4mU2q88jsgahhfNJrJuyEe3whMWYwUV5kMW4EJAnWU8i1pU+LKHVNdwW+OWOiNBZYncJC35vVeJqa2tLzndR3vXp7lcuiOYIW.PCuQKyXawhLt7Jymz7eVK8OTH9Lm1bYPuIiwol.FAdx+GXL+gPO0YmtcgScKA3LN699+ed0ik9xlH3lwTNjucNbX+N.6HfAqt.3v3w.PxFMUMtNNFi.cXhP0f+A9jKrAN1NWXiBg.SJHM4CA5xb7oVOQMCfIg5UlUbN.GSZTTZ63.kkV8gW88gf.b6OObFxjso4ivlm+HrYwGgMu3QXyROBad4ivlkuWavGbuwPnUac4.LQ6cTGPZauifBLKEKz5eAieFzFA
                    

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

                    A 1 Reply Last reply Reply Quote 0
                    • A
                      aaronventure @Christoph Hart
                      last edited by

                      @Christoph-Hart Alright, so what does it look like?

                      I feel like I'm miscommunicating this -- I can't figure out how to write these two lines of code.

                      What's the syntax for storing an array in a panel with .setValue(), and for getting it?

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

                        @ulrik Sure? I mean, the other one also only gets executed once perhaps, at the very first run while it's undefined.

                        This is what I was referring to:
                        https://youtu.be/fV9hOZrNO_g?t=1360

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

                          @aaronventure said in Syntax for Setting and Getting Array Data From a Panel:

                          I have a panel that I want to use to create a horizontal range slider.

                          Why not use the built in range slider?

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

                          ulrikU 1 Reply Last reply Reply Quote 0
                          • ulrikU
                            ulrik @d.healey
                            last edited by

                            @d-healey said in Syntax for Setting and Getting Array Data From a Panel:

                            @aaronventure said in Syntax for Setting and Getting Array Data From a Panel:

                            I have a panel that I want to use to create a horizontal range slider.

                            Why not use the built in range slider?

                            Is it not broken?

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

                            Christoph HartC d.healeyD 2 Replies Last reply Reply Quote 0
                            • Christoph HartC
                              Christoph Hart @ulrik
                              last edited by

                              What's the syntax for storing an array in a panel with .setValue(), and for getting it?

                              setValue([0.5, 0.8]);
                              min = getValue()[0]; // case that panel is not initialised needs to be handled too though...
                              
                              A 1 Reply Last reply Reply Quote 1
                              • d.healeyD
                                d.healey @ulrik
                                last edited by d.healey

                                @ulrik said in Syntax for Setting and Getting Array Data From a Panel:

                                Is it not broken?

                                I never used it. But I just tried it and seems to be broken. I suggest we nag Christoph to fix it instead of hacking a panel (unless you need the panel method for some particular reason). :)

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

                                A 1 Reply Last reply Reply Quote 1
                                • A
                                  aaronventure @d.healey
                                  last edited by

                                  @d-healey The default controls don't let me define custom modifier behavior (ctrl, alt, shift), don't have the useful .data functionality and don't have the mouse callback.

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

                                    @aaronventure said in Syntax for Setting and Getting Array Data From a Panel:

                                    define custom modifier behavior (ctrl, alt, shift), don't have the useful .data functionality and don't have the mouse callback.

                                    Broadcaster would solve those issues I think (well not the data one).

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

                                    A 2 Replies Last reply Reply Quote 1
                                    • A
                                      aaronventure @d.healey
                                      last edited by

                                      @d-healey True, but I still can't disable built-in modifier behavior.

                                      1 Reply Last reply Reply Quote 0
                                      • A
                                        aaronventure @Christoph Hart
                                        last edited by

                                        @Christoph-Hart Thanks.

                                        Is there a way to set only one element, or do I have to be defining all elements every time I'm setting the value?

                                        Is this done by setting these value somewhere else, like a local var which is an array

                                        local tempVal = [];
                                        

                                        and then passing the array itself every time I setValue

                                        setValue(tempVal);
                                        

                                        ?

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

                                          local v = this.getValue();
                                          v[1] = "New Value";
                                          
                                          // technically this is not required because the value is already == v
                                          this.setValue(v); 
                                          
                                          // this will fire the notification that the value has changed.
                                          this.changed();
                                          A 1 Reply Last reply Reply Quote 2
                                          • A
                                            aaronventure @Christoph Hart
                                            last edited by

                                            @Christoph-Hart

                                            Got it working. Thanks.

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

                                            20

                                            Online

                                            1.8k

                                            Users

                                            12.0k

                                            Topics

                                            104.4k

                                            Posts