25 TTPtr graphOutlets[16];
28 t_object* patcherview;
37 void PackStartTracking(
PackPtr self);
38 t_max_err PackNotify (
PackPtr self, t_symbol* s, t_symbol* msg, t_object* sender,
TTPtr data);
41 void PackInt (
PackPtr self,
long value);
42 void PackFloat (
PackPtr self,
double value);
43 void PackList (
PackPtr self, t_symbol* s,
long ac, t_atom* ap);
44 void PackAnything (
PackPtr self, t_symbol* s,
long ac, t_atom* ap);
45 void PackMessage (
PackPtr self, t_symbol* s,
long ac, t_atom* ap);
46 void PackAttribute (
PackPtr self, t_symbol* s,
long ac, t_atom* ap);
52 static t_class* sPackClass;
63 common_symbols_init();
65 c = class_new(
"j.pack-", (method)
PackNew, (method)
PackFree,
sizeof(
Pack), (method)0L, A_GIMME, 0);
67 class_addmethod(c, (method)PackInt,
"int", A_LONG, 0);
68 class_addmethod(c, (method)PackFloat,
"float", A_LONG, 0);
69 class_addmethod(c, (method)PackList,
"list", A_GIMME, 0);
70 class_addmethod(c, (method)PackAnything,
"anything", A_GIMME, 0);
71 class_addmethod(c, (method)PackMessage,
"message", A_GIMME, 0);
72 class_addmethod(c, (method)PackAttribute,
"attribute", A_GIMME, 0);
74 class_addmethod(c, (method)MaxGraphReset,
"graph.reset", A_CANT, 0);
75 class_addmethod(c, (method)MaxGraphSetup,
"graph.setup", A_CANT, 0);
76 class_addmethod(c, (method)MaxGraphDrop,
"graph.drop", A_CANT, 0);
77 class_addmethod(c, (method)MaxGraphObject,
"graph.object", A_CANT, 0);
79 class_addmethod(c, (method)PackNotify,
"notify", A_CANT, 0);
80 class_addmethod(c, (method)
PackAssist,
"assist", A_CANT, 0);
81 class_addmethod(c, (method)object_obex_dumpout,
"dumpout", A_CANT, 0);
83 class_register(_sym_box, c);
98 self =
PackPtr(object_alloc(sPackClass));
100 object_obex_store((
void*)
self, _sym_dumpout, (t_object*)outlet_new(
self, NULL));
101 self->graphOutlets[0] = outlet_new(
self,
"graph.connect");
104 v[0] =
"graph.input";
107 ((
TTGraphInput*)self->graphObject->mKernel.instance())->setOwner(self->graphObject);
109 if (!self->graphObject->mKernel.valid()) {
110 object_error(SELF,
"cannot load Jamoma object");
116 self->graphDictionary->append(
TT(
"outlet"), 0);
118 attr_args_process(
self, argc, argv);
120 self->qelem = qelem_new(
self, (method)PackQFn);
123 defer_low(
self, (method)PackStartTracking, NULL, 0, NULL);
133 qelem_free(self->qelem);
139 t_max_err PackNotify(
PackPtr self, t_symbol* s, t_symbol* msg, t_object* sender,
TTPtr data)
141 if (sender == self->patcherview) {
142 if (msg == _sym_attr_modified) {
143 t_symbol* name = (t_symbol*)object_method((t_object*)data, _sym_getname);
144 if (name == _sym_dirty) {
145 qelem_set(self->qelem);
148 else if (msg == _sym_free)
149 self->patcherview = NULL;
152 if (msg == _sym_free) {
154 t_object* sourceObject;
157 t_object* destObject;
160 #ifdef DEBUG_NOTIFICATIONS
161 object_post(SELF,
"patch line deleted");
162 #endif // DEBUG_NOTIFICATIONS
165 sourceBox = jpatchline_get_box1(sender);
169 sourceObject = jbox_get_object(sourceBox);
170 sourceOutlet = jpatchline_get_outletnum(sender);
171 destBox = jpatchline_get_box2(sender);
174 destObject = jbox_get_object(destBox);
175 destInlet = jpatchline_get_inletnum(sender);
178 if ( zgetfn(sourceObject, gensym(
"graph.object")) && zgetfn(destObject, gensym(
"graph.object")) ) {
179 #ifdef DEBUG_NOTIFICATIONS
180 object_post(SELF,
"deleting graph patchline!");
181 #endif // DEBUG_NOTIFICATIONS
183 object_method(destObject, gensym(
"graph.drop"), destInlet, sourceObject, sourceOutlet);
193 void PackIterateResetCallback(
PackPtr self, t_object* obj)
195 t_max_err err = MAX_ERR_NONE;
196 method graphResetMethod = zgetfn(obj, gensym(
"graph.reset"));
198 if (graphResetMethod)
199 err = (t_max_err)graphResetMethod(obj);
203 void PackIterateSetupCallback(
PackPtr self, t_object* obj)
205 t_max_err err = MAX_ERR_NONE;
206 method graphSetupMethod = zgetfn(obj, gensym(
"graph.setup"));
208 if (graphSetupMethod)
209 err = (t_max_err)graphSetupMethod(obj);
213 void PackAttachToPatchlinesForPatcher(
PackPtr self, t_object* patcher)
215 t_object* patchline = object_attr_getobj(patcher, _sym_firstline);
216 t_object* box = jpatcher_get_firstobject(patcher);
219 object_attach_byptr_register(
self, patchline, _sym_nobox);
220 patchline = object_attr_getobj(patchline, _sym_nextline);
224 t_symbol* classname = jbox_get_maxclass(box);
226 if (classname == _sym_jpatcher) {
227 t_object* subpatcher = jbox_get_object(box);
229 PackAttachToPatchlinesForPatcher(
self, subpatcher);
231 box = jbox_get_nextobject(box);
241 #ifdef DEBUG_NOTIFICATIONS
242 object_post(SELF,
"patcher dirtied");
243 #endif // DEBUG_NOTIFICATIONS
245 object_method(self->patcher, gensym(
"iterate"), (method)PackIterateSetupCallback,
self, PI_DEEP, &result);
249 PackAttachToPatchlinesForPatcher(
self, self->patcher);
254 void PackStartTracking(
PackPtr self)
256 t_object* patcher = NULL;
257 t_object* parent = NULL;
258 t_object* patcherview = NULL;
263 err = object_obex_lookup(
self, gensym(
"#P"), &patcher);
267 parent = object_attr_getobj(patcher, _sym_parentpatcher);
271 object_method(patcher, gensym(
"iterate"), (method)PackIterateResetCallback,
self, PI_DEEP, &result);
272 object_method(patcher, gensym(
"iterate"), (method)PackIterateSetupCallback,
self, PI_DEEP, &result);
277 if (!self->patcherview) {
278 patcherview = jpatcher_get_firstview(patcher);
279 self->patcherview = patcherview;
280 self->patcher = patcher;
281 object_attach_byptr_register(
self, patcherview, _sym_nobox);
286 PackAttachToPatchlinesForPatcher(
self, self->patcher);
297 strcpy (dst,
"multichannel input and control messages");
300 strcpy(dst,
"multichannel output");
302 strcpy(dst,
"dumpout");
307 void PackInt(
PackPtr self,
long value)
311 self->graphDictionary->setSchema(
TT(
"number"));
312 self->graphDictionary->setValue(v);
313 ((
TTGraphInput*)self->graphObject->mKernel.instance())->push(*self->graphDictionary);
317 void PackFloat(
PackPtr self,
double value)
321 self->graphDictionary->setSchema(
TT(
"number"));
322 self->graphDictionary->setValue(v);
323 ((
TTGraphInput*)self->graphObject->mKernel.instance())->push(*self->graphDictionary);
327 void PackList(
PackPtr self, t_symbol* s,
long ac, t_atom* ap)
332 for (
int i=0; i<ac; i++) {
333 switch (atom_gettype(ap+i)) {
335 v[i] = (int)atom_getlong(ap+i);
338 v[i] = atom_getfloat(ap+i);
341 v[i] =
TT(atom_getsym(ap+i)->s_name);
347 self->graphDictionary->setSchema(
TT(
"array"));
348 self->graphDictionary->setValue(v);
349 ((
TTGraphInput*)self->graphObject->mKernel.instance())->push(*self->graphDictionary);
353 void PackAnything(
PackPtr self, t_symbol* s,
long ac, t_atom* ap)
359 self->graphDictionary->setSchema(
TT(
"array"));
360 v[0] =
TT(s->s_name);
361 for (
int i=0; i<ac; i++) {
362 switch (atom_gettype(ap+i)) {
364 v[i+1] = (int)atom_getlong(ap+i);
367 v[i+1] = atom_getfloat(ap+i);
370 v[i+1] =
TT(atom_getsym(ap+i)->s_name);
378 self->graphDictionary->setSchema(
TT(
"symbol"));
379 v[0] =
TT(s->s_name);
382 self->graphDictionary->setValue(v);
383 ((
TTGraphInput*)self->graphObject->mKernel.instance())->push(*self->graphDictionary);
387 void PackMessage(
PackPtr self, t_symbol* s,
long ac, t_atom* ap)
394 self->graphDictionary->setSchema(
TT(
"message"));
395 self->graphDictionary->
append(
TT(
"name"),
TT(atom_getsym(ap)->s_name));
400 for (
int i=0; i < ac-1; i++) {
401 switch (atom_gettype(ap+i)) {
403 v[i+1] = (int)atom_getlong(ap+i);
406 v[i+1] = atom_getfloat(ap+i);
409 v[i+1] =
TT(atom_getsym(ap+i)->s_name);
417 if (atom_gettype(ap+1) == A_SYM)
418 v[0] =
TT(s->s_name);
419 else if (atom_gettype(ap+1) == A_LONG || atom_gettype(ap+1) == A_FLOAT)
420 v[0] = atom_getfloat(ap+1);
423 self->graphDictionary->setValue(v);
424 ((
TTGraphInput*)self->graphObject->mKernel.instance())->push(*self->graphDictionary);
428 void PackAttribute(
PackPtr self, t_symbol* s,
long ac, t_atom* ap)
435 self->graphDictionary->setSchema(
TT(
"attribute"));
436 self->graphDictionary->
append(
TT(
"name"),
TT(atom_getsym(ap)->s_name));
441 for (
int i=0; i < ac-1; i++) {
442 switch (atom_gettype(ap+i)) {
444 v[i+1] = (int)atom_getlong(ap+i);
447 v[i+1] = atom_getfloat(ap+i);
450 v[i+1] =
TT(atom_getsym(ap+i)->s_name);
458 if (atom_gettype(ap+1) == A_SYM)
459 v[0] =
TT(s->s_name);
460 else if (atom_gettype(ap+1) == A_LONG || atom_gettype(ap+1) == A_FLOAT)
461 v[0] = atom_getfloat(ap+1);
464 self->graphDictionary->setValue(v);
465 ((
TTGraphInput*)self->graphObject->mKernel.instance())->push(*self->graphDictionary);
The TTGraphObjectBase wraps a TTDSP object such that it is possible to build a dynamic graph of audio...
TTErr TTObjectBaseRelease(TTObjectBasePtr *anObject)
DEPRECATED.
Base class for all first-class Jamoma objects.
Pack * PackPtr
Pointer to a j.pack= instance.
#define TT
This macro is defined as a shortcut for doing a lookup in the symbol table.
A type that represents the key as a C-String and the value as a pointer to the matching TTSymbol obje...
void append(const T &anElementValueToAppend)
Insert a single TTElement at the end.
PackPtr PackNew(t_symbol *msg, long argc, t_atom *argv)
Create a new instance of the j.in= object.
void * TTPtr
A generic pointer.
void PackAssist(PackPtr self, void *b, long msg, long arg, char *dst)
Provides assist strings in Max for object inlets and outlets.
int C74_EXPORT main(void)
Set up this class as a Max external the first time an object of this kind is instantiated.
TTErr TTObjectBaseInstantiate(const TTSymbol className, TTObjectBasePtr *returnedObjectPtr, const TTValue arguments)
DEPRECATED.
TTErr setSchema(const TTSymbol aSchemaName)
TODO: Add documentation schemaName TODO: Add documentation.
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Data Structure for the j.pack= Max object.
void resize(size_type n)
Change the number of elements.
[doxygenAppendixC_copyExample]
void PackFree(PackPtr self)
Called when the object is freed (destroyed), ensuring that memory is properly freed up...