Mathematic theory behind "kink~"

Qian Liu's icon

Is it possible to know the implementation of the objects in max/msp? For example, I want to know the mathematic theory behind the object "kink~", but I only can find the description of the relation between the output and input instead of the code of its implementation.

Max Gardener's icon

I'm not sure what you mean by "theory" here - the prose text in the kink~ object's help file (which is taken directly from the refpage, by the way) describes quite precisely how the calculation is done.

Roman Thilenius's icon

the ref page says that it applies a "slope".

i would more generally say that the math behind it is in the field of "scaling a range". like tanh, cos, or *.

but both these desciptions wont explain what exact formula is used in case someone wants to replicate the functionality.

i am big fan of helpfiles such as the mtof one, which has always been revealing exactly what it does.

mzed's icon

Apparently, you haven't looked at mtof.maxhelp in a while.

For kink~, I think the help file says:

if ( * slope) < 0.5 then output = * slope
else, a complimentary slope will be applied that connects 0.5 to 1.0 over the remaining input values.

I think that the complementary slope would be something like 0.5/(1-(0.5/slope)), with an offset applied (1 - complementarySlope?) to make it fit.

I'm just having my coffee, so excuse me if the math is not exactly correct.

mzed's icon

Seems that the coffee had done its job:

Max Patch
Copy patch and select New From Clipboard in Max.

Roman Thilenius's icon

haha, but what IS slope? the rest is clear.

mtof ... duh. not even in the ref. and i bet it has changed and i will find out when the first incompatibilty occurs.

Max Gardener's icon
Christopher Dobrian's icon

Re mtof, ftom, dbtoa, and atodb formulae:Pitch and loudness formulae

Roman Thilenius's icon

seems i just dont know the word. mb the OP had the same problem.

christopher: how do you know when it is no longer in the helpfile?

ward de jager's icon

This is the kink~algo in gen ~

Kink value is between 0.0 - 1.0
x= phase

d= kink value

when x <d = x/2d

when x > d = (((x-d)/1-d )+1)*0.5