Set attribute for sliderPacks



  • How do I set the value of a slider pack slider from another script?


  • administrators

    Actually there isn't. Pretty weird, but I didn't need that function yet, because I am always connecting the slider packs directly to the modules, however this only works for hardcoded modules which have SliderPacks.

    I'll think about something.



  • Ok great, basically I'm making a front interface for my mic mixer module and just realised I couldn't control the slider packs :) could also do with middlePosition and defaultValue properties for slider packs if possible.

    How about passing an array as the second parameter for setAttribute() to set the relevant slider index and value?



  • Little bump :)


  • administrators

    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);
    


  • 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?


  • administrators

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


  • administrators

    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



  • Thanks Christoph, looks excellent


Log in to reply

Looks like your connection to Set attribute for sliderPacks was lost, please wait while we try to reconnect.