General

trigger two pads

Started by charly on .

Sign in or create an account to join the conversation.

8 posts

Topic starter
Happy New Year !!

I am really new on Lemur and i have certainly a very simple question, but i cant find the way.

I have five simple Pads named A B C D E

every Pad send just one different command, via OSC and it works .

i like to have one new pad called AB to trigger A and B simultaneously , another for CE , and BC , and the last one BD.

I script under A and B

if(AB.x==1)x=1;
else if(AB.x==0)x=0;

and it's ok AB trigger A et B
the same for C and E , but i dont know what to script for BD (as i already use B in AB )

Hope you can understand my question and my english !!!!

Thanks :D

question.jzml
You can use B in multiple places without issue. It's referencing an object, not a global variable, and even in that case it wouldn't cause a problem. There are a few problems here though. When you release a pad, pad.x=0. So if you have if pad.x==1 x=1 else if pad.x==0 x=0, the other pad won't work when you press it b/c x will be set to 0. I rewrote your script and placed it under AB etc. instead of A and B. This allows you to trigger the script on x instead of on frame, so it will use less cpu.

question.jzml
So yes, i have another question :)

i have two pads A and B


under B
if(A.x==1)x=1;
else if(B.x==0)x=0;

so i press A and i have B simultaneously

but i need a delay , i want B trigger 400 ms after A .

i must use delay() but i dont understand where and how :(

Thanks

ABdelay.jzml
Let's start by breaking down your script:
if(A.x==1)x=1;
else if(B.x==0)x=0;
If (Pad A x is on) Pad B x is on.
Otherwise if (Pad B x is off) Pad B x is off.

The above is called pseudocode. It's a way to think through a problem. When you put it like that, it's clear your code won't do what you want it to do. A small note to make is that when you put a script at object level, you don't have to reference the object, you can just use x. So if you write x in your script, it implies B.x.

What you want in pseudocode is this:
If (Pad A x is on) after 400 ms, Pad B x is turned on.

Another thing to keep in mind is triggering a pad without an off message will leave the pad turned on. Have you checked the user guide? I don't see reference to the delay() function in the user guide or addendum. Did you see this in another patch? Are you sure it exists? If not, you're going to have to use the built-in time variable to trigger the second pad after 400 ms.
Sorry, I'm too busy getting paid writing scripts for my job to build or debug anything for free. The way I would do this is create a variable (a), when you trigger the first pad, save the value of the built in time variable, then subtract a from the built in time variable in another script on frame and store the difference as another variable (b). then in the same script write a conditional if (b==400)Pad.x=1; else; If it were me, I would get real fancy and make a third variable (c) and set it equal to a fader's output*10,000 so that I could change the delay length. No guarantees any of what I just wrote will work or is error free