Forums > Jitter

Nth had maximum value?

May 20, 2006 | 7:22 am

Dear Maxers,

I’m trying to map some fft data to MIDI and need two values from a list; the
maximum value in that list (easy enough with [maximum]) AND the position in
the list that had that value (should be easy enough but I’m not getting it).
Any ideas on how to do this?

Many thanks,

Christopher

max v2;
#N vpatcher 8 135 392 469;
#P window setfont "Sans Serif" 10.;
#P window linecount 1;
#P message 4 61 74 9109514 1 2 6 8 9 33 7;
#P number 83 160 35 10 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 83 131 55 9109514 maximum;
#P user multiSlider 83 56 77 62 0. 255. 256 2681 15 0 0 2 0 0 0;
#M frgb 0 0 0;
#M brgb 255 255 255;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P window linecount 2;
#P comment 126 162 136 9109514 Which slider (or nth position) had this
value?;
#P connect 4 0 2 0;
#P connect 1 0 2 0;
#P connect 2 0 3 0;
#P pop;


May 20, 2006 | 9:30 am

hi christopher,
[Ltop] from peter elsea’s Lobjects does exactly that.
one possible "native" max solution is below.
hth,
volker.

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 482 362 33 196617 pos;
#P newex 323 253 60 196617 t i b;
#P newex 480 312 27 196617 i;
#P number 480 337 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 323 197 184 196617 t i b;
#P newex 323 143 96 196617 t l b -2147483648;
#P number 323 337 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 323 230 96 196617 if $i1>$i2 then $i1;
#N counter;
#X flags 0 0;
#P newobj 497 255 66 196617 counter;
#P newex 323 172 47 196617 zl iter 1;
#P window setfont "Sans Serif" 10.;
#P number 161 155 35 10 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 161 126 55 196618 maximum;
#P user multiSlider 161 51 77 62 0. 255. 256 2681 15 0 0 2 0 0 0;
#M frgb 0 0 0;
#M brgb 255 255 255;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P window setfont "Sans Serif" 9.;
#P comment 326 362 33 196617 val;
#P connect 1 0 2 0;
#P connect 1 0 8 0;
#P connect 12 0 7 0;
#P fasten 12 0 6 1 328 301 432 301 432 222 414 222;
#P fasten 8 1 5 2 371 165 530 165;
#P connect 8 2 6 1;
#P connect 8 0 4 0;
#P connect 12 1 11 0;
#P connect 6 0 12 0;
#P connect 11 0 10 0;
#P connect 5 0 11 1;
#P connect 9 1 5 0;
#P connect 9 0 6 0;
#P connect 4 0 9 0;
#P connect 2 0 3 0;
#P window clipboard copycount 14;


May 20, 2006 | 12:32 pm

hi volker,

many thanks for this and the [Ltop]!

christopher


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