Dynamic inlets / outlets
I saw in the Max SDK that it was possible to dynamically create inlets using the inlet_append, inlet_delete, inlet_count, same for outlets, however these functions are not documented.
I saw in another post from 4 months ago that Cycling did not officially support yet these functions, but has this changed since the Max 6 release ? They could prove really useful.
However, the arguments described in the prototypes are not very explicit. Does anyone have any documentation on this set of functions, or code excerpts using them ?
Martin Di Rollo
Here’s an example from the plot~ object when you change the attribute for the number of plots:
object_method(&x->p_box, gensym("dynlet_begin")); dsp_resize((t_pxobject*)x, numplots); object_method(&x->p_box, gensym("dynlet_end"));
This assumes you have an audio object. I’d need to dig a little more to find out what happens for dynamic inlets in a plain Max object.
Thanks a lot ! I’ve been testing around with it, and it works !
Do you know if there is a similar way of dealing with outlets ? dsp_resize only allows for inlet creation, not outlets.
This would be for audio objects, (MSP object with signals).
This is untested code, which should be documented made into an example at some point, but it should get you going:
// start the transaction with the box t_object *b = NULL; object_obex_lookup(x, _sym_pound_B, (t_object **)&b); object_method(b, gensym("dynlet_begin")); // update outlets with one or both of these calls //outlet_delete(outlet_nth((t_object*)x, i)); //outlet_append((t_object*)x, NULL, gensym("signal")); // end the transaction with the box object_method(b, gensym("dynlet_end"));
Thanks ! This is exactly what I was looking for, it works just fine.
I’d have a final question about this which could simplify my code :
Do you have an example of how inlet_append is used ? I guess it must be quite similar to outlet_append, but I’m having trouble with the void* who argument, which I don’t know what it actually refers to.
Thanks again !
Forums > Dev