stupid save value.x question

Discuss problems and solutions.
vmy
Newbie
Posts: 10
Joined: 20 Oct 2013 16:06

stupid save value.x question

Post by vmy »

hi all :)
im newbee in scriping and programming. think its a very simple problem and hope someon can help me!

i want to control fadervalue with a button. therefor i used a switch. when switch is on fader value should be 0. when switch is of fader value should be at the last value. hope you anderstand what i want to do?
therefor i creat the following script. on is switch object. value is a normal fader:

decl temp;

if (on.x==1)
{
temp=value.x;
value.x=0;
}
else if (on.x==0)
{
value.x=temp;
}

in my oppinion it should be work? but it seems the value cant be saved by the temp variable?

maybe someone has also a quick solution to use same for a multislider. to turn off every slider seperat with a special switch. think therefor i must
use vectors.

greetings
vmy
Phil999
Regular
Posts: 919
Joined: 11 Jan 2012 01:53

Re: stupid save value.x question

Post by Phil999 »

I guess it doesn't work because the variable is inside the script. Creating a variable (expression) and include it in the script should solve the problem.
Formant+Eurorack, PPG wave 2.2, Korg MS-20, etc., EWI 4000s, QuNeo, etc., Mixbus32c, u-he, MadronaLabs, Samplemodeling, NI, etc., iPad2/4/Pro
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: stupid save value.x question

Post by Softcore »

Create a new empty expression (x= button in desktop editor) inside your fader - call it lastX (for example).

Create a script in your fader - lets name the script setLastX.

Set this script to execute on expression z, and then use the dropdown menu at the far right of the scripting window to execute when z drops to zero (arrow pointing down).

Inside the script type:

lastX = x;


This script will be saving the fader's value as lastX everytime z drops to zero - in other words everytime you stop touching the fader, in other words every last value as you want. (Assuming physics are off for the fader)

Now, inside your button type this script

If (x==1) {value.x = value.lastX;} else {value.x = 0;}


;)
vmy
Newbie
Posts: 10
Joined: 20 Oct 2013 16:06

Re: stupid save value.x question

Post by vmy »

very nice!!
it runs.... :D

thanks alot.

now i will test this templet to use it with 10 faders in multislider and 10 button.
hope i now can solve this problem....

greetings
vmy
Attachments
save.jzml
savebutton
(4.05 KiB) Downloaded 54 times
vmy
Newbie
Posts: 10
Joined: 20 Oct 2013 16:06

Re: stupid save value.x question

Post by vmy »

just have modified the templet to use also multislider by painting over switchs and it runs very well!!!!
think its a very stupid solution. think i also can use variable for vectors in multislider, but i only need 10 and for this its running well.....

greetings and thanks alot for your help !!
vmy

save2.jzml
with multislider
(14.68 KiB) Downloaded 62 times
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: stupid save value.x question

Post by Softcore »

There's a simpler way to achieve what you achieved in "save2" with the use of vectors and a loop.....
save2-usingloops.jzml
(8.35 KiB) Downloaded 56 times
Yet though, it still isnt "right" - both my example attached above and yor version....Draw some values on the sliders, switch on button 1 and ALL the sliders go to zero not only the first one....Thats not what we hoped for, was it?


Here is the correct functionality!

;)
save3.jzml
(10.54 KiB) Downloaded 64 times
vmy
Newbie
Posts: 10
Joined: 20 Oct 2013 16:06

Re: stupid save value.x question

Post by vmy »

yes!! great! i understand. but i wasnt able to get this nice solution. 8-)

only one thing i missed. maybe you also have a solution for this problem? but its only a blemish.
when buttons are of i can change the value of the fader. to save the value i must put the button on and of. maybe there can be a solution that i cant change the faders value when the corresponding button is off? hope you understand?

thanks for this very nice templet. i have saved it as modul to use it also in other templets!!! :P

greetings
vmy
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: stupid save value.x question

Post by Softcore »

I think you would be better off by using two buttons - one to reset the fader to zero (as now our buttons does when it's turned to off) which would be a "push button" not a switch (in Lemur terminology, a "pad") and one to save the fader position as a "preset". There is a very nice tutorial hanging around somewhere in the forums about saving "presets" - this would allow you to "recall" not one, but all faders into their position with the push of a button and have not one but many "presets" available. Let me know if you need an example to get you started! ;)
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: stupid save value.x question

Post by Softcore »

here's the dual buttons approach actually - no preset saving needed - I think it is much more clear and intuitive than our previous efforts! ;) And its better code-wise!
Attachments
save4.jzml
(12.2 KiB) Downloaded 75 times
vmy
Newbie
Posts: 10
Joined: 20 Oct 2013 16:06

Re: stupid save value.x question

Post by vmy »

wowowowo :D

softcore your the greatest!!! just have tested your solution. runs very well.
i must learn very much to understand your code..... uuuuuhps. :P

thanks alot! i worked with a kyma and therefor its fantastic to programm special controllers. lemur is an fantastic tool for this kind of work.

greetings
vmy
Post Reply