How to switch scripts on and off

Discuss problems and solutions.
jbgeluid
Regular
Posts:60
Joined:16 Jan 2012 14:03
How to switch scripts on and off

Post by jbgeluid » 06 Oct 2012 01:08

Is there a way to switch scripts on and off with buttons? I did read the manual...
Last edited by jbgeluid on 07 Oct 2012 11:53, edited 1 time in total.
Cubase 11, Windows 10/
Intel I7 4930K @3.4Ghz/
multiple RME hammerfall cards
Controllers: Ipad2/16gb, Lemur, BCR2000
http://www.jbgeluid.nl

brianc
Regular
Posts:87
Joined:10 Jan 2012 02:16

Re: Switch scripts on and off

Post by brianc » 06 Oct 2012 01:49

You could create a variable called run_script or something, and start those scripts with:

Code: Select all

if(!run_script) return;
Then just set run_script to 1 when you want it to run, and 0 otherwise.

jbgeluid
Regular
Posts:60
Joined:16 Jan 2012 14:03

Re: How to switch scripts on and off

Post by jbgeluid » 09 Oct 2012 12:39

brianc,

thanks for your reply, but can you be more specific? I'm a beginner, sorry..
Cubase 11, Windows 10/
Intel I7 4930K @3.4Ghz/
multiple RME hammerfall cards
Controllers: Ipad2/16gb, Lemur, BCR2000
http://www.jbgeluid.nl

Macciza
Regular
Posts:1325
Joined:07 Dec 2011 04:57
Location:Sydney, Australia.

Re: How to switch scripts on and off

Post by Macciza » 09 Oct 2012 12:59

Hi
Brianc has shown a way for scripts to only run if the run_script variable is set - say by a switch
This lets you have a script for say an object that will only run when the flag is set - say by using a Switch or set from another script

If you mean run a script in response to a switch set the script up to execute On Expression and Switch.x (or whatever) to use your switch to run it . .
Cheers
MM
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]

brianc
Regular
Posts:87
Joined:10 Jan 2012 02:16

Re: How to switch scripts on and off

Post by brianc » 09 Oct 2012 15:25

jbgeluid wrote:brianc,

thanks for your reply, but can you be more specific? I'm a beginner, sorry..
Sure, here's an example template that (I hope) demonstrates how this can be done.
Attachments
script_onoff.jzml
(3.74KiB)Downloaded 202 times

Phil999
Regular
Posts:932
Joined:11 Jan 2012 01:53

Re: How to switch scripts on and off

Post by Phil999 » 09 Oct 2012 22:37

excellent. So simple.

Now, what if you don't have a switch as 'trigger', but a Knob object? A Fader object has a 'touch'-variable z, but the Knob object not. Is it possible to fake a z variable with a Knob object? For example, when Knob.x increases or decreases? How to you express that? Or is there a simpler method?

Code: Select all

if (Knob.x ++) return;
if (Knob.x --) return;
The code is wrong, but you probably understand what it should do. If Knob.x changes, return (don't continue with the script). If Knob.x remains the same, continue with the script.
Formant+Eurorack, PPG wave 2.2, Korg MS-20, etc., EWI 4000s, QuNeo, etc., Mixbus32c, u-he, MadronaLabs, Samplemodeling, NI, etc., iPad2/4/Pro

brianc
Regular
Posts:87
Joined:10 Jan 2012 02:16

Re: How to switch scripts on and off

Post by brianc » 09 Oct 2012 22:53

Phil999 wrote:Now, what if you don't have a switch as 'trigger', but a Knob object? A Fader object has a 'touch'-variable z, but the Knob object not. Is it possible to fake a z variable with a Knob object? For example, when Knob.x increases or decreases? How to you express that? Or is there a simpler method?
It's a little ugly, but I guess my approach would be to have a script that runs whenever Knob.x changes that updates a variable that stores the time at which the value was last changed. So something like:

Code: Select all

last_change = time;
Then in the script that was dependent on that knob activity, you could put something like:

Code: Select all

if(time - Knob.last_change > 2) return;
Which will disable that script if the knob hasn't been changed in the last 2 seconds. With a really small threshold, you can have this be sensitive to within a few milliseconds.

Phil999
Regular
Posts:932
Joined:11 Jan 2012 01:53

Re: How to switch scripts on and off

Post by Phil999 » 09 Oct 2012 23:41

good idea. I tried it out, it doesn't work yet, but using a variable, and an expression-x-script for the 'trigger'-knob is a good method.

I also tried a variable (touch) and two scripts (touch_on, touch_off), but this also didn't work yet.

It shouldn't be too difficult, I'll get it soon I guess. Thank you for your help, very appreciated.
Formant+Eurorack, PPG wave 2.2, Korg MS-20, etc., EWI 4000s, QuNeo, etc., Mixbus32c, u-he, MadronaLabs, Samplemodeling, NI, etc., iPad2/4/Pro

jbgeluid
Regular
Posts:60
Joined:16 Jan 2012 14:03

Re: How to switch scripts on and off

Post by jbgeluid » 10 Oct 2012 00:07

Thanks Brianc and Phil999 for your input! This realy helps.

Jurgen
Cubase 11, Windows 10/
Intel I7 4930K @3.4Ghz/
multiple RME hammerfall cards
Controllers: Ipad2/16gb, Lemur, BCR2000
http://www.jbgeluid.nl

Phil999
Regular
Posts:932
Joined:11 Jan 2012 01:53

Re: How to switch scripts on and off

Post by Phil999 » 10 Oct 2012 01:55

brianc wrote:

Code: Select all

if(time - Knob.last_change > 2) return;
Which will disable that script if the knob hasn't been changed in the last 2 seconds. With a really small threshold, you can have this be sensitive to within a few milliseconds.
I want to disable the script when the knob changes, so it's

Code: Select all

if(time - Knob.last_change < 2) return;
That is working. Very nice.

Unfortunately, the script I want to prevent being executed does receive MIDI and moves the 'trigger'-knob - I'm running again in a feedback loop, something I wanted to prevent in the first place. My fault, I didn't expect that. I have to rethink this matter ...

Thanks again, your method is working.

My problem is described here:
http://liine.net/forum/viewtopic.php?f=25&t=1732
Formant+Eurorack, PPG wave 2.2, Korg MS-20, etc., EWI 4000s, QuNeo, etc., Mixbus32c, u-he, MadronaLabs, Samplemodeling, NI, etc., iPad2/4/Pro

Post Reply