Page 1 of 1

Help with multi line script - multiple Fader defaults

Posted: 16 Feb 2013 13:34
by Kaatza_Music
Softcore helped me with a script to make a Fader snap back to a default value:

act()
On Expression
z
mode - leave or reach zero

Script

CC19.x=0.475362

It works great. The problem I have, is several instruments use the same Fader, but have different default settings. What I would like to do is have a Switches with 4 rows and 1 column with radio turned on so I can use it to select one of 4 Instruments. I would like the Fader default to be controlled by the Switches with a multi line script so that whatever Instrument is selected by the radio button, that instrument's default setting are loaded by the fader.

I don't have a clue how to write this script, I've read the manual and couldn't figure it out. So don't laugh, but this is just to kind of illustrate what I am trying to do. Obviously the script is not written correctly, if anyone could help me correct the coding for this to make it work,it would be appreciated.

Object being controlled by the script is a Fader linked to Switches

act()
On Expression
z
mode - leave or reach zero

Script

if Switches,radio.on.selected,'name'='Trumpet' CC19.x=0.3 ;
else if Switches,radio.on.selected 'name'='Trombone' CC19.x=0.4 ;
else if Switches,radio.on.selected,'name'='Horn' CC19.x=0.5 ;
else if Switches,radio.on.selected,'name'='Tuba' CC19.x=0.6 ;

I have no idea how you link the radio on value to which of the 4 buttons is selected.

Re: Help with multi line script - multiple Fader defaults

Posted: 16 Feb 2013 16:23
by Phil999
I think you can create an expression for that value. The radio switches define that expression. That should work.

Re: Help with multi line script - multiple Fader defaults

Posted: 16 Feb 2013 22:34
by Kaatza_Music
Ok, thanks. Being that I obviously know nothing about writing scripts or expressions, any hints about how to do that would be appreciated.

Back to the manual I go . . .

Re: Help with multi line script - multiple Fader defaults

Posted: 16 Feb 2013 22:39
by Kaatza_Music
On further reading of the manual, since the radio button turns the other switches off, all I need to do is have the fader controlled by the x value set in the Switches. So since I am using 4 buttons in the Switches, 0, 1, 2, 3, the script just needs to tell the Fader what value is turned on in the Switches. So I am thinking maybe something more like this for the fader script though it still isn't right:

The Fader is named: CC22
The Switches is named: Instruments
Script is controlling the Fader

act()
On Expression
Z
Leave or reach zero

Script:

decl CC22.x, val;
val = firstof(x);
if Instruments,(val==[0])
CC22.x = 0.3 ;
else if Instruments,(val==[1]) CC22.x = 0.4 ;
else if Instruments,(val==[2]) CC22.x = 0.5 ;
else if Instruments,(val==[3]) CC22.x = 0.6 ;
Setattribute(CC22 'content' CC22.x);


Am I getting any closer or completely on the wrong track? Appreciate any help. Thanks.

Re: Help with multi line script - multiple Fader defaults

Posted: 18 Feb 2013 01:27
by Softcore
Add a variable (expression) in your set of radio swittches (press the "x=" button instead of the script button)

Lets name this expression "def"...leave it blank at this point.

Add a script in your radio buttons

On expression x, rising from zero (up arrow)

Code: Select all

if (x[0]==1) def=0.2;
else  if (x[1]==1) def=0.3;
else  if (x[2]==1) def=0.5;
else  if (x[3]==1) def=0.6;
Now go to the script you have added in the fader and replace it with

Code: Select all

x=switches_name.def;
Obviously in the first script replace the four def values with your desired ones and in the second script replace the name of the switches with the actual name in your project (instruments?)

P.S. edit: with the above scripts you will make the fader "resettable" to different default settings but theactual press of the switches will NOTreset the fader....if you want to make the switches reset thefader you will have to add Fader_name.x=some value in the if statements above...

Re: Help with multi line script - multiple Fader defaults

Posted: 18 Feb 2013 01:34
by Softcore
Your firstof(x) approach could also work but you have a lot of syntax errors in your script...

;)

Re: Help with multi line script - multiple Fader defaults

Posted: 18 Feb 2013 07:33
by Softcore
here is an example also utilising a different approach (a vector expression and firstof(x) )
resettable_fader-with-options.jzml
(12.76 KiB) Downloaded 109 times

Re: Help with multi line script - multiple Fader defaults

Posted: 18 Feb 2013 10:59
by Kaatza_Music
No doubt there was syntax errors. I don't really know what I am doing. Just guessing a lot of the time :D

I really appreciate the help from someone who knows what he is doing. Thanks.