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 *polywave_new(t_symbol *s, long argc, t_atom *argv) { t_polywave *x = (t_polywave *)object_alloc(polywave_class); if(x) { x->buf_proxy = (t_buffer_proxy **)sysmem_newptr(POLYWAVE_MAX_BUFFERS * sizeof(t_buffer_proxy *)); critical_new(&x->lock); int n = POLYWAVE_MAX_BUFFERS; while (--n) { x->buf_proxy[n] = NULL; } x->dims = ONE_D; x->interp_type = LINEAR; x->backup = x->interp_type; x->numbufs = 0; t_dictionary *d = NULL; d = dictionary_new(); if (d) { attr_args_dictionary(d, argc, argv); attr_dictionary_process(x, d); //calls appropriate class_attr_accessors object_free(d); } int numlets = 0; switch (x->dims) { case ONE_D: numlets = 2; break; case TWO_D: numlets = 5; break; default: object_error((t_object *)x, "dimention attribute set to unknown value, cannont create inlets"); break; } dsp_setup((t_pxobject *)x, numlets); outlet_new((t_object *)x, "signal"); } return x; }
void *grans_new(t_symbol *s, long argc, t_atom *argv) { int n; t_grans *x = (t_grans *)object_alloc(grans_class); if (x) { dsp_setup((t_pxobject *)x, 8); x->maxoscillators = DEFAULTMAXOSCILLATORS; if( argc > 0) { int i; t_atom *ap; for (i = 0, ap = argv; i < argc; i++, ap++) { if(atom_gettype(ap) == A_LONG) { switch(i){ case 0: n = atom_getlong(ap); x->maxoscillators = n; // object_post((t_object *)x, "%d oscillators initialized", n); break; case 1: n = atom_getlong(ap); x->numoutlets = n; // object_post((t_object *)x, "%d outlets?", n); while(n--){ outlet_new(x, "signal"); } default: break; } } } } else { x->numoutlets = 1; outlet_new(x, "signal"); // outlet_new(x, "signal"); } x->ob.z_misc |= Z_NO_INPLACE; x->base = (t_osc *)calloc(x->maxoscillators, sizeof(t_osc)); // x->modbase = (t_osc *)calloc(x->maxoscillators, sizeof(t_osc)); x->sinetab = (double *)calloc(STABSZ, sizeof(double)); x->wind_costab = (double *)calloc(STABSZ, sizeof(double)); x->expdecaytab = (double *)calloc(STABSZ, sizeof(double)); x->dampedsinetab = (double *)calloc(STABSZ, sizeof(double)); x->sincwindow = (double *)calloc(STABSZ, sizeof(double)); double coefshape[NSHAPINGTABS]; PowTableFunction(NSHAPINGTABS, coefshape, 1, 0.0001, 1.0, 2.0); x->exptab = (double **)calloc(NSHAPINGTABS, sizeof(double *)); long i; for(i = 0; i < NSHAPINGTABS; i++){ x->exptab[i] = (double *)calloc(STABSZ, sizeof(double)); if(x->exptab[i]) { PowTableFunction(STABSZ, x->exptab[i], 1, 0.0001, 1.0, coefshape[i] * 10.0); } else { object_error((t_object *)x, "could not allocate memory for lookup table"); } } x->samplerate = sys_getsr(); if(x->samplerate<=0) x->samplerate = 44100; x->sampleinterval = 1.0 / x->samplerate; x->pkw = ( STABSZ * x->sampleinterval ) ; x->maxhz = (x->samplerate / 2) * x->pkw; x->nosc = x->next_nosc = 0; x->prev_in1 = 0.0; x->sincripples = 5; //could make this an attribute, or maybe compute sinc in realtime... Makeoscsinetable(x); MakeCosWindow(x); MakeExpDecaytable(x); MakeDampedSineWindow(x); MakeSincWindow(x); grans_clear(x); x->always_on = 0; t_dictionary *d = NULL; d = dictionary_new(); if (d) { attr_args_dictionary(d, argc, argv); attr_dictionary_process(x, d); object_free(d); } } else { object_post((t_object *)x, "this is potentially bad!"); } return (x); }