Forums > Dev

Creating an external with a left inlet allowing floats

April 1, 2013 | 3:37 pm

I’m trying to create an external with a few inlets and I want the first one to allow floats. Regardless of what I try, however, when I send it a float in the left inlet, I see a message in the Max window that says that it doesn’t understand floats. This is what I have done so far:

In the main function:

class_addmethod(c, (method)DTNyqMultiply_f0, "ft0", A_FLOAT, 0);
class_addmethod(c, (method)DTNyqMultiply_coefficients, "list", A_GIMME, 0);
class_addmethod(c, (method)DTNyqMultiply_samplingRate, "ft2", A_FLOAT, 0);

In the "new instance" function:

// create inlets (in reverse order), and the outlet
floatin(x, 2);
inlet_new(x, "list");
floatin(x, 0); // I have tried removing this; it doesn’t make a difference
x->p_outlet = listout(x);

How can I get the left inlet to allow floats?


April 1, 2013 | 4:05 pm

Hi Antony,

To accomplish what you want, you need:

in the main function:

class_addmethod(c, (method)DTNyqMultiply_float, "float", A_FLOAT, 0);
class_addmethod(c, (method)DTNyqMultiply_samplingRate, "ft1", A_FLOAT, 0);
class_addmethod(c, (method)DTNyqMultiply_coefficients, "list", A_GIMME, 0);

In the "new instance" function:

// create inlets (in reverse order), and the outlet
floatin(x, 1);
x->p_outlet = listout(x);

the method prototyped as:

void DTNyqMultiply_float(t_DTNyqMultiply *x, double f)
{

}

will receive floats sent to the left inlet ("float").

———————————-

the method prototyped as:

void DTNyqMultiply_samplingRate(t_DTNyqMultiply *x, double f)
{

}

will receive floats sent to the right inlet ("ft1").

———————————-

…and finally the method prototyped as:

void DTNyqMultiply_coefficients(t_DTNyqMultiply *x, t_symbol *sym, long argc, t_atom *argv)
{

}

will receive lists sent to the left inlet ("list").

———————————-

You might want to read the MaxAPI SDK docs because it’s all there…

Hope this helps.

- Luigi


April 1, 2013 | 5:17 pm

That is helpful. Thanks. I think the problem is that I needed to write "float" instead of "ft0". By the way, I have been reading the SDK documentation but the examples are a bit scarce in the "Inlets and Outlets" page.


April 1, 2013 | 7:49 pm

No, the examples are not scarce at all…
The SDK docs come accompanied with many open source Max/MSP/Jitter externals.
You can check out the code and compile it on your platform.
Although reading the manual is helpful to get a general understanding of the underlying API structure, checking out the code of the examples is crucial to learn how to accomplish specific tasks in code.

- Luigi


Viewing 4 posts - 1 through 4 (of 4 total)