Page 1 of 1
Problem with MultiSlider x vector
Posted: 04 Oct 2012 07:03
by brianc
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?
Re: Problem with MultiSlider x vector
Posted: 04 Oct 2012 10:06
by Macciza
Hi
Maybe a be a little more explicit
see attached
Cheers
MM
Re: Problem with MultiSlider x vector
Posted: 04 Oct 2012 16:20
by brianc
Macciza wrote:Hi
Maybe a be a little more explicit
see attached
Thanks for that! It doesn't fix the problem, though. Yes, I will know what the length of the vector of slider values will be, but I still don't have access to the vector at the proper size.
Re: Problem with MultiSlider x vector
Posted: 07 Oct 2012 14:05
by Macciza
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
Re: Problem with MultiSlider x vector
Posted: 07 Oct 2012 19:20
by brianc
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?
Re: Problem with MultiSlider x vector
Posted: 15 Jan 2013 01:00
by dBlicious
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.
Re: Problem with MultiSlider x vector
Posted: 16 Jan 2013 03:01
by Macciza
Hi
My best advice would be to send in an example project - there are too many ways of achieving(or not) many things in Lemur . ..
Cheers
MM
Re: Problem with MultiSlider x vector
Posted: 17 Jan 2013 21:14
by dBlicious
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