Storing data in widgets



  • i have read a topic here in the forum about storing data arrays in widgets with saveInPreset enabled, but somehow i don't understand the concept behind. could someone please point me in the right direction with a really simple example?
    what i want to know is:

    1. how can i save data in an array within a widget like for example a Panel, where "index" is a variable for the array index (controlled by a combobox for example) and "value" for ... yeah, you guessed it - the value to store (by a knob for example)? i tried this, but seemed not to work.
    Panel.setValue([index[value]]);
    
    1. how can i then recall the values in the array at a specific index using a simple Console.print function like this (which of course also didn't work):
    Console.print(Panel.getValue([index[value]]));
    

    here's a snippet of what i mean:

    HiseSnippet 955.3ocwVEtaaaCDlx1rKVcdnEXO.B8W1.sA1IYManXnZwNYvqKIBScACHMHfVh1lHRjBTTYwnn.6QYOJ6MYuB6MX6HkjkbZbZfAJlBfQNd22G+3o6NJOoHfllJjHq1ucQBEY8kX+Eb07gyILNZ7HjUGrmjlRUWpnoJzAKRHoozPjkUyeTGhU6VHyy+75CHQDd.sZID5LAKf9yrXlpZUO22vhhNhDReKKtVz64NNPvGJhDYfbZh6iRHAWQlQOgnCqAFY8nCCYJgzWQ.wfrZcfHbg+bwuyyi+LVJaRDUaL.4CDku7QhnPsh0qhFNmEE5UdrSQ.KdUIgl4IguFeLKjsb8pjwSLNbpPTOeX039j2f5xq+CWdV0jWqb48Trefjknp7n01iwi4JpbJAdETWV4whZbcC7PADAWscL4J5QRvXIht68c67bmA6ueuW0wFdMjpbtlHc7HbZz.mu2oD4LpZnHNQvAitOK28yVEC3eh3.wMqG1xHtEx2vESVOJi2agXLOjdiAQAiZLmQhxnc68hAPnU+w3QLN0YZFOPwDbGA2PndujhntAkazyAhA785X+9N1NvS9u4G0sSKo+byVetI1KtPqpOX1t6U6Z3Ea3PRTzDn9t6p5n2RMCKjJhnamHY.CEa+r0r88dUsy0IBE8Td2d1u2ts8GrctsqoSuSeEJHhJuS25lU48ArKOKdBUVl+JCDpZWss.u91h5csA4IxZAJ3i4L0oIT95ZVPEYensoYgpf+SYZZ5T1znyjHFzZrENOqhLBV2V8S9mdx4YPlcJTpDdQNe0I4qJHwOhERkFV9Br48WII4Sy58t+90eD3mT.trX0.+w3k0tqRABskK5WGOhnH5o.EmL3zlPkJlNQZMhdMLdMelPa7HZ5UJQh4nWT3AI6O4g+lka3eLxcwRi+5ctojqoi44S+gcqApFus9j4iJdc8pwKZW2577nGXpohs+bVM1b8ciIfOrUSvhonwo5o2IRpy.a8u6X9cWa3ZmOZLJLLWDlEQTqNgWesVgCn9dkQo5wk7TlZQ8q89rL1+gJ2mh8Xpf42sda7+idKtDsC9voSoApJw1Bezu84+FSzuHxTL9riIJISWabRVrO7MEATPIbnlWOCBpl0PM18015biOkGZL9W3ov4.ssUgyAkNQwj.o3xf7Nb80zaYVAzD270JswGqscV1Tiw82tOJF95gKCBzohW.Z+twryFfY2M.yda.luYCv7xM.y9a.lu8dwn+vseHSIhyaSfE7NzLb0x5PNApxLUjn+C707.SB
    


  • @toxonic Ok heres a little code element we can look at:---

    function sampleHoldSelectorPanelFunction(event) 
    {
        
        if (event.clicked)
        {
            this.setValue(1 - this.getValue());
            this.repaint();
        };
      
        if (event.doubleClick)
        {        
             //set the panel up properly..
             SampleHoldPanel.set("x", editPanelXPositions[this.data.panelX]);
             SampleHoldPanel.set("y", this.data.panelY);
             SampleHoldDepth.setValue(this.data.target.getIntensity());
             SampleHoldSpeed.setValue(this.data.target.getAttribute(this.data.target.Frequency));
             SampleHoldSmoothing.setValue(this.data.target.getAttribute(this.data.target.SmoothingTime));
             
    

    So its the first few lines of a function defined for a panel(or set of panels) by using the OnMouseCallback

    so everywhere it says "this" it means the panel

    in the On Clicked you can see it recalling and resetting some Value this.getValue() and this.setValue()

    here you can see it just using a really simple single integer value but you can save any javascript variable in here I think - so you could save an array if you wished

    The important thing about this "value" is that it is saved in any preset, as long as you have saveInPreset = true for the panel

    Later in the doubleClick code you will see it referencing a whole bunch of other "data" held in the panel:

    this.data.someNameHere = someVarHere;

    so you can set up quite complex "containers" of data inside the panel - here I'm using some simple int values (x and y positions) but also some fairly complex things like a Synth or effect:

    this.data.target

    (NOTE: I just decided to call it "target" you can call it whatever you want...)

    BUT: these DONT get saved in your presets no way no how.

    Does this help?



  • @Lindon
    thank you for your efforts, but i'm afraid, i'm too much noob or simply too dumb to understand, what is going on there... but i don't really know where to begin. 😕 i thought, this might be not such a big task....

    So its the first few lines of a function defined for a panel(or set of panels) by using the OnMouseCallback

    so everywhere it says "this" it means the panel

    ok, at least i know now, what "this" means, but how did you define the function for the panel? and how can then "this" refer to that panel? maybe my second question would already be answerd by the answer to question 1.
    the this.getValue() and this.setValue() are clear so far, but how can i save values at a given index with this method?

    here you can see it just using a really simple single integer value but you can save any javascript variable in here I think - so you could save an array if you wished

    and that's, what i don't know how to do.

    this.data.someNameHere = someVarHere;

    so, i could also store arrays in this data member object? the same problem here - how to index that? this here....

    Content.makeFrontInterface(300, 100);
    const var Panel1 = Content.getComponent("Panel1");       //Panel to store Values in
    const var Value_1 = Content.getComponent("Value_1");      //Knob
    const var Preset = Content.getComponent("Preset");        //ComboBox
    
    //  i want the values from the slider to be stored in the panel
    inline function onValue_1Control(component, value)
    {
        var index = Preset.getValue() - 1;         //index from Preset ComboBox (zero-based)
    	Panel1.data.values[index] = value;     //doesn't work                       
    };                         
    Content.getComponent("Value_1").setControlCallback(onValue_1Control);
    

    ... won't work.
    sorry, as i already introduced - i guess, thats simply a huge lack of knowledge and experience, and if to much to explain to a newbie like me, maybe you could point me to a tutorial regarding this topic? i have read the forum thread https://forum.hise.audio/topic/52/variable-persistence but i have to confess, i don't understand just half of it! 😞



  • @toxonic

    okay, after hours of ripping off my hair, i finally got it managed to get it working for 5 presets for a knob.
    but although i have set the Panel to saveInPreset, the values are not persistent after relaunching HISE. any ideas?
    here's a snippet:

    HiseSnippet 1062.3ocsV80aaaCDmJNrsVcdnEnO0GFD5SN.oAR9+ACE0MNICdYIwXtKn.AAFzxzwbQhzPhNyFE8w88ZeT166k8MX6HkjkriiSfABeR7t62oe2wi2wNABWZXnH.Yj+yyFSQFeGt6LtbTqQDF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XA5WESjL90mRjALUIwYS76BO8xkBLgCknpdZPwmBpdusZuJyzkxGn27evJVoiZuQrRmDkHehafnmazEa0qYdgVBvIt9Qc4wmp1aM+tLFaumMxGdjUOWWUp38.2WMlRa.lxa.lJa.lpa.lZa.l5a.lFqEi58seZhT3GcMADz4HcOUCii3DnJSWQh9efqPiUr�
    


  • okay, slowly i'm getting into this thread:
    https://forum.hise.audio/topic/52/variable-persistence
    but somehow, i seem to miss something. i understand now, that i have to reacall the values, stored persistently inside a panel, within the onControl Callback. i tried to load the values into an array and print them out via console, but they are still the initial array values.

    function onControl(number, value)
    {
        if (number == Panel1)
        {
            array = Panel1.getValue();     //assign values to array
                Console.print("data loaded into array");
    
    // check loaded values -> BUT GET INITIAL VALUES OF ARRAY!? 
                 for (i=0;i<5;i++)
                {
                    var printval = array[i];
                    Console.print("array index " + i + ": " + printval);
                }
        }
    }
    

    another question: does it make a difference, if i use a panel, that i created with the interface designer and enabled it's property "saveInPreset" there, instead of creating it via script like this? and what do the both "0" define?

    var Panel = Content.addPanel("Panel", 0, 0); 
    Panel.set("saveInPreset", true);
    

    Here's a snippet, what i've got so far:

    HiseSnippet 1145.3ocsV80SajCD2a.2ir83Tqz8TexhmRD+QYoj1RygZJA3TNNfnK8PsBghL65.VrqcztNzDg3CRe69ncuduceCtar2cytIDBUQBiRH1y7yyuY73wSqPoKKJRFhrJ9og8XHqeD2dnPcUiqnbAp4dHqWgaqjgrNsBYQLUmlhNsnBlemJNncG1iFEw7PVVK7qZ8sJtHxL92OrK0mJbYYKgPmJ4tremGvUYq1p9gbe+CndrOwCxo8V0a5JEMj9x9.2V.WA0i5dM8R1wTsZEvHqmsuGGXVaEUwhPVKtqzaX6qjeUDq+o7H9E9L8DGTaXihW9.oumlw5UQMth660JMFDgfcoUVDYg3HxOiOh6wGsdVj4EFAjLD4iGVElE8bxSuJe+zyJG8VLlduD21Mj2SkIQysmiaJTrvtT3HHOsh0EU3KKhaHAMDpMBnWyNHDlLBQopa4rFwo5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
    

    thanks in advance! 🙂



  • What's the end goal here? Are you trying to store the values of knobs in a panel?



  • @d-healey
    Yes, thats it. I know, i could use the sliderpack too, but i'm interested in using panels as storage objects, mainly to learn more about storing data in widgets in general.



  • My next question. Why do you want to store knob values in panels? They are stored in presets by default anyway.



  • @d-healey
    Yeah, but as far as i know, only a single value. I want to store an array of different values and recall these values according to a "preset" called by a ComboBox.



  • @toxonic Each preset can have a different value, so if you want to store multiple values you just need to use multiple presets.



  • @d-healey
    You mean each HISE preset? to clearify: in the end, i want to store different sets of start and end points of a Sample Loop an recall these on demand, in order to get different ranges of the loop to rearrange it. Finally i'd like to export a plugin.

    edit: regarding the fact, that HISE' native file format is called "preset", my choice of words might be a bit confusing. maybe i should call it "snapshots" or whatever.



  • all right, i know now, what i've done wrong. in the custom onControl callback for the knob, i did overwrite the values in the panel with the initial values of the array. i made a workaround, using a "Snapshot" button to store all values in the panel.

    HiseSnippet 1257.3ocsW0saaaCElJIbM1cdnEnWMrKH5U1.owRNw4GXDTu3jL30kDu4thBzEXvHQGSDIRCI5jXTzK2a1dA1ywtYuAaGRIYI6ZGGDfnfXYd9SeeGd3QG2IT5xhhjgHqBue7PFx5awcGKTCZMfxEn1Ggr9dbWkLj0qSHKho50VzqCUv76Y6fNb7PZTDyCYYs5Oos2pvZHy0+91Co9TgKKSDB8AI2k8K7.tJSZmlui66eB0i8ddPNq2tYaWonkzWNBv1pXazPp60zqXmQ0lsBFY8MG6wAj0UQUrHj0ZGJ8F2cf7VQr8efGwuzmoW3f5BAJV7IReOMh0RQsFv885jlChPPT5jkQVMNi7J7obO9D4YYlWXTPx7He9vZk6CdN4gm8CGdV4f2Zwv6k3ttg7gpLMZr8bbaghE1mBaA4gUrsnU9q0vsjfEB0lAzqYmDBKl3Q4Z0s2f3XaWoQohv1PjhbCMjzRFbo7P4cNjCHoNeESAhGJEvhxudhEudZOemPd4h8xncFOL0XK1kX0y3SWAcXz.oZgdkZfwOsGzvP5Xv7OYuY8Ml4+KZPpV0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7wDPPmiMuEvx5XAEpxLUjn+GPaAUA5�
    


  • Yes unfortunately the HISE project file (.hip) is also called a preset which is confusing. I'm referring to the user presets and the preset browser. This is where every widget, including panels, have their data stored. So if you are just wanting to store the values of knobs I'd use the preset system. Add a preset browser floating tile to your interface and you're pretty much done.



  • @d-healey
    ah, okay - i must confess, i didn't think about that possibility and i didn't deal with the preset browser yet.
    could i assign single keys from the keyboard to single presets, so i could for example hit
    C4 on my keybord to play range from sample 0-40000 of the loop,
    C#4 on my keybord to play range from sample 50000-60000 of the loop and so on?
    would the performance of loading the presets be good enough for realtime tasks like that?
    thank you for your reply, this was helpful either way! 🙂



  • @toxonic Preset just store and recall the values of widgets. For key switches you will need to script. If you want different key switches for different presets then you can use a combination of scripting and widgets.



  • @d-healey said in Storing data in widgets:

    If you want different key switches for different presets then you can use a combination of scripting and widgets.

    does "preset" in this case mean: preset via the presetbrowser? so you can control the selection of presets via keystrokes, (...but i need to script that (which i didn't find a method for yet))?
    or am i back to the idea of storing widget values in panels?



  • @toxonic

    does "preset" in this case mean: preset via the presetbrowser?

    Yes, whenever I talk about presets this is what I mean, unless I specifically say otherwise. 🙂

    so you can control the selection of presets via keystrokes

    No. User selects the preset from the preset browser. Do you want different keyswitches for different presets?



  • @d-healey

    Yes, whenever I talk about presets this is what I mean, unless I specifically say otherwise. 🙂

    okay, do not mind me, i wasn't sure! 😉 and if i'm honest, i don't really know what you mean with that sentence

    If you want different key switches for different presets then you can use a combination of scripting and widgets.

    since this somehow contradicts with

    No. User selects the preset from the preset browser.

    or did i misunderstand that?
    but yes, i want to different presets with different keyswitches on my midi keyboard. 😉



  • The user selects a preset from the preset browser with the mouse - not the keyboard.

    i want to different presets with different keyswitches on my midi keyboard

    I don't quite understand what you want. You said this previously:

    C4 on my keybord to play range from sample 0-40000 of the loop,
    C#4 on my keybord to play range from sample 50000-60000 of the loop and so on?

    Will those keyswitches, C4 and C#4, be used for all presets or do you need each preset to have totally different keyswitches?



  • @d-healey
    uhh, i really seem to express myself very awkward, i'm sorry for that. 😕
    i want to store different loopranges (AudioWaveForm) to different presets. by pressing a key on my midi keyboard i want to select a specific preset and play the looprange saved within that preset.
    C4 -> looprange a (saved in preset 1)
    C#4 -> looprange b (saved in preset 2)
    D4 -> looprange c (saved in preset 3)
    ....and so on
    got me now? thanks for your patience with me, my english is quite poor and my HISE knowledge as well.... 😕


Log in to reply
 

10
Online

553
Users

2.1k
Topics

16.4k
Posts