Max API  8.0.2
Inlets and Outlets

Routines for creating and communicating with inlets and outlets. More...

Functions

void * inlet_new (void *x, C74_CONST char *s)
 Use inlet_new() to create an inlet that can receive a specific message or any message. More...
 
void * intin (void *x, short n)
 Use intin() to create an inlet typed to receive only integers. More...
 
void * floatin (void *x, short n)
 Use floatin() to create an inlet typed to receive only floats. More...
 
void * outlet_new (void *x, C74_CONST char *s)
 Use outlet_new() to create an outlet that can send a specific non-standard message, or any message. More...
 
void * bangout (void *x)
 Use bangout() to create an outlet that will always send the bang message. More...
 
void * intout (void *x)
 Use intout() to create an outlet that will always send the int message. More...
 
void * floatout (void *x)
 Use floatout() to create an outlet that will always send the float message. More...
 
void * listout (void *x)
 Use listout() to create an outlet that will always send the list message. More...
 
void * outlet_bang (void *o)
 Use outlet_bang() to send a bang message out an outlet. More...
 
void * outlet_int (void *o, t_atom_long n)
 Use outlet_int() to send an int message out an outlet. More...
 
void * outlet_float (void *o, double f)
 Use outlet_float() to send a float message out an outlet. More...
 
void * outlet_list (void *o, t_symbol *s, short ac, t_atom *av)
 Use outlet_list() to send a list message out an outlet. More...
 
void * outlet_anything (void *o, t_symbol *s, short ac, t_atom *av)
 Use outlet_anything() to send any message out an outlet. More...
 
void * proxy_new (void *x, long id, long *stuffloc)
 Use proxy_new to create a new Proxy object. More...
 
long proxy_getinlet (t_object *master)
 Use proxy_getinlet to get the inlet number in which a message was received. More...
 

Detailed Description

Routines for creating and communicating with inlets and outlets.

Function Documentation

◆ bangout()

void* bangout ( void *  x)

Use bangout() to create an outlet that will always send the bang message.

Parameters
xYour object.
Returns
A pointer to the new outlet.
Remarks
You can send a bang message out a general purpose outlet, but creating an outlet using bangout() allows Max to type-check the connection a user might make and refuse to connect the outlet to any object that cannot receive a bang message. bangout() returns the created outlet.

◆ floatin()

void* floatin ( void *  x,
short  n 
)

Use floatin() to create an inlet typed to receive only floats.

Parameters
xYour object.
nLocation of the inlet from 1 to 9. 1 is immediately to the right of the leftmost inlet.
Returns
A pointer to the new inlet.

◆ floatout()

void* floatout ( void *  x)

Use floatout() to create an outlet that will always send the float message.

Parameters
xYour object.
Returns
A pointer to the new outlet.

◆ inlet_new()

void* inlet_new ( void *  x,
C74_CONST char *  s 
)

Use inlet_new() to create an inlet that can receive a specific message or any message.

Parameters
xYour object.
sCharacter string of the message, or NULL to receive any message.
Returns
A pointer to the new inlet.
Remarks
inlet_new() ceates a general purpose inlet. You can use it in circumstances where you would like special messages to be received in inlets other than the leftmost one. To create an inlet that receives a particular message, pass the message's character string. For example, to create an inlet that receives only bang messages, do the following
inlet_new (myObject,"bang");
To create an inlet that can receive any message, pass NULL for msg
inlet_new (myObject, NULL);
Proxies are an alternative method for general-purpose inlets that have a number of advantages. If you create multiple inlets as shown above, there would be no way to figure out which inlet received a message. See the discussion in Creating and Using Proxies.

◆ intin()

void* intin ( void *  x,
short  n 
)

Use intin() to create an inlet typed to receive only integers.

Parameters
xYour object.
nLocation of the inlet from 1 to 9. 1 is immediately to the right of the leftmost inlet.
Returns
A pointer to the new inlet.
Remarks
intin creates integer inlets. It takes a pointer to your newly created object and an integer n, from 1 to 9. The number specifies the message type you'll get, so you can distinguish one inlet from another. For example, an integer sent in inlet 1 will be of message type in1 and a floating point number sent in inlet 4 will be of type ft4. You use addinx() and addftx() to add methods to respond to these messages.

The order you create additional inlets is important. If you want the rightmost inlet to be the have the highest number in- or ft- message (which is usually the case), you should create the highest number message inlet first.

◆ intout()

void* intout ( void *  x)

Use intout() to create an outlet that will always send the int message.

Parameters
xYour object.
Returns
A pointer to the new outlet.
Remarks
You can send a bang message out a general purpose outlet, but creating an outlet using bangout() allows Max to type-check the connection a user might make and refuse to connect the outlet to any object that cannot receive a bang message. bangout() returns the created outlet.

◆ listout()

void* listout ( void *  x)

Use listout() to create an outlet that will always send the list message.

Parameters
xYour object.
Returns
A pointer to the new outlet.

◆ outlet_anything()

void* outlet_anything ( void *  o,
t_symbol s,
short  ac,
t_atom av 
)

Use outlet_anything() to send any message out an outlet.

