Highest one from a b or c float

Nov 6, 2009 at 5:49pm

Highest one from a b or c float

Hello,

I wonder whether there is an object that can show which of its inlets has the highest value?

Any help appreciated.
Krisztian

code:

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 324 131 13 196617 c;
#P comment 281 132 13 196617 b;
#P number 304 147 35 9 0 0 0 3 0 0 0 255 227 23 222 222 222 0 0 0;
#P number 262 148 35 9 0 0 0 3 0 0 0 255 227 23 222 222 222 0 0 0;
#P number 220 148 35 9 0 0 0 3 0 0 0 255 227 23 222 222 222 0 0 0;
#P comment 233 132 13 196617 a;
#P window clipboard copycount 6;

#46327
Nov 6, 2009 at 10:11pm

Your code doesn’t show much of a starting point!

3 numbers >> pak 0. 0. 0. >> maximum 0. >> voila

one of several ways.

David

#166797
Nov 6, 2009 at 10:44pm

hi David, thanks for the reply, yes my start is not the best, sorry.
with the use of maximum, I only get the value, not the sender, not the index/inlet number. Sorry if I was a bit unclear.
any help appreciated.
K

#166798
Nov 6, 2009 at 11:08pm

no max on this computer but i will try it blind.

step 1 is to find the highest value:

[pak 0. 0. 0.]

[maximum]

step 2 then … comparing all input numbers versus the mean output:

[t l l]

[zl iter 1] [zl len]

[== 0.] (right inlet from maximum)

[zl group]

this will end up with a list “0 1 0″, which can now be decoded
to three outlets using [unpack] and [select 1] or whatever you
want the output to be.

when i am back at max i can make you a better version for sure.
Smile

#166799
Nov 6, 2009 at 11:21pm

Maximum does give you the index of it’s current highest input number. Maybe I’m misunderstanding what you need.

edit—- just read your post properly, don’t mind me! —-

– Pasted Max Patch, click to expand. –
#166800
Nov 6, 2009 at 11:38pm

did you look at the help file for maximum? Take a look at the second outlet.

David

#166801
Nov 6, 2009 at 11:56pm

hi, only the Max5 object does the second outlet, unfortunately.
My EEG patch seems to work faster on Max4 Sad

I will try what Roman Thilenius suggested.

thank you all.
Krisztian

#166802
Nov 7, 2009 at 11:29am

dear Roman

sMaRt !!!

thank very much.

Krisztian

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 134 343 60 196617 print group;
#P newex 195 224 41 196617 print G;
#P newex 106 196 40 196617 print E;
#P newex 15 197 41 196617 print C;
#P newex 134 312 64 196617 zl group;
#P newex 195 192 34 196617 == 0.;
#P newex 69 152 34 196617 zl len;
#P newex 15 152 47 196617 zl iter 1;
#P newex 15 108 27 196617 t l l;
#P flonum 126 126 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 159 92 89 196617 maximum;
#P newex 15 65 89 196617 pak 0. 0. 0.;
#P flonum 93 42 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 54 42 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 15 42 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 2;
#P comment 146 28 100 196617 Find which inlet has the highest value!;
#P connect 9 0 13 0;
#P connect 9 0 11 1;
#P connect 10 0 11 0;
#P connect 10 0 14 0;
#P connect 8 0 12 0;
#P fasten 8 0 10 0 20 180 200 180;
#P fasten 5 0 6 0 164 117 131 117;
#P fasten 5 0 10 1 164 118 224 118;
#P connect 4 0 7 0;
#P fasten 4 0 5 0 20 87 164 87;
#P connect 7 0 8 0;
#P connect 11 0 15 0;
#P fasten 7 1 9 0 37 138 74 138;
#P connect 1 0 4 0;
#P connect 2 0 4 1;
#P connect 3 0 4 2;
#P window clipboard copycount 16;

#166803
Nov 13, 2009 at 3:53pm

with zl sub it would be even easier, feed the output of maximum into the right inlet of zl sub, but pay attention on float types (your example had an int maximum but float pak…)

I am too lazy to fire up Max 4 to create the patch…;-)

#166804
Nov 13, 2009 at 4:26pm

hello Stefan, yes you are right, it is easier, thanks a lot.
Krisztian

#166805
Nov 13, 2009 at 4:52pm

If you got only 3 inlets, you could use expr quite easily as well :

#P window setfont “Sans Serif” 9.;
#P number 47 139 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 133 38 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 90 38 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 47 38 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 47 74 96 196617 pak 0. 0. 0.;
#P newex 47 106 195 196617 expr ($f1< $f2) + ($f1<$f2 && $f2<$f3);
#P comment 87 139 100 196617 inlet number (0 to 2);
#P connect 1 0 6 0;
#P connect 5 0 2 2;
#P connect 4 0 2 1;
#P connect 3 0 2 0;
#P connect 2 0 1 0;
#P window clipboard copycount 7;

Charles

#166806
Nov 14, 2009 at 10:44pm

hello Charles

thanks, good to know that there are many ways..
best, K

#166807
Nov 20, 2009 at 4:21pm

Hello,
I wonder whether there is a way to make the following code a bit quicker (CPU friendlier) in Max 4.6.

I have 6 constantly changing inlets, where I look for the maximum. As a result I get a list with 0s and 1s. 1 is the maximum. The list is bang even if it doesn’t change.

In the subpatch I would like to use channel that is on the maximum to trigger a sound, but only if it can keep being the maximum for a certain amount of time (3sec).

Is there a way to make this easier or smarter perhaps?

Any help appreciated,
all the best
Krisztian

#166808

You must be logged in to reply to this topic.