list magic

May 21, 2007 at 12:46am

list magic

hi all,

looking for some advice on some list/loop magic. i need to take a collection that has 2 associated elements: a buffer number (1-16) and a time in ms. the time values of each occurrence of each specific buffer need to be subtracted from the following occurrence of that same buffer, which tells me how much time elapsed between them. then, if the time is less than a certain variable (say 2000ms) that index should be removed from the coll.

for example, if this is the coll

1, 1 1000;
2, 3 1600;
3, 1 1700;
4, 8 2000;
5, 3 3000;
6, 1 3500;
7, 3 3600;
8, 8 5000;

if would result in a list (or a coll) like this:

1 1000
3 1600
8 2000
1 3500
3 3600
8 5000

i have a really ugly attempt going (loops in max really suck), but it only half works. i don’t want to spend any more time on a bad algorithm. any advice would be appreciated.

-j

#32004
May 21, 2007 at 10:33am

I like building things like these. Hope this is of some help to you:

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 217 221 75 196617 comparing coll;
#P newex 87 294 27 196617 t l l;
#P newex 87 381 121 196617 if $i1 >= 2000 then bang;
#P newex 87 412 36 196617 zl reg;
#P newex 87 324 44 196617 zl nth 2;
#P newex 173 462 62 196617 print result;
#P newex 87 271 47 196617 gate 2 1;
#P newex 87 249 120 196617 if $i1 == 0 then 2 else 1;
#P newex 226 189 49 196617 append 0;
#P newex 196 165 40 196617 uzi 16;
#P newex 87 352 27 196617 – 0;
#P newex 124 144 27 196617 t l l;
#P newex 141 189 30 196617 grab;
#P newex 141 165 44 196617 zl nth 1;
#N coll ;
#P newobj 161 221 53 196617 coll;
#P newex 124 90 48 196617 t dump b;
#P button 124 58 15 0;
#N coll ;
#P newobj 124 122 53 196617 coll;
#P comment 57 123 63 196617 original coll;
#P connect 15 0 4 0;
#P connect 15 0 13 0;
#P connect 12 1 4 0;
#P connect 12 1 13 0;
#P fasten 6 0 11 0 146 239 92 239;
#P connect 6 0 8 1;
#P connect 1 0 7 0;
#P connect 8 0 16 0;
#P connect 16 0 15 0;
#P connect 17 0 14 0;
#P fasten 17 1 15 1 109 316 118 316;
#P connect 12 0 17 0;
#P connect 7 0 12 1;
#P connect 14 0 8 0;
#P connect 11 0 12 0;
#P connect 7 1 5 0;
#P fasten 10 0 4 0 231 213 166 213;
#P fasten 3 1 9 0 167 116 201 116;
#P connect 9 2 10 0;
#P connect 2 0 3 0;
#P connect 3 0 1 0;
#P connect 6 1 4 0;
#P connect 5 0 6 0;
#P window clipboard copycount 19;

#104618

You must be logged in to reply to this topic.