lookup tables
-
If I have some values in 2 arrays like this
tbl1 = [23, 300, 420, 570, 700]; tbl2 = [60, 200, 620, 880, 1200];I also have a knob that has the range 0 -1.
If I would like to send the values between tbl1[0] and tbl2[0] (23 -> 60) in the knobs callback, I would write:
sendValue = tbl1[0] + (tbl2[0] - tbl1[0]) * knob.getValue();I will always go from tbl1 to tbl2, or vice versa, using the same index
How can I achieve this inside script node?
Where do I store the arrays, etc.... -
@ulrik the question is: what's the size of your arrays?
if not too big (max 128?) you should be able to use slider packs
Above this, you might consider a third party node to which you send the data arrays with a cable, perform that simple operation in C++ (in the cable callback so you leave the process untouched)
Then you output the result to a third cable that you grab in the network. for the last part, I haven't done such a thing but it should be possible -
@ulrik A small precisions needed:
- Do you need all resulting values at once or a unique value for a specific index?
- And are the array values pre-defined or dynamic?
That would change a bit how you want to handle it...
-
@ustk said in lookup tables:
@ulrik the question is: what's the size of your arrays?
if not too big (max 128?) you should be able to use slider packs
It's 2 arrays with 15 values in each and 2 other arrays with 5 values in each, so not so big
So I'll test with slider packs thenAbove this, you might consider a third party node to which you send the data arrays with a cable, perform that simple operation in C++ (in the cable callback so you leave the process untouched)
So it's not possible to do the operations in script node?
Then you output the result to a third cable that you grab in the network. for the last part, I haven't done such a thing but it should be possible
-
@ustk said in lookup tables:
@ulrik A small precisions needed:
- Do you need all resulting values at once or a unique value for a specific index?
- And are the array values pre-defined or dynamic?
That would change a bit how you want to handle it...
I need all calculated values at once
-
@ulrik said in lookup tables:
I need all calculated values at once
Here's your biggest problem. In script node you'll be able to get them one by one depending on the index value of a slider pack, not re-write an entire slider pack as output of the two. (Unless I'm not aware or smart enough to find a workaround)
Is the weighting knob changing at a modulation rate or just from a user UI knob? If it's the second then you might consider doing the computation in the UI script and just set one slider pack data connected to your network. Otherwise -> third party node, maybe...
-
@ulrik and what about this?
you can use twopack8_writer
-
@ustk Yes that's a nice way, however I would like to have everything inside script node, because I will make a hardcoded fx and use it in a FX slot, and it would make a lot of scripting to connect it to slider packs as well as all other knobs in the UI when inserted.
But if that is the best way I will go that path...I will think some more on this and decide later.
Thank you for feedback, it's much appreciated! -
@ulrik The solution I've posted above is entirely inside scriptnode. However a pack_writer is limited to 8 sliders... Can you go with two of them?