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 *dummy_new(t_symbol *s, long argc, t_atom *argv) { t_dummy *x = NULL; if (x = (t_dummy *)object_alloc(dummy_class)) { x->name = gensym(""); if (argc && argv) { x->name = atom_getsym(argv); } if (!x->name || x->name == gensym("")) x->name = symbol_unique(); atom_setlong(&x->val, 0); x->out = outlet_new(x, NULL); } return (x); }
void *breakgen_new(t_symbol *s, long argc, t_atom *argv) { t_breakgen *x = NULL; if ((x = (t_breakgen *)object_alloc(breakgen_class))) { x->name = gensym(""); if (argc && argv) { x->name = atom_getsym(argv); } if (!x->name || x->name == gensym("")) x->name = symbol_unique(); atom_setlong(&x->val, 0); x->out = outlet_new(x, NULL); x->constsig = 0; x->constval = 1.0; x->rando_gen = NULL; x->rando_gen = new_rando(); if(x->rando_gen == NULL){ post("no memory for random generator\n"); } x->rando_func = no_rando; srand(time(NULL)); x->tick = sinetick; x->sr = 10000.00; x->freq = 100.00; x->osc = NULL; x->osc = new_oscil(x->sr); if(x->osc == NULL){ post("no memory for oscillator\n"); } x->buffy = buffer_ref_new((t_object *)x, gensym("buffy")); if (buffer_ref_exists(x->buffy) != 0) { post("buf ref exists"); } else { post("buf ref doesn't exist"); }; } return (x); }
void *dummy_new(t_symbol *s, long argc, t_atom *argv) { t_dummy *x = NULL; if (x = (t_dummy *)object_alloc(dummy_class)) { x->name = gensym(""); if (argc && argv) { x->name = atom_getsym(argv); } if (!x->name || x->name == gensym("")) x->name = symbol_unique(); atom_setlong(&x->val, 0); x->out = outlet_new(x, NULL); double val = 35.78; object_post((t_object *) x, "d3-3 %e %f %g", val, val, val);//!!!! } return (x); }
void testrunner_one_integration(t_testrunner *r, t_symbol *testname) { t_testdb *db = (t_testdb*)((t_testmaster*)(ps_testmaster->s_thing))->m_db; t_symbol *pound_t = gensym("#T"); if (!r->r_running) { // start it t_testunit *testunit = (t_testunit*)testunit_new(NULL, 0, NULL); r->r_testid = testdb_createcase(db, testname->s_name); testunit->o_db = db; testunit->o_id = r->r_testid; testdb_log(db, r->r_testid, "preparing to run %s", testname->s_name); pound_t->s_thing = (t_object*)testunit; object_method(_sym_max->s_thing, _sym_openfile, symbol_unique(), testname, 0); object_attach_byptr_register(r, testunit, _sym_nobox); r->r_testunit = (t_test*)testunit; r->r_running = true; } else { // try to finish it if (r->r_terminated) { t_max_err err = MAX_ERR_NONE; // moved to here from the block above because when loading a maxzip the patcher instantiation maybe deferred/asynchronous pound_t->s_thing = NULL; testdb_log(db, r->r_testid, "concluding test"); err = object_free(r->r_testunit); testdb_log(db, r->r_testid, "test patcher freed with status %i", err); testdb_closecase(db, r->r_testid); r->r_running = false; return; } } qelem_set(r->r_qelem); }
void *return_new(t_symbol *s, long argc, t_atom *argv) { long attrstart = attr_args_offset(argc, argv); t_return* x = (t_return *)object_alloc(return_class); t_symbol* name = _sym_nothing; ObjectPtr patcher = NULL; if (attrstart && argv) atom_arg_getsym(&name, 0, attrstart, argv); else name = symbol_unique(); // for instances buried inside of another object: // we pass a second argument which is a pointer to the patcher if (attrstart>1 && argv) patcher = ObjectPtr(atom_getobj(argv+1)); if (x) { x->outlets[k_outlet_dumpout] = outlet_new(x, 0L); object_obex_store((void *)x, _sym_dumpout, (t_object *)x->outlets[k_outlet_dumpout]); x->outlets[k_outlet_thru] = outlet_new(x, 0L); jcom_core_subscriber_new_extended(&x->common, name, jps_subscribe_return); atom_setsym(&x->output[0], name); x->output_len = 1; x->attrEnable = true; x->attrDataspace = jps_none; x->attrUnitNative = jps_none; if (patcher) x->common.container = patcher; attr_args_process(x, argc, argv); jcom_core_subscriber_subscribe((t_jcom_core_subscriber_common*)x); return_makesend(x); } return (x); }
void filecontainer_gettemppath(t_filecontainer *x) { char temppath[512]; char outpath[512]; t_symbol *unique = symbol_unique(); OSErr err = 0; #ifdef MAC_VERSION FSRef folderref, newref; UniChar uni[512]; unsigned short i; err = FSFindFolder(kUserDomain, kTemporaryFolderType, kCreateFolder, &folderref); err = FSRefMakePath(&folderref, (UInt8 *)temppath, 511); strcat(temppath, "/"); #else // WIN_VERSION GetTempPath(512, (LPSTR)temppath); #endif strcat(temppath, unique->s_name); #ifdef MAC_VERSION for(i=0; i<strlen(unique->s_name); i++) // Convert from 8-bit ASCII to 16-bit Unicode uni[i] = unique->s_name[i]; err = FSCreateDirectoryUnicode(&folderref, strlen(unique->s_name), uni, kFSCatInfoNone, NULL, &newref, NULL, NULL); #else // WIN_VERSION CreateDirectory((LPCSTR)temppath, NULL); #endif path_nameconform(temppath, outpath, PATH_STYLE_MAX, PATH_TYPE_ABSOLUTE); x->temp_fullpath = gensym(outpath); path_frompathname(outpath, &x->temp_path, temppath); // re-using temppath since we don't need it anymore // Add to the searchpath path_addnamed(SEARCH_PATH, outpath, 1, 0); }
t_paramui* paramui_new(t_symbol *s, long argc, t_atom *argv) { t_paramui *x = NULL; t_dictionary *d = NULL; long flags; t_atom a[LISTSIZE+34]; long argLen; //t_max_err err = MAX_ERR_NONE; if(!(d=object_dictionaryarg(argc, argv))) return NULL; if(x = (t_paramui*)object_alloc(s_ui_class)){ flags = 0 | JBOX_DRAWFIRSTIN | JBOX_NODRAWBOX // | JBOX_DRAWINLAST | JBOX_TRANSPARENT // | JBOX_NOGROW // | JBOX_GROWY // | JBOX_GROWBOTH // | JBOX_IGNORELOCKCLICK | JBOX_HILITE // | JBOX_BACKGROUND // | JBOX_NOFLOATINSPECTOR | JBOX_TEXTFIELD ; jbox_new(&x->box, flags, argc, argv); x->box.b_firstin = (t_object *)x; x->outlet = outlet_new(x, 0L); x->menu_items = NULL; attr_dictionary_process(x, d); // handle attribute args // a textlayout is used for the displaying the value and the unit x->layout_value = jtextlayout_create(); x->layout_unit = jtextlayout_create(); jbox_ready(&x->box); x = (t_paramui *)object_register(CLASS_BOX, symbol_unique(), x); x->menu_items = (t_linklist *)linklist_new(); paramui_menu_build(x); x->menu_qelem = qelem_new(x, (method)paramui_menu_qfn); // here we create our internal instance of jcom.parameter atom_setsym(a+0, x->attr_name); atom_setsym(a+1, gensym("@type")); atom_setsym(a+2, x->attr_type); atom_setsym(a+3, gensym("@ramp/drive")); atom_setsym(a+4, x->attr_rampDrive); atom_setsym(a+5, gensym("@ramp/function")); atom_setsym(a+6, x->attr_rampFunction); atom_setsym(a+7, gensym("@view/freeze")); atom_setlong(a+8, x->attr_uiFreeze); atom_setsym(a+9, gensym("@value/stepsize")); atom_setfloat(a+10, x->attr_stepsize); atom_setsym(a+11, gensym("@priority")); atom_setlong(a+12, x->attr_priority); atom_setsym(a+13, gensym("@range/bounds")); atom_setfloat(a+14, x->attr_range[0]); atom_setfloat(a+15, x->attr_range[1]); atom_setsym(a+16, gensym("@repetitions/allow")); atom_setlong(a+17, x->attr_repetitions); atom_setsym(a+18, gensym("@range/clipmode")); atom_setsym(a+19, x->attr_clipmode); atom_setsym(a+20, gensym("@description")); atom_setsym(a+21, x->attr_description); atom_setsym(a+22, gensym("@dataspace")); atom_setsym(a+23, x->attr_dataspace); atom_setsym(a+24, gensym("@dataspace/unit/active")); atom_setsym(a+25, x->attr_unitActive); atom_setsym(a+26, gensym("@dataspace/unit/native")); atom_setsym(a+27, x->attr_unitNative); if(x->attr_defaultSize){ atom_setsym(a+28, gensym("@value/default")); sysmem_copyptr(x->attr_default, a+29, sizeof(t_atom) * x->attr_defaultSize); argLen = 29 + x->attr_defaultSize; } else argLen = 28; jcom_core_loadextern(gensym("jcom.parameter"), argLen, a, &x->obj_parameter); } return x; }