Jamoma API  0.6.0.a19
j.max.gain.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup implementationMaxExternalsJitter
4  *
5  * @brief j.gain% : Scale values in a matrix
6  *
7  * @details This is the Max wrapper
8  *
9  * @authors Tim Place, Trond Lossius
10  *
11  * @copyright © 2011 by Timothy Place @n
12  * This code is licensed under the terms of the "New BSD License" @n
13  * http://creativecommons.org/licenses/BSD/
14  */
15 
16 
17 #include "jit.common.h"
18 #include "max.jit.mop.h"
19 #include "TTClassWrapperMax.h"
20 
21 
22 // types and structures
23 typedef struct _jcom_max_gain {
24  Object ob;
25  Ptr obex;
26 } MaxGainObject;
27 
28 typedef MaxGainObject* MaxGainObjectPtr;
29 
30 
31 // method prototypes
32 t_jit_err GainClassInit (void);
33 TTPtr MaxGainNew (t_symbol *s, long argc, t_atom *argv);
34 void MaxGainFree (MaxGainObjectPtr self);
35 
36 
37 // globals
38 static ClassPtr sMaxGainClass = NULL;
39 
40 
41 /************************************************************************************/
42 
43 int TTCLASSWRAPPERMAX_EXPORT main(void)
44 {
45  void *p, *q;
46 
47  TTFoundationInit();
48 
49  // initialize the Jitter class
50  GainClassInit();
51 
52  // create the Max class
53  setup((t_messlist**)&sMaxGainClass, (method)MaxGainNew, (method)MaxGainFree, sizeof(MaxGainObject), 0, A_GIMME, 0);
54 
55  // specify a byte offset to keep additional information
56  p = max_jit_classex_setup(calcoffset(MaxGainObject, obex));
57 
58  // look up the Jitter class in the class registry
59  q = jit_class_findbyname(gensym("j_gain"));
60 
61  max_jit_classex_mop_wrap(p, q, 0); // attrs & methods for name, type, dim, planecount, bang, outputmatrix, etc
62  max_jit_classex_standard_wrap(p, q, 0); // attrs & methods for getattributes, dumpout, maxjitclassaddmethods, etc
63  addmess((method)max_jit_mop_assist, (char*)"assist", A_CANT, 0); // standard matrix-operator (mop) assist fn
64  return 0;
65 }
66 
67 
68 
69 /************************************************************************************/
70 // Object Life Cycle
71 
72 void *MaxGainNew(t_symbol *s, long argc, t_atom *argv)
73 {
74  MaxGainObjectPtr self;
75  void *o;
76 
77  self = (MaxGainObjectPtr)max_jit_obex_new(sMaxGainClass, gensym("j_gain"));
78  if (self) {
79  o = jit_object_new(gensym("j_gain"));
80  if (o) {
81  max_jit_mop_setup_simple(self, o, argc, argv);
82  max_jit_attr_args(self, argc, argv);
83  }
84  else {
85  jit_object_error(SELF, (char*)"could not allocate object");
86  object_free(SELF);
87  self = NULL;
88  }
89  }
90  return self;
91 }
92 
93 
94 void MaxGainFree(MaxGainObjectPtr self)
95 {
96  max_jit_mop_free(self);
97  jit_object_free(max_jit_obex_jitob_get(self));
98  max_jit_obex_free(self);
99 }
100 
void * TTPtr
A generic pointer.
Definition: TTBase.h:248
int TTCLASSWRAPPERMAX_EXPORT main(void)
Set up this class as a Max external the first time an object of this kind is instantiated.
Definition: j.max.gain.cpp:43