Practical difference between int 0 and float 0 for "line~"?
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,
"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’).
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.
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′).
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.
Sure, here’s a couple of examples.
----------begin_max5_patcher---------- 1431.3ocyZ00aiiBE84zeEH+3pNQf+N6acGUsuL6LqT2U6CippH1zDl0wDgs SamQS+sOXv1wtwogjXSajpcLfgKGt2y4Bo+3hIVyYORxr.+N3qfIS9wESlHK prfIUOOwZE9wnDblrYVQrUqHo4VWppKm7Xtr7+gthlt.7.MIALm.xWR.Y3UD w2ivEYDvJRVFd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MiCiSqm 2s6rV3ey4bmg2PhuCmmyoyEJfa+VV0BQ0JQIVmTPX2WWbc4ss+DV5h8udzoo YKY7bMaa8zG1ScqDqMk08gflbmdQ8XoKkeu0RSo4hvmF+hZDrSiJDMJK+I0B iqpdoma8sggD62ddfx7nxOzwSxA4XO06zXhpb05iKZLxrdOvRF9gmkYELPnC JLTRMOSdKDcp7zuB53aNzo7rLGJ+FGwFtJyX0UjSicnjDyI7TyXcKO0dEz7L PpqZycWsA92KIg59dJGziDDeKRmzYLyl7b4iUvx3kX3QDGIeeIqwK9OLPZ2k k2EuxXE7nZKn9v1Aas8XRVNMsISiut82gCfZZzRZbLIs85ZLMqboVNGf8txo q8T9qScP6oqMuq4rh1IHCAm4HEMUpCNt9SCa3EamO2.NMP5BqPy.q15XONFy dzxsq7HkMjamuFlSf4PG3vGDDVk3Xn7V2X.QQiPLfsNgxuXpNpnpst9blwdz ID.4ZLyAMDLuCn4.6D7uG3wbqVHcXzQliQGoi2LxbQW5.OlyYVGeYjwrlPMr lYFSqSWqwLXSfFVS36JN4.isR4pAE3oxHq14.d85MDdVUWJMDwdp9FiKOisK kORSUOJ2IiEmrgV2dUCvbwNjxEaOpfq1pxig9h8nHFmedwuvOJDWU -----------end_max5_patcher-----------
You are so kind!
Thank you very much. That helps me a lot.
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)
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.
Forums > MaxMSP