UnpackPtr UnpackNew(t_symbol *msg, long argc, t_atom* argv) { UnpackPtr self; TTValue v, none; TTErr err; self = UnpackPtr(object_alloc(sUnpackClass)); if (self) { object_obex_store((void*)self, _sym_dumpout, (t_object*)outlet_new(self, NULL)); // dumpout self->graphOutlets[0] = outlet_new(self, NULL); v.resize(2); v[0] = "graph.output"; v[1] = 1; err = TTObjectBaseInstantiate(TT("graph.object"), (TTObjectBasePtr*)&self->graphObject, v); if (!self->graphObject->mKernel.valid()) { object_error(SELF, "cannot load Jamoma object"); return NULL; } self->callback = new TTObject("callback"); self->callback->set(TT("function"), TTPtr(&UnpackGraphCallback)); self->callback->set(TT("baton"), TTPtr(self)); // Dynamically add a message to the callback object so that it can handle the 'dictionaryReceived' notification self->callback->instance()->registerMessage(TT("dictionaryReceived"), (TTMethod)&TTCallback::notify, kTTMessagePassValue); // Tell the graph object that we want to watch it self->graphObject->mKernel.registerObserverForNotifications(*self->callback); attr_args_process(self, argc, argv); } return self; }
UnpackPtr UnpackNew(SymbolPtr msg, AtomCount argc, AtomPtr argv) { UnpackPtr self; TTValue sr(sys_getsr()); long attrstart = attr_args_offset(argc, argv); // support normal arguments short i; TTValue v; TTErr err; self = UnpackPtr(object_alloc(sUnpackClass)); if (self) { self->maxNumChannels = 2; // An initial argument to this object will set the maximum number of channels if(attrstart && argv) self->maxNumChannels = atom_getlong(argv); ttEnvironment->setAttributeValue(kTTSym_sampleRate, sr); v.setSize(2); v.set(0, TT("thru")); v.set(1, 1); // arg is the number of inlets err = TTObjectBaseInstantiate(TT("audio.object"), (TTObjectBasePtr*)&self->audioGraphObject, v); //self->audioGraphObject->getUnitGenerator()->setAttributeValue(TT("linearGain"), 1.0); attr_args_process(self, argc, argv); object_obex_store((void*)self, _sym_dumpout, (object*)outlet_new(self, NULL)); // dumpout dsp_setup((t_pxobject*)self, 1); for(i=0; i < self->maxNumChannels; i++) outlet_new((t_pxobject*)self, "signal"); self->qelem = qelem_new(self, (method)UnpackQFn); self->obj.z_misc = Z_NO_INPLACE | Z_PUT_LAST; } return self; }
UnpackPtr UnpackNew(SymbolPtr msg, AtomCount argc, AtomPtr argv) { UnpackPtr self; TTValue v; TTErr err; self = UnpackPtr(object_alloc(sUnpackClass)); if (self) { object_obex_store((void*)self, _sym_dumpout, (ObjectPtr)outlet_new(self, NULL)); // dumpout self->graphOutlets[0] = outlet_new(self, NULL); v.setSize(2); v.set(0, TT("graph.output")); v.set(1, TTUInt32(1)); err = TTObjectInstantiate(TT("graph.object"), (TTObjectPtr*)&self->graphObject, v); if (!self->graphObject->mKernel) { object_error(SELF, "cannot load Jamoma object"); return NULL; } err = TTObjectInstantiate(TT("Callback"), (TTObjectPtr*)&self->callback, kTTValNONE); self->callback->setAttributeValue(TT("Function"), TTPtr(&UnpackGraphCallback)); self->callback->setAttributeValue(TT("Baton"), TTPtr(self)); // dynamically add a message to the callback object so that it can handle the 'dictionaryReceived' notification self->callback->registerMessage(TT("dictionaryReceived"), (TTMethod)&TTCallback::notify, kTTMessagePassValue); // tell the graph object that we want to watch it self->graphObject->mKernel->registerObserverForNotifications(*self->callback); attr_args_process(self, argc, argv); } return self; }