Forums > MaxMSP

acceleration recognition

June 13, 2009 | 3:31 pm

Hi all

here is a simple patch demonstrating my attempt to do a acceleration detector. It does work very well. I’ve searched the forum and the max objects list for an external that would do this but did not find anything.
It’s obvious that in order to accomplish this you need time based objects but I only know of [thresh][quickthresh][timer][clocker].

any suggestions would be greatly appreciated.

thanks a lot

phil

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 324 235 100 196617 if $i1>= 9 then bang;
#P toggle 357 348 15 0;
#P newex 391 367 31 196617 dac~;
#P number 360 275 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 360 293 61 196617 cycle~ 600;
#P message 434 269 62 196617 0.5 , 0. 500;
#P newex 391 336 35 196617 *~ 0.;
#P newex 434 294 44 196617 line~ 0.;
#P number 324 206 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 324 157 27 196617 t b l;
#P newex 324 178 34 196617 zl len;
#P newex 324 138 62 196617 prepend set;
#P user hslider 324 90 18 128 128 1 0 0;
#P newex 324 114 83 196617 quickthresh 100;
#P window linecount 2;
#P comment 469 96 100 196617 toy around @ different speeds;
#P connect 8 0 12 0;
#P fasten 8 0 12 1 396 360 417 360;
#P fasten 10 0 8 0 365 323 396 323;
#P connect 11 0 10 0;
#P connect 6 0 14 0;
#P fasten 14 0 9 0 329 260 439 260;
#P connect 1 0 3 0;
#P connect 2 0 1 0;
#P connect 3 0 5 0;
#P connect 5 0 4 0;
#P connect 5 1 4 0;
#P connect 4 0 6 0;
#P fasten 13 0 12 0 362 365 396 365;
#P fasten 7 0 8 1 439 323 421 323;
#P connect 9 0 7 0;
#P window clipboard copycount 15;


June 14, 2009 | 6:38 am

OOPs !!

I meant it doesn’t work very well. Damn I should really reread myself more often. sorry about that.

Again, Since it DOESN’T work very well, would any of you have any suggestions.

Thanks and sorry about my mistake.

phil


June 14, 2009 | 5:26 pm

What about something like this:

– Pasted Max Patch, click to expand. –

June 14, 2009 | 7:29 pm

Hey Thanks a lot Holland.

Not quite sure what’s going on your subpatch, will need to investigate further.

I just love simplified patching like that!

thanks again it works like a charm.

phil


June 17, 2009 | 1:47 am

It’s a bit of a hack, but it works. Technically velocity = change in distance / time and acceleration = change in velocity / time. Since the values are always updated at a constant rate, I’ve just pulled time out of the equations and simplified velocity to change in distance and acceleration to change in velocity. So, a bit of a hack, but one that’s proved useful for me.


June 20, 2009 | 5:15 pm

Hi Holland

Hi

After having a 2nd deeper look into you "gap calculator patch". My question is;for calculating gaps in between did you choose [bucket] because it does this (by mistake or not) anyways ??

If you look in the help file example; when you quickly change values on input slider, bucket creates a gap in it’s output. < - is this natural behaviour from [bucket] or would it be because I,m in overdrive mode.

Again, I understand that by putting a

[metro 50]
|
[i ]
|

that’s what your creating , a (calculate the gap between 2 values @ the rate of 50ms) < - so another question is; is there contradiction in the operations since [bucket] seems to be reacting (opening gate up) @ it's on rate. (Scheduler I guess ?)

thanks again

phil


June 20, 2009 | 5:25 pm

here is a patch that illustrates what I mean with no metro @ all.

