reroute

Created by Panaiotis
© 2001 by Panaiotis. All rights reserved.

General

Integer re-router: Reroutes 8 integer streams to any of up to 32 outlets. More than one inlet may be directed to an outlet, but each inlet may be directed to only one outlet at a time. (for matrix rerouting, see the matrix object).

Input

  int in leftmost inlet assigns an inlet to any outlet. integers are received in pairs; the first indicates which inlet is being assigned. The second integer received assigns it to an outlet. Numbers are given as separate messages or lists. It is recommended that a message object be used to preserve the pairing order:
   

assigns a variable inlet to outlet 2.

    It is possible to get the pairing off by sending (theoretically) two inlet integers followed by (theoretically) an outlet assignment. In actuality, what has been sent is an inlet/outlet pair followed by a dangling inlet indicator. There are a couple ways to correct this disorder. The safest is to send list pairs instead (see list below). Otherwise, send an integer N<0 to the leftmost inlet. This clears the pairing sequence.
    Inlet indicators range from 1 to 8. Outlet assignments range from 0 (off) to 32.
  int in data inlets d1 to d8 will be sent to its assigned outlet.
  list pair of numbers representing inlet to outlet assignment. Same rules as above apply. The first two arguments in the list must be integers; reroute ignores additional numbers.  and  are treated the same. It is the author’s belief that reroute will process number pairs slightly faster than the list pair. However, a list will always maintain the correct inlet/outlet pairing.

Arguments

  int arg1 number of inlets (maximum 8).
  int arg2 number of outlets (maximum 32).

Output

  int Integers received in data inlets are passed out its assigned outlet.

Examples

see also

gate, matrix

 

Note about efficiency of gate, reroute, and matrix

The following discussion will only be applicable in extremely time critical processes. For the most part, you should not be concerned with this and in my own experience, I have not found a measurable performance difference between the three objects. This discussion is from a theoretical analysis only.

reroute, gate, and matrix have crossover functions. If a single gate can replace either a single reroute or matrix object, gate will process faster than either reroute or matrix.

In the example above, an integer stream is routed to one of three outlets. gate does no interpretation of the data. reroute accepts the data and passes it to its assigned outlet. matrix checks the data and sends the data through a list of outlets. However, the matrix configuration shown above has the added possibility of sending its data to any combination of outlets. The equivalent gate configuration is:

The speed factor now is less sided toward the gate since Max must send integer data to three objects instead of one. matrix has the additional advantage of having an assortment of configuration assignment tools that may substantially reduce the number of objects needed to route information.

There are several factors to keep in mind when choosing which object to use: Efficiency of processing data.

Type of data being sent.

Number of objects and patch chords necessary to create the routing.

The logic necessary to configure the routing assignments.
 
  Comparison table of routing objects
 
  gate reroute matrix
Max Inlets 1 8 253
Max Outlets 9 32 253
Data types all integers all
Speed of data processing Fastest on one to one basis. Several gates for data distribution reduce its speed efficiency rating. Slower than gate but faster than matrix in several to one of many configuration. Slower than one gate or reroute object but faster than both when distributing data to a combination of outlets.
Distribution of data: inlets to outlets 1 to any one of several. Least flexible. Several. Each to any 1 of many. More flexible than gate but less than matrix. Many. Each to any combination of many.
Supporting objects May need many patch chords and additional gate and other objects to create the equivalent matrix. The logic in handling sophisticated routing changes could become quite extensive. Fewer objects needed than with the gate, especially when handling multiple inlets. Routing configuration more manageable than with multiple gates. matrix substantially reduces the number of patch chords and additional objects necessary in matrix routing, especially when distributing data to combinations of several outlets.
Configuration commands Simple integer. Quick for single gate. pairs of numbers or list or pairs.  Highly versatile. Much faster and simpler than multiple gate or reroute objects.

Typical usage:
 
1 to one of (up to 9) gate
1 to more than 9 but all integer data reroute
(2 to 8) inlets sent to one of up to 32 outlets (all integer data) reroute
(1 to 253) inlets sent to a combination of up to 253 outlets matrix
Flexible routing configuration matrix

Use reroute if you need more gate outlets than gate provides or more than one gate object to accomplish the same thing as a single reroute object. reroute is slightly faster than matrix. Use matrix if you need to distribute data streams to multiple outlets, if you need more inlets than reroute provides, or data other than integers. If you can replace more than one object with a single matrix object, matrix will most likely process data faster than the configuration with several objects.