Forums > MaxMSP

Practical difference between int 0 and float 0 for "line~"?

May 14, 2014 | 10:09 pm

Hello, I was tackling "MSP Tutorial 3: Wavetable Oscillator", and noticed the author used the message of "0, 1. 20 0.5 80 0.125 500 0. 400" to be sent to "line~" for ADSR purpose.
Is there any practical reason behind the differentiation between "0" and "0."?
Why this shouldn’t be "0., 1. 20 0.5 80 0.125 500 0. 400" or "0, 1. 20 0.5 80 0.125 500 0 400"?

Many thanks for your knowledge,

May 14, 2014 | 10:46 pm

"Is there any practical reason behind the differentiation between "0" and "0."?"

No practical reason in that tutorial. The message is sent to ‘line~’ the signal-rate object(signals are always floating-point/decimal-numbers), but might have a more practical reason if used with the non-signal version ‘line'(see helpfile, shows you how it can use integers or floats).
Where the signal-version ‘line~’ is concerned, you can leave decimals out wherever you don’t need them(even the ‘1.’ could be written as ‘1’).

May 20, 2014 | 1:50 pm

One minor thing: I’d recommend that you not use the "initial_target, target time target time" format in favor of "initial_target 0. target time target time". The first one will send it in two messages and you may see slight timing differences on performing the envelope. If you use the second one, all of the messages arrive at line~ in the same message so the performance of the envelope will always be exactly the same.

You can also force function to do this by setting it to line mode, though my preference is to put a "route list" between function’s 2nd outlet and line~’s input, because most of the time I don’t want my envelopes resetting all the way to 0 if they are not at 0 already.

May 22, 2014 | 8:42 am

Hi, RAJA_THE_RESIDENT_ASSWIPE. Thanks a lot again.

From your post, these are the knowledge I didn’t know and I find it useful.

signals are always floating-point/decimal-numbers

Where the signal-version ‘line~’ is concerned, you can leave decimals out wherever you don’t need them(even the ’1.’ could be written as ’1′).

May 22, 2014 | 9:18 am

Thank you very much, PETER MCCULLOCH.

Could you kindly give me the example of "initial_target, target time target time" and "initial_target 0. target time target time"?

Also I am not sure about "route list". It would be great if you could possibly show me the simple example of the patch.

May 22, 2014 | 10:14 am

Sure, here’s a couple of examples.

– Pasted Max Patch, click to expand. –
May 22, 2014 | 10:54 am

You are so kind!
Thank you very much. That helps me a lot.

March 18, 2015 | 7:40 am

The Decimal, Double, and Float variable types are different in the way that they store the values. Precision is the main difference where float is a single precision (32 bit) floating point data type, double is a double precision (64 bit) floating point data type and decimal is a 128-bit floating point data type.

Float – 32 bit (7 digits)

Double – 64 bit (15-16 digits)

Decimal – 128 bit (28-29 significant digits)

More about…..


March 19, 2015 | 5:09 am

Lynda’s note is correct as far as it goes, but that all has nothing to do with how Max passes values in messages. Max has only two numeric data types: ints and floats. In 32-bit Max, floats are always 32-bit values, and both ints and floats fit nicely into a data structure called an Atom that Max uses for passing values in messages.

What you do need to be aware of is that Max automatically converts ints to floats as needed (and vice versa). If an object (like line~) is expecting a float but receives an int, the int simply gets converted to the equivalent float. So, back to Masa’s question, in line~ the int 0 gets converted to a float 0. and all is well.

There is some fine print here: really large integers lose precision when converted to floats; floats have some idiosyncrasies, like distinguishing between positive and negative zero; and so on. For the most part you don’t need to worry about these details, but if something isn’t working the way you expect, that’s where you need to look for answers.

Once more to Masa’s question: you don’t really need to worry about sending int zero or float zero to line~. BUT, if you’re worried about nanoseconds in a patch, you might prefer to use the float. I don’t how many times I’ve written this, but converting between int and float uses a surprising amount of CPU. It’s relatively minor compared to the CPU used in passing a single message through a patch cord, but still, if you’re worried about nanoseconds, try to give an object the numeric type it wants.

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

Forums > MaxMSP