Re: Can you create your own externals?

Hello,

Yes, you can :-)

C is the main language used to make externals (even if it can be done with C++ and i guess Objective-C). Download the API there (for max5 or max6) : http://cycling74.com/products/sdk/

There is examples inside with a html documentation pretty well done to start. For questions, search then ask in the “dev” forum. If you are more used with Java / Python / Lua… you can use interpreters embedded in Max.

I joined the code of an object [flop] that do nothing except bang when it is banged ;-)

#include "ext.h"
#include "ext_obex.h"

typedef struct _flop {
    t_object    ob;
    void        *outlet;
    } t_flop;

void *flop_new  (t_symbol *s, long argc, t_atom *argv);
void flop_free  (t_flop *x);
void flop_bang  (t_flop *x);

static t_class *flop_class;

int main(void)
{
//
t_class	*c = NULL;

c = class_new("flop", (method)flop_new, (method)flop_free, sizeof(t_flop), 0, A_GIMME, 0);
class_addmethod(c, (method)flop_bang, "bang", 0);
class_register(CLASS_BOX, c);

flop_class = c;

return 0;
//
}

void *flop_new(t_symbol *s, long argc, t_atom *argv)
{
    t_flop *x = NULL;

    if (x = (t_flop *)object_alloc(flop_class)) {
        x->outlet = bangout((t_object *)x);
    }	

    return x;
}

void flop_free(t_flop *x)
{
    ;
}

void flop_bang(t_flop *x)
{
    outlet_bang(x->outlet);
}
Attachments:
  1. flop.c
Jul 4, 2012 at 5:31am #143588