Messages 

Pd's objects intercommunicate using messages. Data is sent from outlets, travels along the connections and is received in the inlets of objects in the patch and it is understood or decoded by objects in a specific way. These messages are usually a request to do something, in the form of a command like "open" or data to be processed.  Apart from audio signals all other data are messages. Pd messages can be of different types, such as:

  • numbers - also known as floats (floating point numbers)
  • symbols - a word or a mixture of letters and numbers
  • lists - groups of numbers and/or symbols
  • pointers - references to data stored in graphical data structures

 messages01.png

Message Boxes

Messages can go between objects directly - as they do in the bottom two rows of each group -, or be sent (or go through, as we'll see later) message boxes. Message boxes allow the user to see directly which elements are being sent.

A message box with several elements is a list. But in case there is a comma between these elements, it becomes several messages, which are sent one immediately after the other. The comma breaks the message, creating a new instance.

messages02.png

You can also send messages to receive objects (or to the Pd engine) by writing a receive symbol, the message, and a semicolon in the end. This technique is usually used to initate several parameters simultaneously.

messages03.png

Packing elements and variables

You can create more complex messages by joining several elements together - the most current object for that is [pack]. You can create lists by joining several elements: either only numbers, or mixing numbers with symbols.

messages04.png

If you want to work with a list combining fixed and variable elements, replace the variable ones with dollarsign variables. These will take on the parameters from the message that arrives to them. $1 will take the first element, $2 the second, and so on. In case you send only a number or a symbol, they will be considered to be a list with only one element.

messages05.png

And combining the power of [pack] with variables, it's possbile to build complex commands for your patches:

messages06.png

Deconstructing messages: unpack and route

After you've built and formatted the commands you need, in the next part of your patch you can decide where to send them. First we can look at [pack]'s evil twin, [unpack]. As the name says, [unpack] separates a list into it's individual elements. This can be useful after you created your list command, to distribute it into the several parts of your synthetizer patch. Be sure to match the creation parameters with the format of the list you're expecting to receive.

messages07.png

Besides deconstructing your messages, you can also sort them qualitatively, through string comparison. For that we use [route]. With [route] you can send different elements to the same input, and sort them out quite easily. For example through data types - bangs, floats, symbols, lists, or something else:

messages08.png

But making groups (or lists) of strings and parameters is the most popular way of using [route]. You can use the strings as filters to channel parameters to specific places:

messages09.png

Of course, the strings that channel (or "route") the parameters can also be numbers themselves.

messages10.png

Or, if you don't use any parameters, you can use it just to trigger events. In this case, the output of each route string is only a bang.

messages11.png

And the grand finale: combine all objects (and variables) to create your own complex commands, and distribute them through the elements of your instruments - all in the same patch:

messages12_1.png