route

From Pdpedia

Jump to: navigation, search
route
{{{example_image}}}
caption
Description: route messages according to first element
Abbreviation:  
Library: vanilla
Author(s): Miller S. Puckette and others
Developer(s):
Release version:
Release date: 2007
Status: active
Dependencies:
License: BSD
Website: http://crca.ucsd.edu/~msp/software.html
Programming Language:
Platform(s): GNU/Linux, Mac OS X, Windows
Language: English
Data type(s): message
Distribution(s): DesireData, PDa, Pd-extended, Pd-vanilla, puredata debian package, pure:dyne


Route messages according to their first element

Route checks the first element of a message against each of its creation arguments, which may be numbers or symbols (but not a mixture of the two unless the data types are defined explicitly), then sends the messages through the appropriate outlets.

If a match is found, and the message contains only ONE element, then a bang is sent out the corresponding outlet. If a match if found, and the message contains multiple elements (a list) \, then all the list elements except the first element is sent out the corresponding outlet. If no match is found, then the entire message is sent out the right-most outlet - the "rejection" outlet. The number of outlets is the number of arguments plus one.

These objects are offered in Pd only if you have downloaded and properly installed the appropriate library. These objects may or may not exist in a single library. The best places to find information about Pd's libraries is: www.pure-data.org and click on "Downloads" then "Software" re or iem.kug.ac.at/pdb/

routing based on reserved words: "bang", "float", "symbol", and "list"


[route] has three modes, first is float, second is symbol, and third is data type. In the first two modes, the first element of the set is stripped off by [route]. In the third mode, [route] outputs the same atom type (bang->bang, float->float, symbol->symbol).

numeric arguments:

These all output the as same atom type that is routed:

In this case, the creation arguments are all numbers and [route] will therefore assume that it should attempt to match messages that are data type "float". All messages that are not numbers will be output through the right-most outlet.

symbolic arguments:

Lists do not behave the same with [route list] even though it is interpreting incoming lists, not just routing by keyword \, as in the second symbol mode.

In this case, the data type 'symbol' is implied by the creation arguments and therefore this [route] object will match symbols only. Symbolic messages that do not match any of the arguments \, and all numbers, will be output through the right-most outlet.

RELATED OBJECTS

If necessary, messages of different data types can be matched by the [route] object if the data type is explictly defined in the creation arguments.

In the example below, instead of matching the 'value' of a message, the [route] object will match 'data type': i.e. lists will be sent through the first outlet, floats will be sent through the second outlet, symbols through the third outlet, bangs through the fourth outlet. The fifth outlet will then output anything that does not match one of the previously defined data types (i.e. the "pie" message below is a text message that hasn't been defined as a 'symbol' - hence, Pd cannot determine which data type it is and it will be output through the right-most outlet).

SPECIAL CASES OF LISTS.

[trigger]-style shortcuts don't work: "route b f s l" != "route bang float symbol list"

a float

definitely a float!

a list (of floats)

a list of symbols

a bang

a symbol

none of the above!

An empty list is translated into a bang

A list with only one float is translated to a float

A list with only one symbol is translated to a symbol


Contents

[edit] Inlets

[edit] Outlets

[edit] Arguments

[edit] Messages

[edit] Similar objects

See sroute, a settable route.


Personal tools