void match_freebytes(t_match *x) { if (x->m_seen) sysmem_freeptr(x->m_seen);; if (x->m_want) sysmem_freeptr(x->m_want);; }
void inquisitor_attributes(t_inquisitor* x) { t_symbol** names = NULL; long count = 0; t_atom* av = NULL; if(!x->subject){ t_object* b = jpatcher_get_firstobject(x->patcher); while(b){ if(x->name == jbox_get_varname(b)){ x->subject = jbox_get_object(b); break; } b = jbox_get_nextobject(b); } } if(x->subject){ object_attr_getnames(x->subject, &count, (t_symbol***)&names); if(count && names){ av = (t_atom*)sysmem_newptr(sizeof(t_atom) * count); for(long i=0; i<count; i++) atom_setsym(av+i, names[i]); outlet_anything(x->outlet_names, atom_getsym(av), count-1, av+1); sysmem_freeptr(av); sysmem_freeptr(names); } } }
void gendy_free(t_gendy *x){ dsp_free((t_pxobject *)x); sysmem_freeptr(x->mMemoryAmp); sysmem_freeptr(x->mMemoryDur); }
~gmu_bufgranul() { sysmem_freeptr(linear_interp_table); sysmem_freeptr(gmu_bufgrain::tmp_buffer); delete env_shrbuf_manager; delete spat_class; //critical_exit(0); }
void FMfree(fmsynth *x) { if (x->waveTable) sysmem_freeptr(x->waveTable); if (x->waveTable2) sysmem_freeptr(x->waveTable2); if (x->window) sysmem_freeptr(x->window); dsp_free((t_pxobject *)x); //Free the object with Max's routine }
void hub_getstate(t_hub *x) { subscriberList* subscriber = x->subscriber; // head of the linked list subscriberIterator i; t_subscriber* t; char* text = NULL; long textsize = 0; if(!x->textEditor) x->textEditor = (t_object*)object_new(_sym_nobox, _sym_jed, x, 0); if(!x->textSize){ x->textSize = 4096; x->text = (char*)malloc(sizeof(char) * x->textSize); } x->text[0] = 0; critical_enter(0); for(i = subscriber->begin(); i != subscriber->end(); ++i) { t = *i; if(t->type == jps_subscribe_parameter){ long ac = NULL; t_atom* av = NULL; object_attr_getvalueof(t->object, jps_value, &ac, &av); // get atom_gettext(ac, av, &textsize, &text, 0); // this is a really lame way to do this... if(strlen(x->text) > (x->textSize - 1024)){ x->textSize += 4096; x->text = (char*)realloc(x->text, x->textSize); } strncat_zero(x->text, x->osc_name->s_name, x->textSize); strncat_zero(x->text, "/", x->textSize); strncat_zero(x->text, t->name->s_name, x->textSize); strncat_zero(x->text, " ", x->textSize); strncat_zero(x->text, text, x->textSize); strncat_zero(x->text, "\n", x->textSize); sysmem_freeptr(text); text = NULL; textsize = 0; } } critical_exit(0); object_method(x->textEditor, _sym_settext, x->text, _sym_utf_8); object_attr_setchar(x->textEditor, gensym("scratch"), 1); object_attr_setsym(x->textEditor, _sym_title, gensym("jamoma module state")); sysmem_freeptr(text); }
void scripto_dblclick(t_scripto *x) { if (x->s_patcher) object_method(x->s_patcher, gensym("vis")); else { t_dictionary *d = dictionary_new(); char parsebuf[256]; t_atom a; long ac = 0; t_atom *av = NULL; // create a patcher without scroll bars and a toolbar sprintf(parsebuf,"@defrect 0 0 300 400 @title scripto @enablehscroll 0 @enablevscroll 0 @presentation 0 @toolbarid \"\""); atom_setparse(&ac,&av,parsebuf); attr_args_dictionary(d,ac,av); atom_setobj(&a,d); sysmem_freeptr(av); x->s_patcher = (t_object *)object_new_typed(CLASS_NOBOX,gensym("jpatcher"),1, &a); freeobject((t_object *)d); // we created this dictionary and we don't need it anymore object_method(x->s_patcher,gensym("vis")); x->s_ui = newobject_sprintf(x->s_patcher, "@maxclass scripto_ui @patching_rect 0 0 300 400 @oncolor %.2f %.2f %.2f %.2f @offcolor %.2f %.2f %.2f %.2f", x->s_oncolor.red, x->s_oncolor.green, x->s_oncolor.blue, x->s_oncolor.alpha, x->s_offcolor.red, x->s_offcolor.green, x->s_offcolor.blue, x->s_offcolor.alpha); object_attach_byptr_register(x, x->s_ui, CLASS_BOX); // attach our UI object to us object_attach_byptr_register(x, x->s_patcher, CLASS_NOBOX); // attach our UI object to us } }
void jamoma_class_attr_get(t_object *o, t_symbol *attrName, long, t_atom *) { char cAttrName[256]; t_symbol *sAttrName; char *temp; long ac = 0; t_atom *av = NULL; t_jcom_core_subscriber_common *x = (t_jcom_core_subscriber_common*)o; strcpy(cAttrName, attrName->s_name); temp = strrchr(cAttrName, '/'); if(temp) *temp = 0; sAttrName = gensym(cAttrName); object_attr_getvalueof(o, sAttrName, &ac, &av); object_obex_dumpout(o, sAttrName, ac, av); if(x->hub != NULL){ char s[256]; t_atom a[4]; snprintf(s, 256, "%s:/%s", x->attr_name->s_name, attrName->s_name); atom_setsym(a+0, gensym(s)); sysmem_copyptr(av, a+1, sizeof(t_atom) * ac); object_method_typed(x->hub, jps_feedback, ac + 1, a, NULL); } if(ac) sysmem_freeptr(av); }
t_jit_err jit_gl_terrain_maxdim(t_jit_gl_terrain *x, void *attr, long argc, t_atom *argv) { long temp[2], i,j; float *vertnorms, *posit, *facenorms,*texcoords; if (argc&&argv) { temp[0] = jit_atom_getlong(argv+0); temp[1] = jit_atom_getlong(argv+1); } x->maxdim[0] = CLIP(temp[0], 256, 65535); x->maxdim[1] = CLIP(temp[1], 256, 65535); // replace with resize pointer!! important! and defer mem calling // alloc memory here if (x->posit) { sysmem_freeptr(x->posit); post("just free 'd posit"); } x->posit= sysmem_newptr(x->maxdim[0]*x->maxdim[1]*sizeof(float)); if(x->posit) { post("alloced posit %ld * %ld * %ld \(sizeof\(double\)\) = %ld bytes",x->maxdim[0], x->maxdim[1],sizeof(float),x->maxdim[0]*x->maxdim[1]*sizeof(float)); } else {
void omax_object_ioReport(t_object *x, t_symbol *msg, int argc, t_atom *argv) { long buflen; char *buf = NULL; if(argc == 0){ t_atom a; atom_setsym(&a, gensym("/*")); omax_object_createIOReport(x, msg, 1, &a, &buflen, &buf); }else{ omax_object_createIOReport(x, msg, argc, argv, &buflen, &buf); } if(!buf){ return; } char bundle[buflen + OSC_HEADER_SIZE]; osc_bundle_s_setBundleID(bundle); memcpy(bundle + OSC_HEADER_SIZE, buf, buflen); void *outlet = omax_object_getInfoOutlet(x); if(outlet){ t_atom out[2]; atom_setlong(out, buflen + OSC_HEADER_SIZE); atom_setlong(out + 1, (long)bundle); outlet_anything(outlet, gensym("FullPacket"), 2, out); } if(buf){ sysmem_freeptr(buf); } }
void uwemsp_free(t_uwemsp *x) { dsp_free((t_pxobject *)x); // needs to be called for MSP objects on free // delete our array of signal pointers sysmem_freeptr(x->u_buffers); }
// DSP Method void in_dsp(TTPtr self, t_signal **sp, short *count) { WrappedModularInstancePtr x = (WrappedModularInstancePtr)self; TTInputPtr anInput = (TTInputPtr)x->wrappedObject; void** audioVectors = NULL; TTUInt16 vectorSize = 0; if (anInput) { audioVectors = (void**)sysmem_newptr(sizeof(void*) * 3); audioVectors[0] = x; if (count[0] || count[1]) { if (sp[0]->s_n > vectorSize) vectorSize = sp[0]->s_n; audioVectors[1] = sp[0]->s_vec; audioVectors[2] = sp[1]->s_vec; } // set signal numChannels and vectorSize anInput->mSignalIn->setAttributeValue(kTTSym_numChannels, 1); anInput->mSignalOut->setAttributeValue(kTTSym_numChannels, 1); anInput->mSignalIn->setAttributeValue(kTTSym_vectorSize, vectorSize); anInput->mSignalOut->setAttributeValue(kTTSym_vectorSize, vectorSize); // anInput->mSignalIn will be set in the perform method anInput->mSignalOut->sendMessage(kTTSym_alloc); dsp_addv(in_perform, 3, audioVectors); sysmem_freeptr(audioVectors); } }
//this gets called when an object is destroyed. do stuff here if you need to clean up. void curvesmooth_free(t_curvesmooth *x) { int i; //gotta call this one, *before* you free other resources! thanks to Rob Sussman for pointing this out to me. dsp_free((t_pxobject *)x); for(i=0;i<TABLE_SIZE;i++) { if (x->s_table_k_exp[i]) //t_freebytes(x->s_table_k_exp[i], TABLE_SIZE*sizeof(double)); sysmem_freeptr(x->s_table_k_exp[i]); if (x->s_table_k_log[i]) //t_freebytes(x->s_table_k_log[i], TABLE_SIZE*sizeof(double)); sysmem_freeptr(x->s_table_k_log[i]); } }
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_root))::FreeAligned(void *blk) { FLEXT_ASSERT(blk); char *ori = *(char **)((char *)blk-sizeof(size_t)-sizeof(char *)); size_t bytes = *(size_t *)((char *)blk-sizeof(size_t)); if(UNLIKELY(bytes >= LARGEALLOC)) { #if FLEXT_SYS == FLEXT_SYS_MAX && defined(_SYSMEM_H_) sysmem_freeptr(ori); #else // use C library function for large memory blocks free(ori); #endif } else { //! We need system locking here for secondary threads! SYSLOCK(); #if defined(FLEXT_USE_CMEM) free(ori); #else freebytes(ori,bytes); #endif SYSUNLOCK(); } }
TTErr wrappedModularClass_setAttribute(TTPtr self, t_symbol *s, long argc, const t_atom *argv) { WrappedModularInstancePtr x = (WrappedModularInstancePtr)self; TTValue inputValue, outputValue; TTSymbol ttName; TTAttributePtr anAttribute= NULL; long ac = 0; t_atom *av = NULL; TTErr err; err = selectedObject->findAttribute(TTSymbol(s->s_name), &anAttribute); if (!err) { // set attribute's value if (argc && argv) { jamoma_ttvalue_from_Atom(inputValue, _sym_nothing, argc, argv); selectedObject->setAttributeValue(TTSymbol(s->s_name), inputValue); } // or get it and dumpout his value else { selectedObject->getAttributeValue(TTSymbol(s->s_name), outputValue); jamoma_ttvalue_to_Atom(outputValue, &ac, &av); object_obex_dumpout(self, s, ac, av); sysmem_freeptr(av); } } return err; }
t_max_err dbviewer_notify(t_dbviewer *x, t_symbol *s, t_symbol *msg, void *sender, void *data) { if(sender == x->d_view){ if(msg == ps_dbview_update){ dbviewer_bang(x); } else if(msg == ps_dbview_query_changed){ // dump all of the columns t_object *column = NULL; t_symbol **column_names = NULL; long numcolumns = 0; long i; hashtab_getkeys(x->d_columns, &numcolumns, &column_names); if(column_names){ for(i=0; i<numcolumns; i++){ column = jdataview_getnamedcolumn(x->d_dataview, column_names[i]); if(column) jdataview_deletecolumn(x->d_dataview, column); } sysmem_freeptr(column_names); } hashtab_clear(x->d_columns); } else if(msg == _sym_free){ object_detach_byptr((t_object *)x, x->d_view); x->d_view = NULL; } } return jbox_notify((t_jbox*)x, s, msg, sender, data); }
// DSP Method void PackDsp(PackPtr self, t_signal** sp, short* count) { TTUInt16 i, k=0; void **audioVectors = NULL; TTUInt16 highestIndexForConnectedSignal = 0; self->vectorSize = sp[0]->s_n; // Setup the perform method audioVectors = (void**)sysmem_newptr(sizeof(void*) * (self->maxNumChannels + 1)); audioVectors[k] = self; k++; self->numChannels = 0; for (i=0; i < self->maxNumChannels; i++) { self->numChannels++; audioVectors[k] = sp[i]->s_vec; k++; if (count[i]) highestIndexForConnectedSignal = i; } self->audioGraphObject->setOutputNumChannels(0, highestIndexForConnectedSignal+1); self->audioGraphObject->getUnitGenerator()->setAttributeValue(kTTSym_vectorSize, (uint)self->vectorSize); self->audioGraphObject->getUnitGenerator()->setAttributeValue(kTTSym_maxNumChannels, (uint)self->maxNumChannels); self->audioGraphObject->getUnitGenerator()->setAttributeValue(kTTSym_sampleRate, (uint)sp[0]->s_sr); dsp_addv(PackPerform, k, audioVectors); sysmem_freeptr(audioVectors); }
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_root))::operator delete(void *blk) { if(!blk) return; FLEXT_ASSERT(MemCheck(blk)); #ifdef FLEXT_DEBUGMEM char *ori = (char *)blk-sizeof(size_t)-sizeof(memtest); #else char *ori = (char *)blk-sizeof(size_t); #endif size_t bytes = *(size_t *)ori; if(UNLIKELY(bytes >= LARGEALLOC)) { #if FLEXT_SYS == FLEXT_SYS_MAX && defined(_SYSMEM_H_) sysmem_freeptr(ori); #else // use C library function for large memory blocks free(ori); #endif } else { //! We need system locking here for secondary threads! SYSLOCK(); freebytes(ori,bytes); SYSUNLOCK(); } }
void pictmeter_doread(t_pictmeter *x, t_symbol *s, long argc, t_atom *argv) { char filename[MAX_PATH_CHARS]; t_fourcc *type, outtype; long ntype; t_max_err err; char alloc; short path; t_jsurface *surface; jgraphics_getfiletypes(x, &ntype, &type, &alloc); if (s == gensym("")) { err = open_dialog(filename, &path, &outtype, type, ntype); if (err) return; } else { strcpy(filename,s->s_name); err = locatefile_extended(filename, &path, &outtype, type, ntype); if (err) return; } surface = jgraphics_image_surface_create_referenced(filename, path); if (surface) x->p_surface = surface; if (alloc) sysmem_freeptr((char *)type); }
void bed_free(t_bed *x) { /* Free allocated dynamic memory */ sysmem_freeptr(x->undo_samples); /* Print message to Max window */ post("bed • Object was deleted"); }
void buddy_free(t_buddy *x) { short i; for (i=1; i < x->b_num; i++) object_free(x->b_mem[i].m_proxy); sysmem_freeptr(x->b_mem); }
void gen7_free(t_gen7 *x) { if (x != NULL) { if (x->g_table != NULL) { sysmem_freeptr(x->g_table); // free the memory allocated for the table... } } }
void munger_free(t_munger *x) { dsp_free((t_pxobject *)x); object_free(x->l_buffer); if (x->recordBuf) //t_freebytes(x->recordBuf, BUFLENGTH * sizeof(float)); //t_freebytes(x->recordBuf, x->initbuflen * sizeof(float)); sysmem_freeptr(x->recordBuf); }
void oedge_free(t_oedge *x) { dsp_free((t_pxobject *)x); critical_free(x->lock); if(x->av){ sysmem_freeptr(x->av); } osc_bundle_u_free(x->bundle); }
// DSP Method void out_dsp(t_out *x, t_signal **sp, short *count) { short i, j, k=0; void** audioVectors = NULL; TTUInt8 numChannels = 0; TTUInt16 vs = sp[0]->s_n; int sr = sp[0]->s_sr; x->ramp_gain->setAttributeValue(TT("sr"), sr); // convert midi to db for tap_gain x->ramp_xfade->setAttributeValue(TT("sr"), sr); // convert midi to db for tap_gain audioVectors = (void**)sysmem_newptr(sizeof(void*) * ((x->numOutputs * 2) + 1)); audioVectors[k] = x; k++; for(i=0; i < x->numOutputs; i++){ j = x->numOutputs + i; if(count[i] || count[j]){ numChannels++; if(sp[i]->s_n > vs) vs = sp[i]->s_n; audioVectors[k] = sp[i]->s_vec; k++; audioVectors[k] = sp[j]->s_vec; k++; } } x->numChannels = numChannels; x->audioIn->setAttributeValue(TT("numChannels"), numChannels); x->audioOut->setAttributeValue(TT("numChannels"), numChannels); x->audioTemp->setAttributeValue(TT("numChannels"), numChannels); x->zeroSignal->setAttributeValue(TT("numChannels"), numChannels); x->vectorSize = vs; x->audioIn->setAttributeValue(TT("vectorSize"), vs); x->audioOut->setAttributeValue(TT("vectorSize"), vs); x->audioTemp->setAttributeValue(TT("vectorSize"), vs); x->zeroSignal->setAttributeValue(TT("vectorSize"), vs); //audioIn will be set in the perform method x->audioOut->sendMessage(TT("alloc")); x->audioTemp->sendMessage(TT("alloc")); x->zeroSignal->sendMessage(TT("alloc")); x->zeroSignal->sendMessage(TT("clear")); dsp_addv(out_perform, k, audioVectors); sysmem_freeptr(audioVectors); // start the meters if(x->num_meter_objects){ for(i=0; i<MAX_NUM_CHANNELS; i++) x->peakamp[i] = 0; clock_delay(x->clock, kPollIntervalDefault); // start the clock } }
void hub_unsubscribe(t_hub *x, t_object *subscriber_object) { subscriberList *subscribers = x->subscriber; // Search the linked list for this object and remove it t_subscriber* t; critical_enter(0); for(subscriberIterator item = subscribers->begin(); item != subscribers->end(); ++item) { t = *item; if(t->object == subscriber_object) { if(t->type == jps_subscribe_parameter) x->num_parameters--; /* Temporarily disabling this for Jamoma 0.5 We need to evaluate whether or not this is needed any more given the new way we are doing the UI. [TAP] else if(t->type == jps_subscribe_in){ if(x->out_object) object_method(x->out_object, jps_unlink_out); } else if(t->type == jps_subscribe_out){ if(x->in_object) object_method(x->in_object, jps_unlink_in); } else if(t->type == jps_subscribe_remote){ char temp[32]; for(short i=0; i<MAX_NUM_CHANNELS; i++) { snprintf(temp, 32, "__meter__%i", i); if(t->name == gensym(temp)) { if(x->out_object) object_method(x->out_object, gensym("remove_meters")); } } } */ item = subscribers->erase(item); sysmem_freeptr(t); /** XXX why does this need to be here? It seems Microsoft's compiler is generating code * that will preincrement (++) the item iterator in the for loop despite the fact that * the for loops if condition has been met and following conditional statement shouldn't * execute. Either that or something awkward about the the behavior of their STL * implementation */ // XXX -- TIM is commenting it out temporarily. It may not effect us anymore with all of the recent changes? // If we have processed the unsub then we really want to just break right away... //if(item == subscribers->end()) break; } } // TODO: We really need to use our own mutex instead of the global critical region [TAP] critical_exit(0); }
// DSP Method void fade_dsp(t_fade *x, t_signal **sp, short *count) { short i, j, k, l=0; void **audioVectors = NULL; TTUInt8 numChannels = 0; TTUInt16 vs = 0; if(count[x->numChannels * 2]) // SIGNAL RATE CROSSFADE CONNECTED audioVectors = (void**)sysmem_newptr(sizeof(void*) * ((x->numChannels * 3) + 2)); else // CONTROL RATE CROSSFADE audioVectors = (void**)sysmem_newptr(sizeof(void*) * ((x->numChannels * 3) + 1)); audioVectors[l] = x; l++; // audioVectors[] passed to balance_perform() as {x, audioInL[0], audioInR[0], audioOut[0], audioInL[1], audioInR[1], audioOut[1],...} for(i=0; i < x->numChannels; i++){ j = x->numChannels + i; k = x->numChannels*2 + i + 1; // + 1 to account for the position input if(count[i] && count[j] && count[k]){ numChannels++; if(sp[i]->s_n > vs) vs = sp[i]->s_n; audioVectors[l] = sp[i]->s_vec; l++; audioVectors[l] = sp[j]->s_vec; l++; audioVectors[l] = sp[k]->s_vec; l++; } } if(count[x->numChannels * 2]){ // SIGNAL RATE CROSSFADE CONNECTED audioVectors[l] = sp[x->numChannels*2]->s_vec; l++; } x->audioIn1->setNumChannels(numChannels); x->audioIn2->setNumChannels(numChannels); x->audioOut->setNumChannels(numChannels); x->audioIn1->setVectorSizeWithInt(vs); x->audioIn2->setVectorSizeWithInt(vs); x->audioOut->setVectorSizeWithInt(vs); //audioIn will be set in the perform method x->audioOut->alloc(); x->xfade->setAttributeValue(kTTSym_sampleRate, sp[0]->s_sr); if(count[x->numChannels * 2]) // SIGNAL RATE CROSSFADE CONNECTED dsp_addv(fade_perform2, l, audioVectors); else dsp_addv(fade_perform1, l, audioVectors); sysmem_freeptr(audioVectors); }
void data_address(TTPtr self, t_symbol *address) { WrappedModularInstancePtr x = (WrappedModularInstancePtr)self; // Avoid succession of address changes if (!EXTRA->changingAddress) { EXTRA->changingAddress = YES; // filter repetitions if (!(x->arrayAddress == TTAddress(address->s_name))) { if (!x->iterateInternals) { // unregister internals wrappedModularClass_unregister(x); x->arraySize = 0; // rebuild internals defer(self,(method)data_new_address, address, 0, NULL); // for array mode : output the array once afterward if (x->arrayAttrFormat == gensym("array")) { TTValue array; t_symbol *msg; long argc = 0; t_atom *argv = NULL; TTBoolean shifted = NO; data_edit_array(self, array); jamoma_ttvalue_to_typed_Atom(array, &msg, &argc, &argv, shifted); // avoid blank before data if (msg == _sym_nothing) outlet_atoms(x->outlets[data_out], argc, argv); else outlet_anything(x->outlets[data_out], msg, argc, argv); if (shifted) argv--; sysmem_freeptr(argv); } } } EXTRA->changingAddress = NO; return; } object_error((t_object*)x, "can't change to %s address. Please defer low", address->s_name); }
void tralala_paintStrncatPanel(char *dst, long argc, t_atom *argv) { long k = 0; char *p = NULL; if (!(atom_gettext(argc - 1, argv + 1, &k, &p, OBEX_UTIL_ATOM_GETTEXT_SYM_NO_QUOTE))) { strncat_zero(dst, p, TLL_STRING_SIZE); strncat_zero(dst, "\n", TLL_STRING_SIZE); sysmem_freeptr(p); } }
void dict_recurse_free(t_dict_recurse *x) { TRACE("dict_recurse_free"); if (x->path) { sysmem_freeptr(x->path); } regexpr_free(x->search_key_expr); regexpr_free(x->search_val_expr); re_free(&x->re2); }