Namespaces

Variants
Actions

unpack

From Cycling '74 Wiki
Revision as of 17:10, 24 July 2013 by Corymetcalf (Talk | contribs)

Jump to: navigation, search

Contents

unpack online refpage

Using the unpack object

unpack allows us to break lists apart into their component pieces. This can be useful in many contexts, such as performing calculations on a part of a list, accessing data from a getattr object in a physics environment, change the order of messages in a list, and much more. It can also be used to convert messages of one type into another, such as int-to-float or the other way around. Often used together with other list processing objects such as pack, route, and combine to name just a few, unpack is a key part of managing lists.

Like pack, the unpack object has as many outlets as arguments, with each outlet passing values of the same type as the corresponding argument. Lists longer than the number of outlets are truncated, while those shorter fill as many outlets as there are elements in the list with the first message in the list coming out the left outlet.

For a description of the different conversion results, refer to the help patch or reference file.

unpack Tutorials

unpack is introduced together with its inverse object, pack, in Max Basic Tutorial 9: Mouse Drawing. unpack is used here to break out the x and y coordinates from the lcd object so we can use them to generate basic drawing commands, allowing us to draw rectangles and circles in addition to lines.


unpack Tips and Workarounds

Often we want to have more than one interface to work with data, but also want each interface to reflect changes made in the others. This patch uses unpack to parse out RGBA data from a swatch object so we can also use flonums to fine tune the data:

-- Pasted Max Patch, click to expand. --

Need to unpack a list without converting anything? Try using unjoin

-- Pasted Max Patch, click to expand. --

Third-Party Max externals similar to the unpack object

Maxobjects.com listing for the unpack object

People who looked at/used this object also looked at....

Errors or Clarifications

(please list things that you believe to be errors or omissions from the existing refpage)