Using an outlet as a method parameter in min-api

Shakeeb Alireza's icon

In min-api, is there a way to use / call an outlet<> instance as a parameter in a method?

For example:

void Myclass::handle_float_output(outlet<> output, float value);

This compiles ok, but when one tries to use it raises an error:

call to implicitly-deleted copy constructor of 'outlet<>'

Any idea how to do this in min-api? In the c-based max-sdk, this is trivial to do as outlets have the void* type.

Jan M's icon

Hi SHAKEEB ALIREZA,

yes in principle you can do this. You need to pass a pointer to the outlet into your function and then call the send method on the outlet.

something like

void Myclass::handle_float_output(outlet<> *out, float value) {
	atoms msg_atoms;
	msg_atoms.push_back(value);
	out->send(msg_atoms);
}

in your example the output variable is passed by copy. But outlets are constructed only once on object creation and don't have a copy constructor, hence it cannot be called.

Shakeeb Alireza's icon

@JAN M

Thanks for your helpful advice!