Max 5 API Reference
00001 /** 00002 @file 00003 max.jit.simple - simple example of a Jitter external 00004 multiplies an incoming matrix by a constant 00005 00006 @ingroup examples 00007 @see jit.simple 00008 00009 Copyright 2009 - Cycling '74 00010 Timothy Place, tim@cycling74.com 00011 */ 00012 00013 #include "jit.common.h" 00014 #include "max.jit.mop.h" 00015 00016 00017 // Max object instance data 00018 // Note: most instance data is in the Jitter object which we will wrap 00019 typedef struct _max_jit_simple { 00020 t_object ob; 00021 void *obex; 00022 } t_max_jit_simple; 00023 00024 00025 // prototypes 00026 BEGIN_USING_C_LINKAGE 00027 t_jit_err jit_simple_init(void); 00028 void *max_jit_simple_new(t_symbol *s, long argc, t_atom *argv); 00029 void max_jit_simple_free(t_max_jit_simple *x); 00030 END_USING_C_LINKAGE 00031 00032 // globals 00033 static void *max_jit_simple_class = NULL; 00034 00035 00036 /************************************************************************************/ 00037 00038 int main(void) 00039 { 00040 void *p, *q; 00041 00042 jit_simple_init(); 00043 setup((t_messlist**)&max_jit_simple_class, (method)max_jit_simple_new, (method)max_jit_simple_free, sizeof(t_max_jit_simple), 0, A_GIMME, 0); 00044 00045 p = max_jit_classex_setup(calcoffset(t_max_jit_simple, obex)); 00046 q = jit_class_findbyname(gensym("jit_simple")); 00047 max_jit_classex_mop_wrap(p, q, 0); // attrs & methods for name, type, dim, planecount, bang, outputmatrix, etc 00048 max_jit_classex_standard_wrap(p, q, 0); // attrs & methods for getattributes, dumpout, maxjitclassaddmethods, etc 00049 addmess((method)max_jit_mop_assist, "assist", A_CANT, 0); // standard matrix-operator (mop) assist fn 00050 return 0; 00051 } 00052 00053 00054 /************************************************************************************/ 00055 // Object Life Cycle 00056 00057 void *max_jit_simple_new(t_symbol *s, long argc, t_atom *argv) 00058 { 00059 t_max_jit_simple *x; 00060 void *o; 00061 00062 x = (t_max_jit_simple*)max_jit_obex_new(max_jit_simple_class, gensym("jit_simple")); 00063 if (x) { 00064 o = jit_object_new(gensym("jit_simple")); 00065 if (o) { 00066 max_jit_mop_setup_simple(x, o, argc, argv); 00067 max_jit_attr_args(x, argc, argv); 00068 } 00069 else { 00070 jit_object_error((t_object*)x, "jit.simple: could not allocate object"); 00071 freeobject((t_object*)x); 00072 x = NULL; 00073 } 00074 } 00075 return (x); 00076 } 00077 00078 00079 void max_jit_simple_free(t_max_jit_simple *x) 00080 { 00081 max_jit_mop_free(x); 00082 jit_object_free(max_jit_obex_jitob_get(x)); 00083 max_jit_obex_free(x); 00084 } 00085
Copyright © 2008, Cycling '74