static void *gate_new(t_floatarg f1, t_floatarg f2) { t_gate *x; int i, nouts = (int)f1; t_outlet **outs; t_pd *proxy; if (nouts < GATE_MINOUTS) nouts = GATE_DEFOUTS; if (nouts > GATE_C74MAXOUTS) fittermax_rangewarning(gate_class, GATE_C74MAXOUTS, "outlets"); nouts++; /* for convenience (the cost is one pointer) */ if (!(outs = (t_outlet **)getbytes(nouts * sizeof(*outs)))) return (0); if (!(proxy = pd_new(gate_proxy_class))) { freebytes(outs, nouts * sizeof(*outs)); return (0); } x = (t_gate *)pd_new(gate_class); x->x_nouts = nouts; x->x_outs = outs; x->x_proxy = proxy; ((t_gate_proxy *)proxy)->p_master = x; /* from max sdk manual: ``The dst parameter can be changed (or set to 0) dynamically with the inlet_to function... The gate object uses this technique to assign its inlet to one of several outlets, or no outlet at all.'' We have to use a proxy, because Pd's outlet is not a t_pd (besides, Pd does not handle inlets with null destination). */ inlet_new((t_object *)x, proxy, 0, 0); for (i = 1; i < nouts; i++) x->x_outs[i] = outlet_new((t_object *)x, &s_anything); gate_float(x, (f2 > 0 ? f2 : 0)); /* CHECKED */ return (x); }
static void maximum_list(t_maximum *x, t_symbol *s, int ac, t_atom *av) { if (ac > MAXIMUM_C74MAXITEMS) fittermax_rangewarning(*(t_pd *)x, MAXIMUM_C74MAXITEMS, "items"); while (ac && av->a_type != A_FLOAT) ac--, av++; /* CHECKME (a warning?) */ if (ac) { t_float fpick = av->a_w.w_float; ac--; av++; while (ac && av->a_type != A_FLOAT) ac--, av++; /* CHECKME */ if (ac) { t_float fnext, f = av->a_w.w_float; if (f > fpick) { fnext = fpick; fpick = f; } else fnext = f; ac--; av++; while (ac--) { if (av->a_type == A_FLOAT) { f = av->a_w.w_float; if (f > fpick) { fnext = fpick; fpick = f; } else if (f > fnext) fnext = f; } /* CHECKME else */ av++; } x->x_test = fnext; outlet_float(((t_object *)x)->ob_outlet, x->x_last = fpick); } else maximum_float(x, fpick); /* CHECKME */ } /* CHECKME else */ }
static void *bangbang_new(t_floatarg val) { t_bangbang *x; int i, nouts = (int)val; t_outlet **outs; if (nouts < BANGBANG_MINOUTS) nouts = BANGBANG_DEFOUTS; if (nouts > BANGBANG_C74MAXOUTS) fittermax_rangewarning(bangbang_class, BANGBANG_C74MAXOUTS, "outlets"); if (nouts > BANGBANG_DEFOUTS) { if (!(outs = (t_outlet **)getbytes(nouts * sizeof(*outs)))) return (0); } else outs = 0; x = (t_bangbang *)pd_new(bangbang_class); x->x_nouts = nouts; x->x_outs = (outs ? outs : x->x_outbuf); for (i = 0; i < nouts; i++) x->x_outs[i] = outlet_new((t_object *)x, &s_bang); return (x); }
static void *mtr_new(t_floatarg f) { t_mtr *x = 0; int ntracks = (int)f; t_mtrack **tracks; if (ntracks < 1) ntracks = 1; if (tracks = getbytes(ntracks * sizeof(*tracks))) { int i; t_mtrack **tpp; for (i = 0, tpp = tracks; i < ntracks; i++, tpp++) { if (!(*tpp = (t_mtrack *)pd_new(mtrack_class)) || !((*tpp)->tr_binbuf = binbuf_new()) || !((*tpp)->tr_clock = clock_new(*tpp, (t_method)mtrack_tick))) { if (*tpp) pd_free((t_pd *)*tpp); if ((*tpp)->tr_binbuf) binbuf_free((*tpp)->tr_binbuf); while (i--) { tpp--; binbuf_free((*tpp)->tr_binbuf); clock_free((*tpp)->tr_clock); pd_free((t_pd *)*tpp); } return (0); } } if (x = (t_mtr *)pd_new(mtr_class)) { int id; t_outlet *mainout = outlet_new((t_object *)x, &s_list); x->x_glist = canvas_getcurrent(); x->x_filehandle = hammerfile_new((t_pd *)x, 0, mtr_readhook, mtr_writehook, 0); if (ntracks > MTR_C74MAXTRACKS) fittermax_rangewarning(mtr_class, MTR_C74MAXTRACKS, "tracks"); x->x_ntracks = ntracks; x->x_tracks = tracks; for (id = 1; id <= ntracks; id++, tracks++) /* CHECKED 1-based */ { t_mtrack *tp = *tracks; inlet_new((t_object *)x, (t_pd *)tp, 0, 0); tp->tr_trackout = outlet_new((t_object *)x, &s_); tp->tr_mainout = mainout; tp->tr_owner = x; tp->tr_id = id; tp->tr_listed = 0; tp->tr_filehandle = /* LATER rethink */ hammerfile_new((t_pd *)tp, 0, mtrack_readhook, mtrack_writehook, 0); tp->tr_mode = MTR_STEPMODE; tp->tr_muted = 0; tp->tr_restarted = 0; tp->tr_atdelta = 0; tp->tr_ixnext = 0; tp->tr_tempo = 1.; tp->tr_clockdelay = 0.; tp->tr_prevtime = 0.; } } } return (x); }