I am looking for an equivalent of the [modulo] object (of puredata) in maxmsp
the modulo is a math operator a bit equivalent to % instead that with negative value it doesn’t output the same thing:
(e.g. if I want [modulo 33] of -1 give 0 and [modulo 33] of -2 give 32 [modulo 33] of -33 give 1)
As far as I know puredata has a [mod] operator equivalent to % in Max.
Can you point to some definition/documentation of your [modulo] object?
sorry I mean the [mod] object
and [%] doesn’t handle negatives value in the same way [mod] does
But there should be a proper documentation how [mod] handles negative values.
What you describe looks rather strange to me..
from pd documentation :
[mod] takes a number in its left inlet and will divide that number by either the creation argument or the number given at its left inlet and will produce the value of the remainder at its outlet. If no creation argument is given, then the default value is 1
(nothing about negative values)
The Max [%] object handles modulo exactly the way most C implementations do, which is mathematically incorrect.
[expr] may do the trick, otherwise hang a [if $i1 >= 0 then $i1 else out2 $i1] after the [mod] object. Hang a [+] object after the if’s second outlet, make sure the [+] operand is set to your modulo. Et voilà!
Interesting. So does pd have a mathematically correct implementation of modulo?
"Boute argues that Euclidean division is superior to the other ones in terms of regularity and useful mathematical properties, although floored division, promoted by Knuth, is also a good definition. Despite its widespread use, truncated division is shown to be inferior to the other definitions."
pd (apparently) uses Euclidean, max truncated division.
Time for an attribute?
Thanks for the link. Euclidean modulo seems useful in practice (eg. result is always positive).
So based on the article I’ve made an abstraction for usage in Max.
----------begin_max5_patcher---------- 565.3ocyV9sjSBCEF+Z3oHSF8Fsamj.zVbFcFczK8IvYGGVRVabfjNkfVcm8 cWxev15R2FnsXuAJmbZ422WN8CdHL.dmbCqBBdC3KfffGBCBLkzEBbWG.Ky1 jWjUYZClKKKYBEbhcMEaixT+S04EbJKS7YIstP1tdAWvxk0BSSDWw6kBUE+2 LcMLZJxUdUlJeIW7sutlkqrLsPuJHBGoOkLSejjNEAt08UD0kbQASYXC6Jxo Fhj288avyfa6TVqZaEsCIhrRCIv2ulmU.9frfB0q9XXn9vjSzX9H+G7J4ZXu 0NIJ1nZ7VsiWzGsmbUncJSP6u3WX2wQCU6wil1Ere1bGehz42CdAG+NDPsjI .X.qnhAtA21mkI0uVwr5EB+q15wDR7biyDQLmv396Sjt8I7n4Su5fNBWGZL. Sw4FoolnCxzjmySHc3In+2dxqO6dh1.lzZMCvSRGMKw9qCOVx.Yt8gAIsG8d j+HOQnMJS294ON3st7flOaSDZHfnu5v4BSFV1f0lvyrYmIw8NZ3.Injy+VtA COBF67O6FYNegOCCnmJxnmet9TGFNAkY2+7aJuCgQtrB6.S4u7bGb4lhGbtE 9jysL2Jyqw9OulrgVc88soJY857VU6P.rEXJqRwEYJtTrSOw60yRNs4kl1ci sjSWIarPGBfa6bKyWhz2M7QHJcTIR+H2iZRo6g8EGIhGHY3d7XxKjF0MtHeH hb8gD55CoQcRJ1ChlMpdT5ElnlKdL7O.Yio2AC -----------end_max5_patcher-----------