PackPtr PackNew(t_symbol* msg, long argc, t_atom* argv) { PackPtr self; TTValue v; TTErr err; self = PackPtr(object_alloc(sPackClass)); if (self) { object_obex_store((void*)self, _sym_dumpout, (t_object*)outlet_new(self, NULL)); self->graphOutlets[0] = outlet_new(self, "graph.connect"); v.resize(2); v[0] = "graph.input"; v[1] = 1; err = TTObjectBaseInstantiate(TT("graph.object"), (TTObjectBasePtr*)&self->graphObject, v); ((TTGraphInput*)self->graphObject->mKernel.instance())->setOwner(self->graphObject); if (!self->graphObject->mKernel.valid()) { object_error(SELF, "cannot load Jamoma object"); return NULL; } self->graphDictionary = new TTDictionary; self->graphDictionary->setSchema(TT("none")); self->graphDictionary->append(TT("outlet"), 0); attr_args_process(self, argc, argv); self->qelem = qelem_new(self, (method)PackQFn); // PackStartTracking(self); defer_low(self, (method)PackStartTracking, NULL, 0, NULL); } return self; }
AppendPtr AppendNew(t_symbol* msg, long argc, t_atom* argv) { AppendPtr self; TTValue v; TTErr err; self = AppendPtr(object_alloc(sAppendClass)); if (self) { object_obex_store((void*)self, _sym_dumpout, (t_object*)outlet_new(self, NULL)); // dumpout self->graphOutlets[0] = outlet_new(self, "graph.connect"); v.resize(2); v[0] = "dictionary.append"; 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; } attr_args_process(self, argc, argv); } return self; }
// Create void *receive_new(t_symbol *s, long argc, t_atom *argv) { long attrstart = attr_args_offset(argc, argv); // support normal arguments t_receive *x = (t_receive *)object_alloc(s_receive_class); if (x) { object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x, NULL)); x->outlet = outlet_new(x, NULL); if (!g_receivemaster_object) g_receivemaster_object = (t_object *)object_new_typed(CLASS_NOBOX, SymbolGen("jcom.receivemaster"), 0, NULL); x->callback = NULL; x->attr_name = NULL; // attr_args_process(x, argc, argv); // handle attribute args // If no name was specified as an attribute if (x->attr_name == NULL) { if (attrstart > 0) x->attr_name = atom_getsym(argv); else x->attr_name = SymbolGen("jcom.receive no arg specified"); receive_bind(x); } } return x; }
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; }
// Create void *fade_new(t_symbol *s, long argc, t_atom *argv) { long attrstart = attr_args_offset(argc, argv); // support normal arguments short i; t_fade *x = (t_fade *)object_alloc(s_fade_class); if(x){ object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x, NULL)); // dumpout x->numChannels = 1; if(attrstart && argv){ int argument = atom_getlong(argv); x->numChannels = TTClip(argument, 1, MAX_NUM_CHANNELS); } dsp_setup((t_pxobject *)x, (x->numChannels * 2) + 1); // Create Object and N Inlets (last argument) x->x_obj.z_misc = Z_NO_INPLACE; // ESSENTIAL! for(i=0; i< (x->numChannels); i++) outlet_new((t_pxobject *)x, "signal"); // Create a signal Outlet //x->xfade = new TTCrossfade(x->numChannels); // Constructors TTObjectBaseInstantiate(TT("crossfade"), &x->xfade, x->numChannels); TTObjectBaseInstantiate(kTTSym_audiosignal, &x->audioIn1, x->numChannels); TTObjectBaseInstantiate(kTTSym_audiosignal, &x->audioIn2, x->numChannels); TTObjectBaseInstantiate(kTTSym_audiosignal, &x->audioInControl, x->numChannels); TTObjectBaseInstantiate(kTTSym_audiosignal, &x->audioOut, x->numChannels); x->xfade->setAttributeValue(TT("mode"), TT("lookup")); x->xfade->setAttributeValue(TT("shape"), TT("equalPower")); x->xfade->setAttributeValue(TT("position"), 0.5); attr_args_process(x, argc, argv); // handle attribute args } return (x); // Return the pointer }
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; }
void *shift_new(t_symbol *msg, long argc, t_atom *argv) { t_shift *x = (t_shift *)object_alloc(shift_class);; short i; if(x){ object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x,NULL)); // dumpout dsp_setup((t_pxobject *)x, 3); // Create Object and 3 Inlets x->x_obj.z_misc = Z_NO_INPLACE; // ESSENTIAL? outlet_new((t_pxobject *)x, "signal"); // Create a signal Outlet tt_audio_base::set_global_sr(sys_getsr()); // Set Tap.Tools global SR... tt_audio_base::set_global_vectorsize(sys_getblksize()); // Set Tap.Tools global vector size... x->shifter = new tt_shift; for(i=0; i<NUM_INPUTS; i++) x->signal_in[i] = new tt_audio_signal; for(i=0; i<NUM_OUTPUTS; i++) x->signal_out[i] = new tt_audio_signal; // Set initial state x->attr_ratio = 1.0; x->attr_window_size = 87.0; attr_args_process(x,argc,argv); //handle attribute args } return (x); // Return the pointer }
InfoPtr InfoNew(t_symbol* msg, long argc, t_atom* argv) { InfoPtr self; TTValue v; TTErr err; self = InfoPtr(object_alloc(sInfoClass)); if (self) { object_obex_store((TTPtr)self, _sym_dumpout, (t_object*)outlet_new(self, NULL)); self->outletNumChannels = outlet_new((t_pxobject*)self, 0); self->outletVectorSize = outlet_new((t_pxobject*)self, 0); self->outletSampleRate = outlet_new((t_pxobject*)self, 0); self->outletSmartSignal = outlet_new((t_pxobject*)self, "audio.connect"); self->qelem = qelem_new(self, (method)InfoQfn); v.resize(2); v[0] = "thru"; v[1] = 1; // we set it up with 1 inlet, and later modify to 2 inlets if the connection is made err = TTObjectBaseInstantiate(TT("audio.object"), (TTObjectBasePtr*)&self->audioGraphObject, v); if (!self->audioGraphObject->getUnitGenerator().valid()) { object_error(SELF, "cannot load Jamoma DSP object"); return NULL; } attr_args_process(self, argc, argv); } return self; }
OpPtr OpNew(SymbolPtr msg, AtomCount argc, AtomPtr argv) { OpPtr self; TTValue v; TTErr err; self = OpPtr(object_alloc(sOpClass)); if (self) { object_obex_store((void*)self, _sym_dumpout, (ObjectPtr)outlet_new(self, NULL)); // dumpout self->outlet = outlet_new(self, "audio.connect"); self->inlet = proxy_new(self, 1, &self->inletnum); v.setSize(2); v.set(0, TT("operator")); v.set(1, TTUInt32(1)); // we set it up with 1 inlet, and later modify to 2 inlets if the connection is made err = TTObjectInstantiate(TT("audio.object"), (TTObjectPtr*)&self->audioGraphObject, v); if (!self->audioGraphObject->getUnitGenerator()) { object_error(SELF, "cannot load Jamoma DSP object"); return NULL; } attr_args_process(self, argc, argv); } return self; }
void *sheep_new(t_symbol *s, long argc, t_atom *argv) { t_sheep *x = NULL; t_object *jp = NULL; if (x = (t_sheep *)object_alloc(sheep_class)) { jp = (t_object *)gensym("#P")->s_thing; if (jp) { t_hashtab *ht; // look in the jpatcher's obex for an object called "sheephash" object_obex_lookup(jp, gensym("sheephash"), (t_object **)&ht); if (!ht) { // it's not there? create it. ht = hashtab_new(0); // objects stored in the obex will be freed when the obex's owner is freed // in this case, when the patcher object is freed. so we don't need to // manage the memory associated with the "sheephash". object_obex_store(jp, gensym("sheephash"), (t_object *)ht); } // cache the registered name so we can remove self from hashtab x = object_register(CLASS_BOX, x->myobjname = symbol_unique(), x); // store self in the hashtab. IMPORTANT: set the OBJ_FLAG_REF flag so that the // hashtab knows not to free us when it is freed. hashtab_storeflags(ht, x->myobjname, (t_object *)x, OBJ_FLAG_REF); } } return (x); }
void* op_new(t_symbol *msg, short argc, t_atom *argv) { t_op *x; TTValue sr(sys_getsr()); long attrstart = attr_args_offset(argc, argv); // support normal arguments short i; x = (t_op *)object_alloc(s_op_class); if(x){ x->maxNumChannels = 2; // An initial argument to this object will set the maximum number of channels if(attrstart && argv) x->maxNumChannels = atom_getlong(argv); ttEnvironment->setAttributeValue(kTTSym_sampleRate, sr); TTObjectBaseInstantiate(TT("operator"), &x->op, x->maxNumChannels); TTObjectBaseInstantiate(TT("audiosignal"), &x->audioIn, x->maxNumChannels); TTObjectBaseInstantiate(TT("audiosignal"), &x->audioOut, x->maxNumChannels); attr_args_process(x,argc,argv); // handle attribute args object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x,NULL)); // dumpout dsp_setup((t_pxobject *)x, x->maxNumChannels); // inlets for(i=0; i < x->maxNumChannels; i++) outlet_new((t_pxobject *)x, "signal"); // outlets x->obj.z_misc = Z_NO_INPLACE; } return (x); // Return the pointer }
DCBlockPtr DCBlockNew(t_symbol* msg, long argc, t_atom* argv) { DCBlockPtr self; TTValue v; TTErr err; self = (DCBlockPtr)object_alloc(sDCBlockClass); if (self) { object_obex_store((void*)self, _sym_dumpout, (t_object*)outlet_new(self, NULL)); self->audioGraphOutlet = outlet_new(self, "audio.connect"); // TODO: we need to update objects to work with the correct number of channels when the network is configured // Either that, or when we pull we just up the number of channels if when we need to ??? v.resize(2); v[0] = "dcblock"; v[1] = 1; err = TTObjectBaseInstantiate(TT("audio.object"), (TTObjectBasePtr*)&self->audioGraphObject, v); if (!self->audioGraphObject->getUnitGenerator().valid()) { object_error(SELF, "cannot load JamomaDSP object"); return NULL; } attr_args_process(self, argc, argv); } return self; }
PackPtr PackNew(SymbolPtr msg, AtomCount argc, AtomPtr argv) { PackPtr self; TTValue v; TTErr err; self = PackPtr(object_alloc(sPackClass)); if (self) { object_obex_store((void*)self, _sym_dumpout, (ObjectPtr)outlet_new(self, NULL)); self->graphOutlets[0] = outlet_new(self, "graph.connect"); v.setSize(2); v.set(0, TT("graph.input")); v.set(1, TTUInt32(1)); err = TTObjectInstantiate(TT("graph.object"), (TTObjectPtr*)&self->graphObject, v); ((TTGraphInput*)self->graphObject->mKernel)->setOwner(self->graphObject); if (!self->graphObject->mKernel) { object_error(SELF, "cannot load Jamoma object"); return NULL; } self->graphDictionary = new TTDictionary; self->graphDictionary->setSchema(TT("none")); self->graphDictionary->append(TT("outlet"), 0); attr_args_process(self, argc, argv); self->qelem = qelem_new(self, (method)PackQFn); // PackStartTracking(self); defer_low(self, (method)PackStartTracking, NULL, 0, NULL); } return self; }
// Constructor void *binmod_new(t_symbol *msg, short argc, t_atom *argv) { // long attrstart = attr_args_offset(argc, argv); int i; t_binmod *x = (t_binmod *)object_alloc(binmod_class);; if(x){ object_obex_store((void *)x, _sym_dumpout, (object *)(x->dumpout = outlet_new(x,NULL))); // dumpout dsp_setup((t_pxobject *)x, 3); // Create Object and 3 Inlets (last argument) outlet_new((t_pxobject *)x, "signal"); // Create a signal Outlet outlet_new((t_pxobject *)x, "signal"); // Create a signal Outlet for(i=0;i < MAX_NUM_LFOS; i++) // Allocate TapTools LFO objects and store pointers to them x->lfos[i] = new tt_lfo; x->vs = sys_getblksize(); // Cache the global vector size x->krate = sys_getsr() / x->vs; x->tempsig = new tt_audio_signal(x->vs); // Allocate TapTools signal object and store a pointer to it x->attr_bypass = 0; // Set defaults... x->attr_freq_len = 0; x->attr_depth_len = 0; x->attr_phase_len = 0; x->attr_shape_len = 0; binmod_zero_shape(x); binmod_zero_frequency(x); binmod_zero_phase(x); binmod_zero_depth(x); attr_args_process(x,argc,argv); // handle attribute args } return(x); // Return the pointer }
void *ramp_new(t_symbol *s, long argc, t_atom *argv) { t_ramp *x = (t_ramp *)object_alloc(ramp_class); if (x) { x->outlets[k_outlet_dumpout] = outlet_new(x, 0L); x->outlets[k_outlet_value] = outlet_new(x, 0L); object_obex_store((void *)x, _sym_dumpout, (t_object *)x->outlets[k_outlet_dumpout]); x->parameterNames = new TTHash; x->rampUnit = NULL; // Set default attributes // @drive Atom a; atom_setsym(&a, gensym("scheduler")); object_attr_setvalueof(x, gensym("drive"), 1, &a); // @function object_attr_setsym(x, gensym("function"), jps_linear); // Now set specified attributes, if any attr_args_process(x, argc, argv); } return (x); // return the pointer to our new instantiation }
void *radians_new(t_symbol *msg, short argc, t_atom *argv) { t_atom_long myArg = 0; long attrstart; t_radians *x; attrstart = attr_args_offset(argc, argv); if(attrstart && argv) atom_arg_getlong(&myArg, 0, attrstart, argv); // support a normal int argument for bwc x = (t_radians *)object_alloc(radians_class);; if(x){ object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x,NULL)); // dumpout dsp_setup((t_pxobject *)x,1); x->radians_out = floatout(x); // Create a floating-point Outlet outlet_new((t_object *)x, "signal"); x->tt = new tt_audio_base; // Create object for performing radian conversions x->tt->set_sr(sys_getsr()); x->radians_mode = myArg; // default mode attr_args_process(x, argc, argv); //handle attribute args } return (x); }
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; }
MidiOutPtr MidiOutNew(SymbolPtr msg, AtomCount argc, AtomPtr argv) { MidiOutPtr self; TTValue v; TTErr err; self = MidiOutPtr(object_alloc(sMidiOutClass)); if (self) { object_obex_store((void*)self, _sym_dumpout, (ObjectPtr)outlet_new(self, NULL)); // dumpout self->graphOutlets[0] = outlet_new(self, "graph.connect"); v.setSize(2); v.set(0, TT("midi.out")); v.set(1, TTUInt32(1)); err = TTObjectBaseInstantiate(TT("graph.object"), (TTObjectBasePtr*)&self->graphObject, v); if (!self->graphObject->mKernel) { object_error(SELF, "cannot load Jamoma object"); return NULL; } attr_args_process(self, argc, argv); } return self; }
// Create void *audiosend_new(t_symbol *s, long argc, t_atom *argv) { long attrstart = attr_args_offset(argc, argv); // support normal arguments t_audiosend *x = (t_audiosend *)object_alloc(s_audiosend_class); short i; if (x) { x->dumpout = outlet_new(x, NULL); object_obex_store(x, _sym_dumpout, (t_object *)x->dumpout); x->attr_target = _sym_nothing; x->num_inputs = 2; // TODO: make this dynamic from args for (i=0; i<attrstart; i++) { if (argv[i].a_type == A_LONG) x->num_inputs = atom_getlong(argv+i); else if (argv[i].a_type == A_SYM) x->attr_target = atom_getsym(argv+i); } dsp_setup((t_pxobject *)x, x->num_inputs); x->obj.z_misc = Z_NO_INPLACE; attr_args_process(x, argc, argv); // handle attribute args } return x; }
void* balance_new(t_symbol *msg, short argc, t_atom *argv) { t_balance *x; TTValue sr(sys_getsr()); long attrstart = attr_args_offset(argc, argv); // support normal arguments short i; x = (t_balance *)object_alloc(balance_class); if(x){ // Default values x->attrFrequency = 10; x->attrBypass = 0; // An initial argument to this object will set the maximum number of channels to process // Two input channels are required for each processed channel (source and comperator) x->maxNumChannels = 1; if(attrstart && argv) x->maxNumChannels = atom_getlong(argv); ttEnvironment->setAttributeValue(kTTSym_SampleRate, sr); TTObjectInstantiate(TT("balance"), &x->balance, x->maxNumChannels); TTObjectInstantiate(TT("audiosignal"), &x->audioIn, x->maxNumChannels*2); TTObjectInstantiate(TT("audiosignal"), &x->audioOut, x->maxNumChannels); attr_args_process(x,argc,argv); // handle attribute args object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x,NULL)); // dumpout dsp_setup((t_pxobject *)x, x->maxNumChannels*2); // inlets for(i=0; i < x->maxNumChannels; i++) outlet_new((t_pxobject *)x, "signal"); // outlets x->obj.z_misc = Z_NO_INPLACE; } return (x); // Return the pointer }
void *legion_new(t_symbol *msg, short argc, t_atom *argv){ t_legion *x = NULL; if(x = (t_legion *)object_alloc(legion_class)){ object_obex_store(x, _sym_dumpout, outlet_new(x, NULL)); x->t_out = listout(x); x->t_kappa = 1.0; x->t_lambda = 0.5; x->t_temperature = 0.0; x->t_learningRate = 0.3; x->t_entrainmentRate = 0.3; x->t_radius = 3.0; x->t_epoch = 0; //x->t_neighborhoodFunction = legion_gaussian; legion_setneighborhoodFunction(x, gensym("gaussian")); x->t_nfParam = 1.0; x->t_learn = 1; x->t_numColumns = 10; x->t_numRows = 10; x->t_vectorLength = 10; x->t_randMin = 0.; x->t_randMax = 10.; attr_args_process(x, argc, argv); legion_init(x); } return x; }
void *envExp_new(Symbol *s, long argc, t_atom *argv) { //create the new instance and returns a pointer to it t_envExp *x = (t_envExp *)object_alloc(this_class); //post("new"); if (x) { //post("new_x"); // dumpout object_obex_store((void *)x, jps_dumpout, (object *)outlet_new(x,NULL)); // create outlet x->outlet =outlet_new(x, 0L); //Initialisation of attributes x->attr_attack = 10; x->attr_amplitude = 1.; x->attr_decayrate = 90.; x->attr_threshold = -90; x->attr_steal = 1; // handle attribute args attr_args_process(x,argc,argv); envExp_calculate(x); } return(x); //must return a pointer to the new instance }
PlugOutPtr PlugOutNew(SymbolPtr msg, AtomCount argc, AtomPtr argv) { PlugOutPtr self = PlugOutPtr(object_alloc(sPlugOutClass)); TTValue v; TTErr err; if (self) { v.setSize(2); v.set(0, TT("plugtastic.output")); v.set(1, 2); err = TTObjectBaseInstantiate(TT("audio.object"), (TTObjectBasePtr*)&self->audioGraphObject, v); v = TTPtr(self->audioGraphObject); object_obex_store((void*)self, _sym_dumpout, (object*)outlet_new(self, NULL)); self->audioGraphOutlet = outlet_new(self, "audio.connect"); self->qelem = qelem_new(self, (method)PlugOutQFn); object_obex_lookup(self, GENSYM("#P"), &self->patcher); self->pluginName = object_attr_getsym(self->patcher, _sym_name); self->pluginVersion = GENSYM("1.0"); self->pluginVersionHex = GENSYM("0x00010000"); self->pluginManufacturer = GENSYM("Plugtastic"); self->pluginManufacturerCode = GENSYM("74Ob"); self->pluginID = GENSYM("ftmp"); attr_args_process(self, argc, argv); } return self; }
t_object *wrappedModularClass_new(t_symbol *name, long argc, t_atom *argv) { WrappedClass* wrappedMaxClass = NULL; WrappedModularInstancePtr x = NULL; TTErr err = kTTErrNone; // Find the WrappedClass hashtab_lookup(wrappedMaxClasses, name, (t_object**)&wrappedMaxClass); // If the WrappedClass has a validity check defined, then call the validity check function. // If it returns an error, then we won't instantiate the object. if (wrappedMaxClass) { if (wrappedMaxClass->validityCheck) err = wrappedMaxClass->validityCheck(wrappedMaxClass->validityCheckArgument); else err = kTTErrNone; } else err = kTTErrGeneric; if (!err) x = (WrappedModularInstancePtr)object_alloc(wrappedMaxClass->maxClass); if (x) { x->wrappedClassDefinition = wrappedMaxClass; x->useInternals = NO; x->internals = new TTHash(); x->address = kTTAdrsEmpty; x->argv = NULL; x->iterateInternals = NO; #ifdef ARRAY_EXTERNAL x->arrayFormatInteger = TTString(); x->arrayFormatString = TTString(); #endif x->patcherPtr = NULL; x->patcherContext = kTTSymEmpty; x->patcherClass = kTTSymEmpty; x->patcherName = kTTSymEmpty; x->patcherAddress = kTTAdrsEmpty; // dumpout object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x,NULL)); // Make specific things ModularSpec *spec = (ModularSpec*)wrappedMaxClass->specificities; if (spec) { if (spec->_new) spec->_new((TTPtr)x, argc, argv); } else // handle attribute args attr_args_process(x, argc, argv); } return (t_object*)x; }
// Create void *out_new(t_symbol *s, long argc, t_atom *argv) { long attrstart = attr_args_offset(argc, argv); // support normal arguments t_out *x = (t_out *)object_alloc(out_class); short i; if(x){ x->dumpout = outlet_new(x, NULL); object_obex_store((void *)x, jps_dumpout, (object *)x->dumpout); // setup the dumpout x->numOutputs = 1; x->attr_preview = 0; x->preview_object = NULL; x->attr_bypass = 0; x->attr_mute = 0; x->attr_mix = 100; // Assume 100%, so that processed signal is passed through if @has_mix is false if(attrstart > 0){ int argument = atom_getlong(argv); x->numOutputs = TTClip(argument, 1, MAX_NUM_CHANNELS); } #ifdef JCOM_OUT_TILDE if(x->numOutputs > 0) dsp_setup((t_pxobject *)x, x->numOutputs); // Create Object and Inlets else dsp_setup((t_pxobject *)x, 1); // Create Object and Inlets x->common.ob.z_misc = Z_NO_INPLACE | Z_PUT_LAST; // Z_PUT_LAST so that thispoly~ gets it's message properly? for(i=0; i < (x->numOutputs); i++) outlet_new((t_pxobject *)x, "signal"); // Create a signal Outlet x->clock = clock_new(x, (method)update_meters); x->clock_is_set = 0; TTObjectInstantiate(kTTSym_audiosignal, &x->audioIn, x->numOutputs); TTObjectInstantiate(kTTSym_audiosignal, &x->audioOut, x->numOutputs); TTObjectInstantiate(kTTSym_audiosignal, &x->audioTemp, x->numOutputs); TTObjectInstantiate(kTTSym_audiosignal, &x->zeroSignal, x->numOutputs); TTObjectInstantiate(TT("crossfade"), &x->xfade, x->numOutputs); x->xfade->setAttributeValue(TT("position"), 1.0); TTObjectInstantiate(TT("gain"), &x->gain, x->numOutputs); TTObjectInstantiate(TT("ramp"), &x->ramp_gain, x->numOutputs); TTObjectInstantiate(TT("ramp"), &x->ramp_xfade, x->numOutputs); // out_alloc(x, sys_getblksize()); // allocates the vectors for the audio signals x->gain->setAttributeValue(TT("linearGain"), 1.0); #else for(i=x->numOutputs-1; i >= 1; i--) x->inlet[i] = proxy_new(x, i, 0L); for(i=x->numOutputs-1; i >= 0; i--) x->outlet[i] = outlet_new(x, 0L); #endif jcom_core_subscriber_new_common(&x->common, jps__jcom_out__, jps_subscribe_out); jcom_core_subscriber_setcustomsubscribe_method(&x->common, &out_subscribe); attr_args_process(x, argc, argv); // handle attribute args jcom_core_subscriber_subscribe((t_jcom_core_subscriber_common*)x); } return (x); // Return the pointer }
ObjectPtr wrappedClass_new(SymbolPtr name, AtomCount argc, AtomPtr argv) { WrappedClass* wrappedMaxClass = NULL; WrappedInstancePtr self = NULL; TTValue v; TTErr err = kTTErrNone; TTUInt8 numInputs = 1; TTUInt8 numOutputs = 1; long attrstart = attr_args_offset(argc, argv); // support normal arguments // Find the WrappedClass hashtab_lookup(wrappedMaxClasses, name, (ObjectPtr*)&wrappedMaxClass); // If the WrappedClass has a validity check defined, then call the validity check function. // If it returns an error, then we won't instantiate the object. if (wrappedMaxClass) { if (wrappedMaxClass->validityCheck) err = wrappedMaxClass->validityCheck(wrappedMaxClass->validityCheckArgument); else err = kTTErrNone; } else err = kTTErrGeneric; if (!err) self = (WrappedInstancePtr)object_alloc(wrappedMaxClass->maxClass); if (self){ if (wrappedMaxClass->options && !wrappedMaxClass->options->lookup(TT("argumentDefinesNumInlets"), v)) { long argumentOffsetToDefineTheNumberOfInlets = v; if ((attrstart-argumentOffsetToDefineTheNumberOfInlets > 0) && argv+argumentOffsetToDefineTheNumberOfInlets) numInputs = atom_getlong(argv+argumentOffsetToDefineTheNumberOfInlets); } for (TTUInt16 i=numInputs-1; i>0; i--) self->inlets[i-1] = proxy_new(self, i, NULL); object_obex_store((void*)self, _sym_dumpout, (object*)outlet_new(self, NULL)); // dumpout if (wrappedMaxClass->options && !wrappedMaxClass->options->lookup(TT("argumentDefinesNumOutlets"), v)) { long argumentOffsetToDefineTheNumberOfOutlets = v; if ((attrstart-argumentOffsetToDefineTheNumberOfOutlets > 0) && argv+argumentOffsetToDefineTheNumberOfOutlets) numOutputs = atom_getlong(argv+argumentOffsetToDefineTheNumberOfOutlets); } for (TTInt16 i=numOutputs-1; i>=0; i--) self->audioGraphOutlets[i] = outlet_new(self, "audio.connect"); self->wrappedClassDefinition = wrappedMaxClass; v.setSize(3); v.set(0, wrappedMaxClass->ttClassName); v.set(1, numInputs); v.set(2, numOutputs); err = TTObjectInstantiate(TT("audio.object"), (TTObjectPtr*)&self->audioGraphObject, v); attr_args_process(self, argc, argv); } return ObjectPtr(self); }
void *diff_new(void) { t_diff *x = (t_diff *)object_alloc(diff_class);; if(x){ object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x,NULL)); // dumpout dsp_setup((t_pxobject *)x, 1); // Create Object and 1 Inlet (last argument) outlet_new((t_pxobject *)x, "signal"); // Create a signal Outlet x->diff_b1 = 0; // initialize value } return (x); // Return the pointer }
void *folder_new(t_symbol *msg, short argc, t_atom *argv) { t_folder *x; x = (t_folder *)object_alloc(folder_class); if (x) { object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x,NULL)); attr_args_process(x,argc,argv); } return (x); }
void *folder_new(t_symbol *msg, short argc, t_atom *argv) { t_folder *x = (t_folder *)object_alloc(s_folder_class);; if(x){ object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x,NULL)); #ifdef MAC_VERSION x->applescript = (t_object*)object_new_typed(_sym_box, gensym("tap.applescript"), 0, NULL); #endif attr_args_process(x,argc,argv); } return (x); }
void *filecontainer_new(t_symbol *msg, short argc, t_atom *argv) { t_filecontainer *x; x = (t_filecontainer *)object_alloc(s_filecontainer_class);; if(x) { x->sqlite = NULL; x->dumpout = outlet_new(x,NULL); object_obex_store((void *)x, _sym_dumpout, (object *)x->dumpout); attr_args_process(x, argc, argv); } return (x); }