Forums > MaxMSP

Finding the lesser of two numbers

November 3, 2008 | 3:38 pm

Alright, maybe I’m just making this far too difficult on myself again. I’m taking two clicks on a kslider, creating a list, and determining the number of semitones between selected notes. I now need to determine which of the two notes is lowest, and send on this MIDI number. The question sounds so easy that I’m sure the answer is easy. So, either my logic is seriously flawed in the attached patch, or I’m just creating obstacles that I shouldn’t have to deal with!

– Pasted Max Patch, click to expand. –

November 3, 2008 | 3:54 pm

On 3 nov. 08, at 16:39, Brennon Bortz wrote:

>
> Alright, maybe I’m just making this far too difficult on myself
> again. I’m taking two clicks on a kslider, creating a list, and
> determining the number of semitones between selected notes. I now
> need to determine which of the two notes is lowest, and send on this
> MIDI number. The question sounds so easy that I’m sure the answer
> is easy. So, either my logic is seriously flawed in the attached
> patch, or I’m just creating obstacles that I should have to deal with!

Hi,

Have a look to [minimum].

ej


November 3, 2008 | 3:56 pm

Thanks, Emmanuel. I’m surprised [minimum] isn’t cross-referenced in the reference or help files for [< ].

Nonetheless, mine was a problem of order of operations… A couple of triggers fixed it!

———-begin_max5_patcher———-
955.3oc0Y0saaBCF85jmBDWmF4+wrKlzdNlllHIzVuRLQAiVWq569.aSKIa.
1ARZxME84PCmywmuev404yBWk+bZQXvWB9dvrYuNe1L8R0KLyFOKbaxyqyRJ
z2VnL824q9U3ByGoReVoWVEHBDMqlWpxRUp+rK07MGJjpvElKA+vdS6RTqeT
He3m6SWqL2GIhsDrH.ii0WPKoKBPfkf2+eDazOrJ.bGl27ztOWpjIa0Oqvus
Wjj07IxxsBYERzHG9whF7oWE05KoP7h9KAhVBpW8s4yq+yhq.kgwrJC1AkAe
inLEA2WJ2D1MqifZi.AR0WzbuKVilFVC97YMgfbm0nqMVupToxkc52WkHenW
mNk.qILEE0v6dXOzCNB+LHCG3LYf7yLY5vO1eso9XmM8Dy4CWTBR7znh9+79
rmdd5xgMu0M4.diHGEoYAf.X+o.K93pK41jXc5.g0a5.XRprgO6JzWOYCSib
DgF1vbqj9TJ2kr9oJKCXri7XUGDUqNr39LK2JS77RVvC6yK2Ef5TcbMIBgzo
OrdGOXZpxb90kjUEiNKBZFMt2dr73Iwnb9SitarxgScg3rqspJicfKFzVKkO
7.Wb54dfqxsqR2OTcvg4DlXb1lYI6kSQwWcUBmFQnwV6jHDcy7BvEoaEUF9z
hvgKvg0d5HZeTmEes89fOUjI1LrAXnxZX6PR5ldDShME2wrRrdKdsuxqoe5L
Pu6661mVjJUIJQtrERzOZv+.iVRiFSgYB4wmrllW0qendUjWtecidzjEG7A0
1jVnDRMNZcS0kuZcSOJ1rIU1dyaqXyt7Jc0BBFAW2K.iztIl4xwQQMQTazAD
ag2L4HP9+YRc9pWLwhOpttHCXZ7ePDJVaWnUEJn1nQxji.YG6IL+XxXwTrqX
B5uOgoKzPYllO0Qi0KvbAswWTEj6hBx7DSVWGASa4A0QiDsDWTP3EU.qO0pg
gDwSAjGWKYTSJcDvpisivbcBdT0fdTazHYBB5BSfmjUvhcBF1hI1Hr4G8fPM
E0piF6dhKLo9jiuj9DhKXBeYwD3fJicriy8bG2TvjZ5n13jqilBzNnBdYy9w
NHfQdV8jAL8rMGctsajNZB.6TOJxX2Sc.R3quQJv3SazSygyvpdEllnwtk5h
ATW5wmAf3leVCyaZEYOU+H5kYDRL+j5vXGjmvouGMVsk6h1B8SaIw1exHyKP
wnuGMEncHs0ywPZDSiQfZNSoCiHLd6Y7pilBKsKDwGGsIiqArlNTSAXcoo9Q
8s7q.VUvay+KKW9y5.
———–end_max5_patcher———–


November 3, 2008 | 4:05 pm

On 3 nov. 08, at 16:56, Brennon Bortz wrote:

> Thanks, Emmanuel. I’m surprised [minimum] isn’t cross-referenced in
> the reference or help files for [ Nonetheless, mine was a problem of order of operations... A couple
> of triggers fixed it!

Here's another solution using [zl sort].

ej

– Pasted Max Patch, click to expand. –

November 3, 2008 | 4:28 pm

Quote: Emmanuel Jourdan wrote on Mon, 03 November 2008 16:05
—————————————————-
> On 3 nov. 08, at 16:56, Brennon Bortz wrote:

> Note that if you search in the documentation, minimum is pretty easy
> to find;-)

Sometimes your brain just gets stuck in a rut, though…y’know? I was searching for "less", "lesser", "lower", "less than", etc.


November 3, 2008 | 4:35 pm

I’d have gone:

[if $f1 < $f2 then $f1 else $f2]

That’s easier to read than [zl sort] for me. But [minimum] is most beautiful…


November 3, 2008 | 5:31 pm

But then you have to compute the absolute difference to find the
interval.

ej

On 3 nov. 08, at 17:35, Bas van der Graaff

wrote:

>
> I’d have gone:
>
> [if $f1 < $f2 then $f1 else $f2]
>
> That’s easier to read than [zl sort] for me. But [minimum] is most
> beautiful…
> –
> SmadSteck – http://www.smadsteck.nl
> Hard- and software for interactive audiovisual sampling


November 3, 2008 | 5:41 pm

Quote: Bas van der Graaff wrote on Mon, 03 November 2008 16:35
—————————————————-
> I’d have gone:
>
> [if $f1 < $f2 then $f1 else $f2]

Yes, I know about [if]. But, anytime a help file begins: "For those stuck in traditional programming habits…", I just feel like less of a person if I must be one of "those" people. ;)


November 3, 2008 | 6:19 pm

2008/11/3 Brennon Bortz :

> Yes, I know about [if]. But, anytime a help file begins: "For those stuck in traditional programming habits…", I just feel like less of a person if I must be one of "those" people. ;)

There is a reason a tradition arises – no reason to ignore it completely, IMHO.

I use [if] all the time – particularly after counter to exit a loop -
simply because it nicely handles the associated logic in one object.


November 8, 2008 | 2:15 pm

Quote: arne wrote on Mon, 03 November 2008 18:19
—————————————————-

> There is a reason a tradition arises – no reason to ignore it completely, IMHO.
>
> I use [if] all the time – particularly after counter to exit a loop -
> simply because it nicely handles the associated logic in one object.

Don’t get me wrong…I use if statements all the time…just not in Max. It does feel so clunky and out of place within Max, and always seems as if there’s a better, more efficient way to accomplish the task at hand–whatever that may be.


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