Forums > MaxMSP

Comparing current value and previous value in a list

March 1, 2008 | 12:10 pm

hi people!
I need to store incoming acceleration data in some kind of list format, like an array. The list would need to store about 30 incoming values and then eventually empty itself and start again. Would a buffer be better and how would I go about doing this?

Also I need to be able to compare the current value that has just entered the list, to previous int values within the list. Basically say for example that in order for an acceleration value to trigger a sound, it must be above 135. I want to be able to check back to where the last trigger point occurred, if the incoming values in the list start to decrease below the trigger point. I also want to check how much time has passed since the last trigger point. This is a similar idea to a peak finder!

I hope this makes sense! Thanks

A



MIB
March 2, 2008 | 7:01 am

I am not sure if you want to compare two consecutive numbers or all numbers of your list with the current one… comparing two numbers is easy (see patch), also the biggest number out of a list isn’t that hard (patch again) – I am sure there is a more efficient way, but it’s late…
Hope this helps and gets you started.

#P window setfont "Sans Serif" 9.;
#P number 69 160 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 156 34 15 0;
#P window linecount 1;
#P newex 171 34 52 196617 metro 50;
#P newex 171 53 65 196617 drunk 128 7;
#P number 240 291 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P button 252 100 15 0;
#P newex 220 168 30 196617 t b b;
#P window linecount 2;
#P comment 283 283 100 196617 output biggest number of last 30;
#P window linecount 1;
#P newex 240 270 27 196617 i;
#P number 188 251 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 220 202 14 196617 0;
#P newex 220 147 38 196617 sel 29;
#P newex 188 222 42 196617 peak;
#P newex 171 96 27 196617 t b i;
#N counter 0 0 29;
#X flags 0 0;
#P newobj 220 126 77 196617 counter 0 0 29;
#P number 171 75 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P button 39 210 31 0;
#P newex 39 185 32 196617 sel 1;
#P newex 39 160 30 196617 >= 4;
#P newex 39 125 34 196617 abs 0;
#P newex 39 97 27 196617 – 0;
#P newex 39 65 48 196617 bucket 2;
#P number 39 40 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 4;
#P comment 21 244 100 196617 bang if difference between two numbers is certain threshold;
#P connect 23 0 5 1;
#P connect 5 0 6 0;
#P fasten 4 0 5 0 44 151 44 151;
#P connect 11 0 14 0;
#P fasten 11 0 15 1 193 247 262 247;
#P connect 22 0 21 0;
#P connect 21 0 20 0;
#P connect 20 0 8 0;
#P fasten 19 0 1 0 245 314 136 314 136 30 44 30;
#P connect 15 0 19 0;
#P connect 18 0 9 2;
#P connect 1 0 2 0;
#P connect 2 0 3 0;
#P connect 3 0 4 0;
#P connect 6 0 7 0;
#P fasten 2 1 3 1 82 89 61 89;
#P connect 8 0 10 0;
#P connect 10 1 11 0;
#P fasten 10 0 9 0 176 120 225 120;
#P connect 9 0 12 0;
#P connect 12 0 17 0;
#P connect 17 0 13 0;
#P connect 13 0 11 1;
#P fasten 17 1 15 0 245 191 245 191;
#P window clipboard copycount 24;


March 2, 2008 | 11:54 am

hi thanks, I’m having a look at your patch but I’m not 100% sure of what is going on? If you have time could you explain it please!

Thanks!


March 2, 2008 | 12:49 pm

Hi sorry just had a look and I understand what is going on now! Based on that patch, would it be possible to create something that takes in acceleration values and only sends an output if they fulfill a condition.

That the acceleration value is between the maximum and minimum trigger threshold, e.g. >= 120 && < =130.

If it is between the threshold, before the acceleration value is sent out, It needs to check if it has increased by more than 20 after less than 30 milliseconds since the last hit and if it has then, its value will be subtracted by a certain amount before being outputted!


March 2, 2008 | 1:18 pm

I’m retired from Oberlin but the teacher in me still kicks in now and then.
Reading manuals is not a waste of time. There have been several recent posts
that are almost immediately answered by referring the questioner to a basic
object. I love newbies but this makes learning max a very long and
frustrating process.

Here what I did/do…

First, read the Max/MSP manuals from cover to cover without trying to get
every detail. This gives a general understanding of what is there.

Then, periodically, skim the manual reading only the headers. On the right
is the name of the object and on the left is a brief description of the
object. If the object has a graphic representation in the middle of the
header. I do this about once a week and it takes 10-15 minutes – less each
time I skim. I also skim the bookmarks in the PDF files stopping to read
about objects that I don’t recognize. What this does is remind me of what is
in the toolkit. When a need arises for a particular function I can usually
answer by telling myself that that function does exist. Saves me the time
in trying to write it myself.

I do the same thing – less perfectly (right, ej, st?) – with the third party
packages that I use regularly.

Another approach is to use maxobjects.com as a thesaurus. Try searching
"increment decrement." I got seven items including IncDec with some
descriptions running to more than 10 lines. It also included gak, a genetic
algorithm kit that I did not know about. So (sorry to use my professor
voice) but I learned something useful while looking for something else. Now
THAT saves time!

Cheers
Gary Lee Nelson
Oberlin College
http://www.timara.oberlin.edu/GaryLeeNelson

On 3/2/08 6:54 AM, "Adam" wrote:

>
> hi thanks, I’m having a look at your patch but I’m not 100% sure of what is
> going on? If you have time could you explain it please!
>
> Thanks!



MIB
March 2, 2008 | 10:17 pm

Quote: spondoo@hotmail.com wrote on Sun, 02 March 2008 05:49
—————————————————-
> Hi sorry just had a look and I understand what is going on now! Based on that patch, would it be possible to create something that takes in acceleration values and only sends an output if they fulfill a condition.
>
> That the acceleration value is between the maximum and minimum trigger threshold, e.g. >= 120 && < =130.

Your answer is in the question. Use >= and < =, or && or [split 120 130]. Look at the help-files for all of these and all the other associated objects. That should give you a good idea of what is possible... and you will have the satisfaction of having figured it out yourself rather than getting a patch from someone...

>
> If it is between the threshold, before the acceleration value is sent out, It needs to check if it has increased by more than 20 after less than 30 milliseconds since the last hit and if it has then, its value will be subtracted by a certain amount before being outputted!

Maybe look at timer???


Viewing 6 posts - 1 through 6 (of 6 total)