#P toggle 54 380 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 115 432 31 196617 dac~;
#P newex 120 402 35 196617 *~ 0.;
#P newex 106 360 61 196617 cycle~ 500;
#P message 231 339 62 196617 0.5 , 0. 200;
#P newex 171 361 44 196617 line~ 0.;
#P newex 176 307 115 196617 if $i1 >= 100 then bang;
#P user hslider 159 91 18 128 500 1 0 0;
#P number 200 209 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 125 204 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 169 246 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 163 169 45 196617 buddy 2;
#P number 162 120 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 172 283 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 169 222 27 196617 – 1;
#P newex 171 263 23 196617 abs;
#P newex 162 145 48 196617 bucket 2;
#P comment 159 72 100 196617 move this faster;
#P connect 4 0 11 0;
#P connect 11 0 13 0;
#P connect 6 1 3 1;
#P connect 6 1 9 0;
#P connect 6 0 8 0;
#P connect 6 0 3 0;
#P connect 14 0 15 0;
#P connect 13 0 12 0;
#P connect 15 0 16 0;
#P connect 15 0 16 1;
#P connect 17 0 16 0;
#P connect 12 0 15 1;
#P connect 10 0 5 0;
#P connect 7 0 2 0;
#P connect 3 0 7 0;
#P connect 1 1 6 1;
#P connect 1 0 6 0;
#P connect 5 0 1 0;
#P connect 2 0 4 0;
#P window clipboard copycount 18;

what do you think??

phil


June 20, 2009 | 5:35 pm

yet another version.

SO what is the speed of bucket ?!!

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 223 293 194 196617 * N threshold of gap regardless of speed!!;
#P number 381 24 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 311 26 15 0;
#N counter 1 4;
#X flags 0 0;
#P newobj 350 67 66 196617 counter 1 4;
#P message 457 114 26 196617 149;
#P message 373 112 20 196617 51;
#P newex 374 135 53 196617 switch 3;
#P newex 342 43 52 196617 metro 30;
#P message 349 111 20 196617 50;
#P toggle 54 380 15 0;
#P newex 115 432 31 196617 dac~;
#P newex 120 402 35 196617 *~ 0.;
#P newex 106 360 61 196617 cycle~ 500;
#P message 231 339 62 196617 0.5 , 0. 200;
#P newex 171 361 44 196617 line~ 0.;
#P newex 176 307 115 196617 if $i1 >= 100 then bang;
#P user hslider 159 91 18 128 500 1 0 0;
#P number 200 209 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 125 204 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 169 246 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 163 169 45 196617 buddy 2;
#P number 162 120 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 172 283 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 169 222 27 196617 – 1;
#P newex 171 263 23 196617 abs;
#P newex 162 145 48 196617 bucket 2;
#P comment 159 72 100 196617 move this faster;
#P window linecount 7;
#P comment 440 146 100 196617 so the gap between values has to be >= than what is decided in the [if object] regardless of the speed the metro above;
#P window linecount 1;
#P comment 395 112 52 196617 *< -gap->;
#P connect 21 0 20 0;
#P connect 21 0 25 0;
#P connect 21 0 23 0;
#P connect 21 0 24 0;
#P connect 25 0 22 0;
#P connect 27 0 21 1;
#P connect 22 0 12 0;
#P connect 26 0 21 0;
#P connect 20 0 22 1;
#P connect 23 0 22 2;
#P connect 24 0 22 3;
#P connect 6 0 13 0;
#P connect 13 0 15 0;
#P connect 8 1 5 1;
#P connect 8 1 11 0;
#P connect 8 0 10 0;
#P connect 8 0 5 0;
#P connect 16 0 17 0;
#P connect 15 0 14 0;
#P connect 17 0 18 0;
#P connect 17 0 18 1;
#P connect 19 0 18 0;
#P connect 14 0 17 1;
#P connect 12 0 7 0;
#P connect 9 0 4 0;
#P connect 5 0 9 0;
#P connect 3 1 8 1;
#P connect 3 0 8 0;
#P connect 7 0 3 0;
#P connect 4 0 6 0;
#P window clipboard copycount 29;

phil


June 21, 2009 | 9:30 pm

Bucket simply outputs the previous input, so its "speed" is entirely dependent on the rate of the data fed into it. Your second patch (the one without the metro) works because the slider object doesn’t interpolate between values. Hook up [print] to the output of a slider, mouse around a little and you’ll soon see plenty of "gaps" between values. Someone who knows much more than I do about how Max interacts with the OS can probably explain this behavior.

The advantage of using a metro to bang out incoming data at a constant rate is simply so you don’t have to calculate the time between successive values in order to find velocity or acceleration.


June 21, 2009 | 9:52 pm

Hi holland

thanks for the reply. Yes so my point stands that one can called the accel based on the gap/space between values. So if having a [number box] that outputs to slowly < - then accel recognition could be done!

I pressume it’s totally based on scheduler speed/Overdrive/computer speed etc…

thanks again, for your little patch. It’s very handy for interactive stuff Wink

phil


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