trigger two pads

Discuss Lemur and share techniques.
Post Reply
charly
Newbie
Posts:4
Joined:02 Jan 2017 13:14
trigger two pads

Post by charly » 02 Jan 2017 17:57

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
(20.34KiB)Downloaded 68 times

phase_change
Regular
Posts:114
Joined:31 May 2015 18:45
Location:Austin, TX

Re: trigger two pads

Post by phase_change » 02 Jan 2017 18:37

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.
Attachments
question.jzml
(20.13KiB)Downloaded 75 times
Have you tried turning it off and on again?

charly
Newbie
Posts:4
Joined:02 Jan 2017 13:14

Re: trigger two pads

Post by charly » 02 Jan 2017 19:28

thanks you so much, it works, now i will tried to really understand.

phase_change
Regular
Posts:114
Joined:31 May 2015 18:45
Location:Austin, TX

Re: trigger two pads

Post by phase_change » 03 Jan 2017 06:52

No problem, ask if you have questions about anything and I'll try to answer them. I understand this stuff can seem confusing at first, but I promise it gets easier.
Have you tried turning it off and on again?

charly
Newbie
Posts:4
Joined:02 Jan 2017 13:14

Re: trigger two pads

Post by charly » 03 Jan 2017 09:01

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
Attachments
ABdelay.jzml
(4.69KiB)Downloaded 73 times

phase_change
Regular
Posts:114
Joined:31 May 2015 18:45
Location:Austin, TX

Re: trigger two pads

Post by phase_change » 05 Jan 2017 05:25

Let's start by breaking down your script:

Code: Select all

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.
Have you tried turning it off and on again?

charly
Newbie
Posts:4
Joined:02 Jan 2017 13:14

Re: trigger two pads

Post by charly » 05 Jan 2017 14:21

Thanks for your explanation.
But can you show me an example with built- in time variable, i am so ignorant in script, I do not succeed in using it !

phase_change
Regular
Posts:114
Joined:31 May 2015 18:45
Location:Austin, TX

Re: trigger two pads

Post by phase_change » 08 Jan 2017 17:23

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
Have you tried turning it off and on again?

Post Reply