int cmmjl_entrance_count_get(void *x, const char *func){ t_object *val; t_object *count; if(!_cmmjl_obj_tab){ return -1; } hashtab_lookup(_cmmjl_obj_tab, x, &val); if(!val){ return -1; } hashtab_lookup(((t_cmmjl_obj *)val)->entrance_count_tab, (void *)func, &count); return (long)count; }
t_max_err attr_set_hasmix(t_ui *obj, void *attr, long argc, t_atom *argv) { uiInternalObject *anObject; t_max_err err = MAX_ERR_NONE; float range[2]; obj->attr_hasmix = atom_getlong(argv); if(obj->attr_hasmix){ range[0] = 0.0; range[1] = 100.0; anObject = new uiInternalObject("jcom.parameter", "mix", obj->box.b_patcher, "decimal", "scheduler", "Controls the wet/dry mix of the module's processing routine in percent.", range, NULL, NULL, NULL); anObject->setAction((method)ui_mix, (t_object*)obj); hashtab_store(obj->hash_internals, gensym("mix"), (t_object*)anObject); object_attr_setsym(obj, gensym("prefix"), obj->attrPrefix); } else{ err = hashtab_lookup(obj->hash_internals, gensym("mix"), (t_object**)&anObject); if(!err){ hashtab_chuckkey(obj->hash_internals, gensym("mix")); delete anObject; } } return err; }
t_max_err wrappedClass_attrSet(WrappedInstancePtr self, t_object* attr, long argc, t_atom* argv) { if (argc && argv) { t_symbol* attrName = (t_symbol*)object_method(attr, _sym_getname); TTValue v; long i; t_max_err err; TTPtr ptr; err = hashtab_lookup(self->wrappedClassDefinition->maxNamesToTTNames, attrName, (t_object**)&ptr); if (err) return err; TTSymbol ttAttrName(ptr); v.resize(argc); for (i=0; i<argc; i++) { if (atom_gettype(argv+i) == A_LONG) v[i] = (TTInt32)atom_getlong(argv+i); else if (atom_gettype(argv+i) == A_FLOAT) v[i] = atom_getfloat(argv+i); else if (atom_gettype(argv+i) == A_SYM) v[i] = TT(atom_getsym(argv+i)->s_name); else object_error(SELF, "bad type for attribute setter"); } self->graphObject->mKernel.set(ttAttrName, v); return MAX_ERR_NONE; } return MAX_ERR_GENERIC; }
void dbviewer_getcelltext(t_dbviewer *x, t_symbol *colname, long index, char *text, long maxlen) { t_object *result = (t_object*)object_method(x->d_view, gensym("getresult")); char *itemtext; long column_index; t_max_err err; if(!result) return; err = hashtab_lookup(x->d_columns, colname, (t_object **)&column_index); if(!err){ itemtext = (char*)object_method(result, _sym_valuebyindex, index-1, column_index); if (itemtext && itemtext[0]) { if (strstr(colname->s_name, "date")) { t_datetime td; sysdateformat_strftimetodatetime(itemtext, &td); sysdateformat_formatdatetime(&td, SYSDATEFORMAT_RELATIVE, 0, text, maxlen-1); } else strncpy_zero(text, itemtext, maxlen-1); } } }
t_max_err attr_set_hasgain(t_ui *obj, void *attr, long argc, t_atom *argv) { uiInternalObject *anObject; t_max_err err = MAX_ERR_NONE; float range[2]; obj->attr_hasgain = atom_getlong(argv); if(obj->attr_hasgain){ range[0] = 0.0; range[1] = 127.0; anObject = new uiInternalObject("jcom.parameter", "gain", obj->box.b_patcher, "decimal", "scheduler", "Set gain (as MIDI value by default).", range, "gain", "midi", "midi"); anObject->setAction((method)ui_gain, (t_object*)obj); hashtab_store(obj->hash_internals, gensym("gain"), (t_object*)anObject); object_attr_setsym(obj, gensym("prefix"), obj->attrPrefix); } else{ err = hashtab_lookup(obj->hash_internals, gensym("gain"), (t_object**)&anObject); if(!err){ hashtab_chuckkey(obj->hash_internals, gensym("gain")); delete anObject; } } return err; }
void cc_mousewheel(t_cc *x, t_object *patcherview, t_pt pt, long modifiers){ ccmouse_method f; hashtab_lookup(x->ht, gensym("my_mousemove"), (t_object **)&f); if(f){ f((t_object *)x, x->user_obj, patcherview, pt, modifiers, x->noutlets, x->outlets); } }
t_object* jamoma_get_hub_for_module_named(t_symbol *name) { t_object *hub = NULL; hashtab_lookup(hash_modules, name, &hub); return hub; }
void ar_prev(t_ar *x){ t_hashtab *ht; t_linklist *ll; if(!(ht = (t_hashtab *)x->iname_ht->s_thing) || !(ll = (t_linklist *)x->iname_ll->s_thing)){ return; } if(!(x->current_item)){ x->current_item = linklist_getindex(ll, hashtab_getsize(ht) - 1); }else{ linklist_prev(ll, x->current_item, &(x->current_item)); if(!(x->current_item)){ //x->current_item = linklist_getindex(ll, hashtab_getsize(ht) - 1); outlet_anything(x->outlets[3], _sym_bang, 0, NULL); } } if(x->current_item){ t_atombuf *ab; t_atom a; ar_decode_key((t_symbol *)(x->current_item), &a); hashtab_lookup(ht, (t_symbol *)(x->current_item), (t_object **)(&ab)); if(ab){ outlet_list(x->outlets[1], NULL, 1, &a); outlet_list(x->outlets[0], NULL, ab->a_argc, ab->a_argv); } } }
t_max_err wrappedClass_attrSet(WrappedInstancePtr self, ObjectPtr attr, AtomCount argc, AtomPtr argv) { if (argc && argv) { SymbolPtr attrName = (SymbolPtr)object_method(attr, _sym_getname); TTValue v; AtomCount i; TTSymbolPtr ttAttrName = NULL; MaxErr err; err = hashtab_lookup(self->wrappedClassDefinition->maxAttrNamesToTTAttrNames, attrName, (ObjectPtr*)&ttAttrName); if (err) return err; v.setSize(argc); for (i=0; i<argc; i++) { if(atom_gettype(argv+i) == A_LONG) v.set(i, AtomGetInt(argv+i)); else if(atom_gettype(argv+i) == A_FLOAT) v.set(i, atom_getfloat(argv+i)); else if(atom_gettype(argv+i) == A_SYM) v.set(i, TT(atom_getsym(argv+i)->s_name)); else object_error(SELF, "bad type for attribute setter"); } self->audioGraphObject->mUnitGenerator->setAttributeValue(ttAttrName, v); return MAX_ERR_NONE; } return MAX_ERR_GENERIC; }
ObjectPtr jamoma_new(SymbolPtr s, AtomCount argc, AtomPtr argv) { int attrstart = attr_args_offset(argc, argv); int i = 0; int channelCount = 2; SymbolPtr className = gensym("gain"); MaxAudioGraphWrappedClassPtr classWrapper = NULL; char maxClassName[256]; if (!attrstart) { error("must specify a jamoma class as the first argument"); return NULL; } while (attrstart--) { if (atom_gettype(argv+i) == A_LONG) channelCount = atom_getlong(argv+i); else if (atom_gettype(argv+i) == A_SYM) className = atom_getsym(argv+i); i++; } snprintf(maxClassName, 256, "j.%s=", className->s_name); if (!s_jamoma_class_hash) s_jamoma_class_hash = hashtab_new(0); hashtab_lookup(s_jamoma_class_hash, className, (t_object**)&classWrapper); if (!classWrapper) { wrapAsMaxAudioGraph(className->s_name, maxClassName, &classWrapper); hashtab_store(s_jamoma_class_hash, className, ObjectPtr(classWrapper)); } return MaxAudioGraphWrappedClass_new(gensym(maxClassName), argc-1, argv+1); }
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; }
void cmmjl_osc_setAddress(void *x, t_symbol *address){ if(!_cmmjl_obj_tab){ return; } t_object *ob; hashtab_lookup(_cmmjl_obj_tab, x, &ob); ((t_cmmjl_obj *)ob)->osc_address = address; }
void cc_assist(t_cc *x, void *b, long io, long index, char *s){ void (*f)(long, long, char*); hashtab_lookup(x->ht, gensym("my_assist"), (t_object **)&f); if(f){ //f((t_object *)x, x->user_obj); f(io, index, s); } }
int cmmjl_entrance_count_inc(void *x, const char *func){ t_object *val; t_object *count; long c; if(!_cmmjl_obj_tab){ return -1; } hashtab_lookup(_cmmjl_obj_tab, x, &val); if(!val){ return -1; } hashtab_lookup(((t_cmmjl_obj *)val)->entrance_count_tab, (void *)func, &count); c = (long)count; c += 1; hashtab_store_safe(((t_cmmjl_obj *)val)->entrance_count_tab, (void *)func, (t_object *)c); return c; }
void wrappedClass_anything(WrappedInstancePtr self, t_symbol* s, long argc, t_atom* argv) { TTValue v; TTSymbol ttName; t_max_err err; err = hashtab_lookup(self->wrappedClassDefinition->maxNamesToTTNames, s, (t_object**)&ttName); if (err) { object_post(SELF, "no method found for %s", s->s_name); return; } if (argc && argv) { TTValue v; v.resize(argc); for (long i=0; i<argc; i++) { if (atom_gettype(argv+i) == A_LONG) v[i] = (TTInt32)atom_getlong(argv+i); else if (atom_gettype(argv+i) == A_FLOAT) v[i] = atom_getfloat(argv+i); else if (atom_gettype(argv+i) == A_SYM) v[i] = TT(atom_getsym(argv+i)->s_name); else object_error(SELF, "bad type for message arg"); } self->graphObject->mKernel.send(ttName, v, v); // FIXME: TEMPORARY HACK WHILE WE TRANSITION FROM 1-ARG MESSAGES to 2-ARG MESSAGES // process the returned value for the dumpout outlet { long ac = v.size(); if (ac) { t_atom* av = (t_atom*)malloc(sizeof(t_atom) * ac); for (long i=0; i<ac; i++) { if (v[i].type() == kTypeSymbol) { TTSymbol ttSym = v[i]; atom_setsym(av+i, gensym((char*)ttSym.c_str())); } else if (v[i].type() == kTypeFloat32 || v[i].type() == kTypeFloat64) { TTFloat64 f = v[i]; atom_setfloat(av+i, f); } else { TTInt32 l = v[i]; atom_setfloat(av+i, l); } } object_obex_dumpout(self, s, ac, av); free(av); } } } else self->graphObject->mKernel.send(ttName); }
void setGainDataspaceUnit(t_ui* obj, t_symbol* unit) { uiInternalObject *anObject = NULL; t_max_err err = MAX_ERR_NONE; err = hashtab_lookup(obj->hash_internals, gensym("gain"), (t_object**)&anObject); if(!err) object_attr_setsym(anObject->theObject, gensym("dataspace/unit/active"), unit); }
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); }
t_symbol *cmmjl_osc_getAddress(void *x){ if(!_cmmjl_obj_tab){ return NULL; } t_object *ob; t_max_err e; if(e = hashtab_lookup(_cmmjl_obj_tab, x, &ob)){ return NULL; } return ((t_cmmjl_obj *)ob)->osc_address; }
void *cmmjl_get_error_handler(void *x){ if(!_cmmjl_obj_tab){ return NULL; } t_object *o; t_max_err err; if(err = hashtab_lookup(_cmmjl_obj_tab, x, &o)){ return NULL; } return ((t_cmmjl_obj *)o)->error; }
void cc_anything(t_cc *x, t_symbol *msg, int argc, t_atom *argv){ while(x->compiling){}; x->ok_to_compile = 0; long f = 0; int inlet = proxy_getinlet((t_object *)x); hashtab_lookup(x->ht, msg, (t_object **)(&f)); if(f){ ((ccmethod)(f))((t_object *)x, x->user_obj, inlet, argc, argv, x->noutlets, x->outlets); goto out; } hashtab_lookup(x->ht, gensym("my_anything"), (t_object **)(&f)); if(f){ ((ccmethod_anything)(f))((t_object *)x, x->user_obj, inlet, msg, argc, argv, x->noutlets, x->outlets); goto out; } error("cc: doesn't respond to the message %s", msg->s_name); out: x->ok_to_compile = 1; }
t_max_err jamoma_hub_register(t_symbol *name, t_object *hub) { t_object *test = NULL; hashtab_lookup(hash_modules, name, &test); if(test) return MAX_ERR_GENERIC; else{ hashtab_store(hash_modules, name, hub); return MAX_ERR_NONE; } }
static const char *my_insert(struct HashTab *htab, int value) { struct MyNode *my = make_node(value); void **p; int key = value % cf_mod; p = hashtab_lookup(htab, key, true, my); if (!p) return "FAIL"; if (*p) return "EXISTS?"; *p = my; return "OK"; }
t_max_err attr_set_preview(t_ui *obj, void *attr, long argc, t_atom *argv) { uiInternalObject *anObject = NULL; long value = atom_getlong(argv); t_max_err err = MAX_ERR_NONE; if(obj->attr_ispreviewing != value){ obj->attr_ispreviewing = value; err = hashtab_lookup(obj->hash_internals, gensym("preview"), (t_object**)&anObject); if(!err) object_method(anObject->theObject, _sym_int, obj->attr_ispreviewing); } return err; }
static const char *my_remove(struct HashTab *h, int value) { struct MyNode tmp, *my; void **p; int key = value % cf_mod; tmp.value = value; p = hashtab_lookup(h, key, false, &tmp); if (!p) return "NEXIST"; my = *p; if (my->value != value) return "WRONG"; hashtab_delete(h, key, &tmp); free(my); p = hashtab_lookup(h, key, false, &tmp); if (p) return "EXISTS?"; return "OK"; }
t_max_err attr_set_gain(t_ui *obj, void *attr, long argc, t_atom *argv) { uiInternalObject *anObject = NULL; float value = atom_getfloat(argv); t_max_err err = MAX_ERR_NONE; if(obj->attr_gain != value){ obj->attr_gain = value; err = hashtab_lookup(obj->hash_internals, gensym("gain"), (t_object**)&anObject); if(!err) object_method(anObject->theObject, _sym_float, obj->attr_gain); } return err; }
void cc_list(t_cc *x, t_symbol *msg, short argc, t_atom *argv){ while(x->compiling){}; x->ok_to_compile = 0; long f = 0; hashtab_lookup(x->ht, gensym("my_list"), (t_object **)(&f)); if(!f){ error("cc: doesn't respond to message list"); goto out; } int inlet = proxy_getinlet((t_object *)x); ((ccmethod)(f))((t_object *)x, x->user_obj, inlet, argc, argv, x->noutlets, x->outlets); out: x->ok_to_compile = 1; }
void cc_int(t_cc *x, long l){ while(x->compiling){}; x->ok_to_compile = 0; long f = 0; hashtab_lookup(x->ht, gensym("my_int"), (t_object **)(&f)); if(!f){ error("cc: doesn't respond to message int"); goto out; } int inlet = proxy_getinlet((t_object *)x); ((ccmethod_int)(f))((t_object *)x, x->user_obj, inlet, l, x->noutlets, x->outlets); out: x->ok_to_compile = 1; }
method omax_object_getNotificationCallback(t_object *ob) { t_symbol *classname = object_classname(ob); if(!classname){ return NULL; } t_hashtab *ht = omax_class_getHashtab(classname->s_name); if(!ht){ return NULL; } method f = NULL; hashtab_lookup(ht, gensym("cnmat_internal_osc_notification_function"), (t_object **)(&f)); return f; }
void ar_lookup(t_ar *x, t_symbol *msg, short argc, t_atom *argv){ t_hashtab *ht; if(!(ht = (t_hashtab *)x->iname_ht->s_thing)){ return; } if(argc < 1){ return; } t_atombuf *ab; hashtab_lookup(ht, ar_encode_key(argv), (t_object **)(&ab)); if(ab){ outlet_list(x->outlets[1], NULL, 1, argv); outlet_list(x->outlets[0], NULL, ab->a_argc, ab->a_argv); } }
void ar_remove_encoded_key(t_hashtab *ht, t_linklist *ll, t_symbol *encoded_key){ if(!ht || !ll){ return; } if(encoded_key){ t_atombuf *ab; hashtab_lookup(ht, encoded_key, (t_object **)(&ab)); if(ab){ atombuf_free(ab); } hashtab_chuckkey(ht, encoded_key); linklist_chuckobject(ll, encoded_key); } }