Forums > Max For Live

High amplitude signals

June 8, 2012 | 9:08 pm

Hello to everyone,

I don't understand something going on, but maybe i'm just missing a basic concept..

I want to separate normal amplitude signals, below 1, from higher ones. The problem is, when the amplitude rises really much over 1 (for instance 77000 billions) , it seems like the ">1" test fails, while the "<1" test starts "banging" again.
Actually what I test is a "meter~" output , which is always positive, with a refresh time of 50 ms… but anyway I took some screenshots, since they probably can explain the issue in a better way: the first 3 are ok, while the last shows the problem.

Thanks for your patience,
cheers
Marco

[attachment=196104,3997] [attachment=196104,3998] [attachment=196104,3999] [attachment=196104,4000]

Attachments:
  1. Schermata062456087alle22.28.23.png

June 8, 2012 | 10:30 pm

Because the argument you typed into the > and < objects does not contain a decimal point, you are doing integer comparisons with a float input. The float gets converted to int by the < and > objects. But the maximum positive number that a 32-bit int can represent is 2147483647, so if you send in any float greater than that (or greater than 2147483520, in fact), it will get converted into a negative number. (Floats that large get very imprecise, but the trade-off is that they can go higher than 2147483647.) Perhaps this little patch will exemplify it. Try dragging the float number box to output numbers greater than or less than 2147483520.

– Pasted Max Patch, click to expand. –

June 8, 2012 | 11:02 pm

Thanks a lot Christopher! I just didn’t need float precision and so i chose to compare integers (and I thought it was less expensive for the cpu), but now, since i’m forced to, I won’t scale the <1. signals at all. Well, the < =1. ones.
It’s so strange that ints turn negative… is it a sort of convention, just to let you (in some way) know that the number is out of digits?
thanks again,
m


June 9, 2012 | 5:37 am

No. All 32-bit signed integers "greater than" 2147483647 are actually representations of negative numbers from -2147483648 to -1.

Bit 31 is considered the "sign" bit; if it’s set, the number is negative and all other bits mean their opposite ("ones’ complement").

Do a Wikipedia search on "Integer_(computer_science) and/or "Signed number representations" and/or "Ones’_complement" for more info.

– Pasted Max Patch, click to expand. –

June 9, 2012 | 12:19 pm

Ah yes! Bit depth is half positive and half negative, starting from 0 and coming back to -1. The negative half is the one with the last bit set… did you call it the 31st bit because the first is "bit 0"?


June 9, 2012 | 3:45 pm

Yes. I think I should have more correctly said either "bit 31" or "the 32nd bit".


June 9, 2012 | 4:08 pm

Thank you


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