Parameters
oOutlet that will send the message.
sThe message selector t_symbol*.
acNumber of elements in the list in argv.
avAtoms constituting the list.
Returns
Returns 0 if a stack overflow occurred, otherwise returns 1.
Remarks
This function lets you send an arbitrary message out an outlet. Here are a couple of examples of its use.

First, here's a hard way to send the bang message (see outlet_bang() for an easier way):

outlet_anything(myOutlet, gensym("bang"), 0, NIL);
Remarks
And here's an even harder way to send a single integer (instead of using outlet_int()).
t_atom myNumber;
atom_setlong(&myNumber, 432);
outlet_anything(myOutlet, gensym("int"), 1, &myNumber);
Notice that outlet_anything() expects the message argument as a t_symbol*, so you must use gensym() on a character string.

If you'll be sending the same message a lot, you might call gensym() on the message string at initialization time and store the result in a global variable to save the (significant) overhead of calling gensym() every time you want to send a message.

Also, do not send lists using outlet_anything() with list as the selector argument. Use the outlet_list() function instead.

Referenced by max_jit_mop_jit_matrix(), max_jit_mop_outputmatrix(), and max_jit_obex_dumpout().

◆ outlet_bang()

void* outlet_bang ( void *  o)

Use outlet_bang() to send a bang message out an outlet.

Parameters
oOutlet that will send the message.
Returns
Returns 0 if a stack overflow occurred, otherwise returns 1.

◆ outlet_float()

void* outlet_float ( void *  o,
double  f 
)

Use outlet_float() to send a float message out an outlet.

Parameters
oOutlet that will send the message.
fFloat value to send.
Returns
Returns 0 if a stack overflow occurred, otherwise returns 1.

◆ outlet_int()

void* outlet_int ( void *  o,
t_atom_long  n 
)

Use outlet_int() to send an int message out an outlet.

Parameters
oOutlet that will send the message.
nInteger value to send.
Returns
Returns 0 if a stack overflow occurred, otherwise returns 1.

◆ outlet_list()

void* outlet_list ( void *  o,
t_symbol s,
short  ac,
t_atom av 
)

Use outlet_list() to send a list message out an outlet.

Parameters
oOutlet that will send the message.
sShould be NULL, but can be the _sym_list.
acNumber of elements in the list in argv.
avAtoms constituting the list.
Returns
Returns 0 if a stack overflow occurred, otherwise returns 1.
Remarks
outlet_list() sends the list specified by argv and argc out the specified outlet. The outlet must have been created with listout or outlet_new in your object creation function (see above). You create the list as an array of Atoms, but the first item in the list must be an integer or float.

Here's an example of sending a list of three numbers.

t_atom myList[3];
long theNumbers[3];
short i;
theNumbers[0] = 23;
theNumbers[1] = 12;
theNumbers[2] = 5;
for (i=0; i < 3; i++) {
atom_setlong(myList+i,theNumbers[i]);
}
outlet_list(myOutlet,0L,3,&myList);
Remarks
It's not a good idea to pass large lists to outlet_list that are comprised of local (automatic) variables. If the list is small, as in the above example, there's no problem. If your object will regularly send lists, it might make sense to keep an array of t_atoms inside your object's data structure.

◆ outlet_new()

void* outlet_new ( void *  x,
C74_CONST char *  s 
)

Use outlet_new() to create an outlet that can send a specific non-standard message, or any message.

Parameters
xYour object.
sA C-string specifying the message that will be sent out this outlet, or NULL to indicate the outlet will be used to send various messages. The advantage of this kind of outlet's flexibility is balanced by the fact that Max must perform a message-lookup in real-time for every message sent through it, rather than when a patch is being constructed, as is true for other types of outlets. Patchers execute faster when outlets are typed, since the message lookup can be done before the program executes.
Returns
A pointer to the new outlet.

Referenced by max_jit_mop_matrixout_new(), and max_jit_mop_setup_simple().

◆ proxy_getinlet()

long proxy_getinlet ( t_object master)

Use proxy_getinlet to get the inlet number in which a message was received.

Note that the owner argument should point to your external object's instance, not a proxy object.

Parameters
masterYour object.
Returns
The index number of the inlet that received the message.

Referenced by max_jit_obex_inletnumber_get().

◆ proxy_new()

void* proxy_new ( void *  x,
long  id,
long *  stuffloc 
)

Use proxy_new to create a new Proxy object.

Parameters
xYour object.
idA non-zero number to be written into your object when a message is received in this particular Proxy. Normally, id will be the inlet number analogous to in1, in2 etc.
stufflocA pointer to a location where the id value will be written.
Returns
A pointer to the new proxy inlet.
Remarks
This routine creates a new Proxy object (that includes an inlet). It allows you to identify messages based on an id value stored in the location specified by stuffLoc. You should store the pointer returned by proxy_new() because you'll need to free all Proxies in your object's free function using object_free().

After your method has finished, Proxy sets the stuffLoc location back to 0, since it never sees messages coming in an object's leftmost inlet. You'll know you received a message in the leftmost inlet if the contents of stuffLoc is 0. As of Max 4.3, stuffLoc is not always guaranteed to be a correct indicator of the inlet in which a message was received. Use proxy_getinlet() to determine the inlet number.

Referenced by max_jit_obex_proxy_new().