HISE Logo Forum
    • Categories
    • Register
    • Login

    Set attribute for sliderPacks

    Scheduled Pinned Locked Moved Scripting
    14 Posts 4 Posters 2.3k 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.
    • Christoph HartC
      Christoph Hart
      last edited by

      The problem is that the setAttribute method internally converts the var to a float number (because the HISE parameter system uses float numbers), so you can't pass an array there.

      Unfortunately, there is not an easy solution to this problem (rewriting the entire HISE parameter system is not an option).

      One possibility would be to create a "SliderPackData" object, which holds the data and can be accessed by multiple SliderPacks. Then you can make this a global variable and synchronise the SliderPacks by assigning them to the same data object:

      // In your main interface script:
      
      // Wrapping this inside this condition makes sure that the object will not 
      // get recreated when you recompile the interface script (it would create another
      // object and the second script would loose the connection because it's not recompiled)
      if(!sharedData)
      {
          global sharedData = Engine.createSliderPackData();
      }
      
      const var Pack1 = Content.addSliderPack();
      Pack1.setData(sharedData);
      
      // In your other script:
      const var Pack2 = Content.addSliderPack();
      Pack2.setData(sharedData);
      
      1 Reply Last reply Reply Quote 1
      • d.healeyD
        d.healey
        last edited by

        I think this would only work if you want to use a sliderPack to control a sliderPack but what about if you want to control the sliderPack with other controls, will it still work?

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

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

          If I add a SliderPackData.setValueAt() (the equivalent to the SliderPack`s method), then it should work.

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

            Alright, I've just committed this:

            // Checks if the object is already created (to prevent deleting on recompiling)
            if(!globalPack)
            {
                // Creates an slider pack data.
                global globalPack = Engine.createSliderPackData();
            }
            
            // This can be used in multiple scripts like this
            const var SliderPack = Content.addSliderPack("SliderPack", 0, 0);
            SliderPack.referToData(globalPack);
            

            Grep the autocomplete menu for a list of all methods available for the SliderPackData object and let me know how it works.

            Bonuslevel: right click on the entry in the ScriptWatchTable and it will open a popup with a slider pack for editing / viewing:

            edit

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

              Thanks Christoph, looks excellent

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

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

                @d-healey @Christoph-Hart Hey guys, any idea how I would save SliderPackData to a string / file so I can save and load shapes? I've tried the below but no joy (file saves but there's no string, just: {
                "sliderPackData": ""
                }
                in the saved file).

                    inline function getControlValues3() {
                        return {
                            "sliderPackData": tableProcessor3.exportAsBase64(0)
                        };
                    }
                    
                    inline function setControlValues3(data) {
                        tableProcessor3.restoreFromBase64(0, data.sliderPackData);
                    }
                }
                

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

                ustkU 1 Reply Last reply Reply Quote 0
                • ustkU
                  ustk @DanH
                  last edited by ustk

                  @DanH Apparently you don't update the object properly before writing the file

                  data.sliderPackData = tableProcessor3.exportAsBase64(0)
                  

                  Can't help pressing F5 in the forum...

                  DanHD 1 Reply Last reply Reply Quote 0
                  • DanHD
                    DanH @ustk
                    last edited by

                    @ustk Thanks mate. Just to put this into some context, I'm using @Lunacy-Audio's custom preset browser for this, and it's all working perfectly for my Tables. I think maybe one problem is in a previous line:

                    const var tableProcessor3 = Synth.getTableProcessor("STEPPER1");
                    

                    This works perfectly for acual tables, but not for a SliderPack. I don't know what I can replace '.getTableProcessor' with....

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

                    ustkU 1 Reply Last reply Reply Quote 0
                    • ustkU
                      ustk @DanH
                      last edited by ustk

                      @DanH Oh I haven't paid attention to the table vs sliderpack thing...
                      For a sliderpack, I think you have to manually save the values with a loop, unless there's another way I'm not aware of...
                      Afaik there's no sliderpackProcessor

                      const var SliderPack1 = Content.getComponent("SliderPack1");
                      
                      const var spData = {"data":[]};
                      
                      
                      inline function savedSpState()
                      {
                          spData.data.clear();
                          
                          for (i = 0; i < SliderPack1.getNumSliders(); i++)
                          {
                              spData.data.push(SliderPack1.getSliderValueAt(i));
                          }
                      }
                      savedSpState();
                      

                      Can't help pressing F5 in the forum...

                      DanHD 1 Reply Last reply Reply Quote 0
                      • DanHD
                        DanH @ustk
                        last edited by

                        @ustk Will give this a shot, 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

                        18

                        Online

                        1.7k

                        Users

                        11.8k

                        Topics

                        103.2k

                        Posts