Troubleshooting

Problem with MultiSlider x vector

Started by brianc on .

Sign in or create an account to join the conversation.

8 posts

Topic starter
I'm drawing some values on a MultiSlider for a sequencer. I'd like to have the ability to change the length of the MultiSlider, and have the values shift properly. My goal is:

- When the number of sliders doubles, use the original values for every other slider, and interpolate between the two previous values. Like
- When the number of sliders halves, use average of the previous two values.

I have buttons for halving and doubling the number of sliders. When pressed, they change the length of the MultiSlider using setattribute(). Afterwards, I'd like to update the values in the MultiSlider's x vector. The vector manipulation part is easy, but the problem I'm having is that the length of the x vector isn't updated right away when the number of sliders is increased. Within the execution of the script, the slider's nbr attribute updates fine, but the length of the x vector isn't updated until sometime later, which is a problem.

Attached is a demo template.

Has anyone dealt with this?

MultiSlider_Issue.jzml
Weel
What are you wanting to do?
It solves the problem you posted . . .

To do further work on the MultiSlider values -
Keep an array of your values that gets manipulated by functions that get called when doubling or halving

Cheers
MM
Macciza wrote:Weel
What are you wanting to do?
It solves the problem you posted . . .

To do further work on the MultiSlider values -
Keep an array of your values that gets manipulated by functions that get called when doubling or halving

Cheers
MM
Thanks for sticking with me on this. You're right, it does display the size properly, and what you're suggesting is how I thought I'd solve it as well, but here's the problem:

- I have a script that doubles/halves the size of a multislider. Let's call it mymultislider.
- Once the length has changed, I'd like to replace the values that are in the x vector. I can do that with something like mymultislider.x = newxvector or a for loop that changes the values element by element. Seems pretty straightforward.
- BUT, the mymultislider.x vector actually doesn't get updated in response to my previous setattribute(mymultislider, 'nbr', newsize) command until AFTER that script runs (seems to be how it's implemented in Lemur), so the new values that I set are overwritten by Lemur, which just adds zeros when doubling the vector or chops off the second half when halving. Since that's the case, when is the appropriate time to replace the values?
Has anyone found a workaround for this? I am trying to do something similar to brianc--restoring x values that are lost when MultiSlider nbr is reduced. I have no trouble storing x in an array for later retrieval. No matter how I try, I can't set the missing x values in the same script after I add more sliders. It's making me nuts! I'd be grateful for some guidance.
I finally figured it out. I changed my on expression for the multislider.x memory update function from x to z. That was causing 0's overwrite the memory array when/where I added sliders. The added slider wouldn't update if I set it in the same function that I added the slider with, probably due to the order that lemur does things behind the scenes. I set up a little script to update x[last] when x[last] != memory[last]. In my case I'm only adding one slider at a time so I don't need to update all x. I'm not entirely happy, as the last bit could break something else down the line.

-A