General

Help with multi line script - multiple Fader defaults

Started by Kaatza_Music on .

Sign in or create an account to join the conversation.

8 posts

Topic starter
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.
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.
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)
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
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...