Compare previous value with current

Discuss Lemur and share techniques.
Post Reply
hodok
Newbie
Posts:21
Joined:15 Jan 2013 14:39
Compare previous value with current

Post by hodok » 09 Jan 2015 20:01

I need to identify which values of the array(x from MultiBall) have changed, how do I get "previous" value of x for comparing?

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

Re: Compare previous value with current

Post by Phil999 » 09 Jan 2015 22:35

this is something I'm not very good at, but in principle it is not complicated.

- create an expression, call it 'last_x' or something like that
- create a script under the Multiball object that is executed by z and arrow up (0->1). Every time you touch the multiball the script will run
- in the script, add the line "last_x=x;"

This will write the current value of x (before you touched it) to the 'last_x' expression (memory). You may add a Monitor object to remain informed about the 'last_x' value. Now you can compare this value with the new current x value.

So the method is to use expressions as memory storage. With that you can do many nice things. Have a look at templates from other users, especially Antonio Blanca. But Blanca is just a good example, there are many other users that make good use of expressions.
Formant+Eurorack, PPG wave 2.2, Korg MS-20, etc., EWI 4000s, QuNeo, etc., Mixbus32c, u-he, MadronaLabs, Samplemodeling, NI, etc., iPad2/4/Pro

Softcore
Regular
Posts:1639
Joined:04 Nov 2012 08:34

Re: Compare previous value with current

Post by Softcore » 09 Jan 2015 23:08

Yup, like Phil said! Of course, how you structure your code (how you "express" that "difference" of which ball moved) depends on what you want to do with this information.

Here's an example - the monitor above the multiball shows WHICH balls moved in axis X since last time the object was touched - 1 of the ball has moved, 0 if not)
Attachments
whichballmoved.jzml
(6.12KiB)Downloaded 53 times

Softcore
Regular
Posts:1639
Joined:04 Nov 2012 08:34

Re: Compare previous value with current

Post by Softcore » 09 Jan 2015 23:17

Oops I think its buggy! Anyways, let me know if you need further help - take the above example with a grain of salt.

hodok
Newbie
Posts:21
Joined:15 Jan 2013 14:39

Re: Compare previous value with current

Post by hodok » 10 Jan 2015 22:56

I need to get single changed value, like in attachment. It's a little buggy, and it have something to do with handling of touch events.
Is there a way to compare with each previous state(not only state was when touched)? It would solve a bug.
Attachments
whichballmoved.jzml
(6.07KiB)Downloaded 57 times

Softcore
Regular
Posts:1639
Joined:04 Nov 2012 08:34

Re: Compare previous value with current

Post by Softcore » 11 Jan 2015 10:12

Hmm now I dont understand.......What do you mean "single value"? WHAT IF, you touch two balls at the same time?

So WHAT IS EXACTLY that you want to be able to "monitor" - check for? Because obviously your first description:
"I need to identify which values of the array(x from MultiBall) have changed, how do I get "previous" value of x for comparing?" will not provide "one single value" if you are moving TWO (or more) balls at a time.

hodok
Newbie
Posts:21
Joined:15 Jan 2013 14:39

Re: Compare previous value with current

Post by hodok » 11 Jan 2015 13:19

When two ball touched it going to be acceptable if streams just overlap, passing both values alternately. This meant for control of single point, so multi-touch behaviour is not important.

Post Reply