Compare previous value with current
Compare previous value with current
I need to identify which values of the array(x from MultiBall) have changed, how do I get "previous" value of x for comparing?
Re: Compare previous value with current
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.
- 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
Re: Compare previous value with current
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)
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.12 KiB) Downloaded 46 times
Re: Compare previous value with current
Oops I think its buggy! Anyways, let me know if you need further help - take the above example with a grain of salt.
Re: Compare previous value with current
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.
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.07 KiB) Downloaded 53 times
Re: Compare previous value with current
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.
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.
Re: Compare previous value with current
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.