I’ve just discovered you can use

min(number1,number2)

and

max(number1,number2)

in the Mathematical Expression patch.

min simply sets the output to the smaller of the 2 inputs, while max sets the output to the larger input number. You could quite easily combine the two to get an equivalent of the GLSL clamp() function.

Not very exciting, you might think, but it impresses me…

I’ve never liked the the Math patch, purely based on the amount of screen estate it takes up. The Mathematical Expression patch is much neater, and also somehow makes it easier for me to pretend I know something about maths (which is patently not the case, sadly).

EDIT:

Just to clarify: I’ve been using the Mathemetical Expression patch for ages. I’ve just discovered a couple of new features I didn’t know about before.

### Like this:

Like Loading...

I love the Min/Max feature. Use it a lot. Should probably learn to write it in the expression patch though… not really touched that one!

oh fuck. you mean you’ve been struggling without it for this long? i feel remiss in my duties. its even got the ternary operator in there ffs! not to mention the readability it gives to your patches, with named inputs etc.

Hi toby,

I’ve been using the Mathemetical Expression patch for a while, just never had reason to try min and max before. I’m sure I’ll be using them in the future though.

You’re sacked, by the way 😉

a|x

The parser also supports the following functions: sin(), cos(), tan(), asin(), acos(), atan(), atan2(), sinh(), cosh(), tanh(), exp(), ln(), log(), abs(), sqrt(), ceil(), floor(), min(), max() and rand(). Some predefined constants are provided: pi and e.

Hi Carter,

thanks for the list. I’ve used PI before, but I didn’t realise rand() was supported. I may use that in future.

Cheers,

a|x

If anyone gets here looking for a way to raise a value to an exponent (ie a to the power of b), let it be known that there is no direct, built-in way to do that. But you can do exp(ln(a)*b), which does the same thing (it’s just wordier)

Cheers Mark, that’s good to know.

a|x