Help with multi line script - multiple Fader defaults

Discuss Lemur and share techniques.
Post Reply
Kaatza_Music
Newbie
Posts: 27
Joined: 10 Feb 2013 16:16

Help with multi line script - multiple Fader defaults

Post 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.
Leon Portelance, aka The Katz, B of Mus.
composer . songwriter . producer
Website - IMDb - Vinny's Last Ride
Phil999
Regular
Posts: 919
Joined: 11 Jan 2012 01:53

Re: Help with multi line script - multiple Fader defaults

Post by Phil999 »

I think you can create an expression for that value. The radio switches define that expression. That should work.
Formant+Eurorack, PPG wave 2.2, Korg MS-20, etc., EWI 4000s, QuNeo, etc., Mixbus32c, u-he, MadronaLabs, Samplemodeling, NI, etc., iPad2/4/Pro
Kaatza_Music
Newbie
Posts: 27
Joined: 10 Feb 2013 16:16

Re: Help with multi line script - multiple Fader defaults

Post 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 . . .
Leon Portelance, aka The Katz, B of Mus.
composer . songwriter . producer
Website - IMDb - Vinny's Last Ride
Kaatza_Music
Newbie
Posts: 27
Joined: 10 Feb 2013 16:16

Re: Help with multi line script - multiple Fader defaults

Post 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.
Leon Portelance, aka The Katz, B of Mus.
composer . songwriter . producer
Website - IMDb - Vinny's Last Ride
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: Help with multi line script - multiple Fader defaults

Post 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...
Last edited by Softcore on 18 Feb 2013 07:15, edited 4 times in total.
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: Help with multi line script - multiple Fader defaults

Post by Softcore »

Your firstof(x) approach could also work but you have a lot of syntax errors in your script...

;)
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: Help with multi line script - multiple Fader defaults

Post 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 110 times
Kaatza_Music
Newbie
Posts: 27
Joined: 10 Feb 2013 16:16

Re: Help with multi line script - multiple Fader defaults

Post 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.
Leon Portelance, aka The Katz, B of Mus.
composer . songwriter . producer
Website - IMDb - Vinny's Last Ride
Post Reply