/* starting point for a Max external object ------- */ /* the required include file(s) */ #include "ext.h" /* structure definition of your object */ typedef struct myobject { Object m_ob; // required header void *m_out; // example field: an outlet long m_value; // example field: store a value } MyObject; /* globalthat holds the class definition */ void *myobject_class; /* prototypes for your functions */ void myobject_int(MyObject *x, long n); void myobject_bang(MyObject *x); void myobject_set(MyObject *x, long n); void *myobject_new(long n); /* initialization routine */ void main(fptr *f) { /* tell Max about your class. */ setup((Messlist **)&myobject_class, (method)myobject_new, (method)0L, (short)sizeof(MyObject), 0L, A_DEFLONG, 0); /* bind your methods to symbols */ addbang((method)myobject_bang); addint((method)myobject_int); addmess((method)myobject_set, "set", A_LONG, 0); /* list object in the new object list */ finder_addclass("Data","myobject"); } /* example methods */ void myobject_bang(MyObject *x) { outlet_int(x->m_out,x->m_value); // send stored value out an outlet } void myobject_int(MyObject *x, long n) { x->m_value = n; // store a value inside the object outlet_int(x->m_out,x->m_value); // and send it out } void myobject_set(MyObject *x, long n) { x->m_value = n; // just store incoming value without outputting it } /* instance creation routine */ void *myobject_new(long n) { MyObject *x; x = newobject(myobject_class); // get memory for a new object & initialize x->m_value = n; // store value (default is 0) x->m_out = intout(x); // create an int outlet return (x); // return newly created object to caller }