static void *capture_new(t_symbol *s, t_floatarg f) { t_capture *x = 0; float *buffer; int bufsize = (int)f; /* CHECKME */ if (bufsize <= 0) /* CHECKME */ bufsize = CAPTURE_DEFSIZE; if (buffer = getbytes(bufsize * sizeof(*buffer))) { x = (t_capture *)pd_new(capture_class); x->x_canvas = canvas_getcurrent(); if (s && s != &s_) { if (s == gensym("x")) x->x_intmode = 'x'; else if (s == gensym("m")) x->x_intmode = 'm'; else x->x_intmode = 'd'; /* ignore floats */ } x->x_buffer = buffer; x->x_bufsize = bufsize; outlet_new((t_object *)x, &s_float); x->x_filehandle = hammerfile_new((t_pd *)x, 0, 0, capture_writehook, 0); capture_clear(x); } return (x); }
static void *capture_new(t_symbol *s, int ac, t_atom *av) { t_capture *x = 0; char mode = 0; int precision = -1; float *buffer; int bufsize = 0; char *indices = 0; int szindices = 0, nindices = -1; if (ac && av->a_type == A_SYMBOL) { t_symbol *s = av->a_w.w_symbol; if (s && *s->s_name == 'f') /* CHECKME */ mode = 'f'; ac--; av++; } if (ac && av->a_type == A_FLOAT) { bufsize = (int)av->a_w.w_float; /* CHECKME */ ac--; av++; if (ac && av->a_type == A_FLOAT) { int i; t_atom *ap; precision = (int)av->a_w.w_float; /* CHECKME */ ac--; av++; for (i = 0, ap = av; i < ac; i++, ap++) { if (ap->a_type == A_FLOAT) { int ndx = (int)ap->a_w.w_float; /* CHECKME noninteger, negative */ ndx++; if (ndx >= CAPTURE_MAXINDICES) { /* CHECKME complaint */ szindices = CAPTURE_MAXINDICES; break; } else if (ndx > szindices) szindices = ndx; } else break; /* CHECKME */ } if (szindices && (indices = getbytes(szindices * sizeof(*indices)))) { nindices = 0; while (i--) { int ndx = (int)av++->a_w.w_float; /* CHECKME noninteger */ if (ndx >= 0 && ndx < szindices) indices[ndx] = 1, nindices++; } } } } if (bufsize <= 0) /* CHECKME */ bufsize = CAPTURE_DEFSIZE; if (buffer = getbytes(bufsize * sizeof(*buffer))) { x = (t_capture *)pd_new(capture_class); x->x_glist = canvas_getcurrent(); x->x_mode = mode; if (precision < 0) /* CHECKME */ precision = CAPTURE_DEFPRECISION; else if (precision > CAPTURE_MAXPRECISION) /* CHECKME */ precision = CAPTURE_MAXPRECISION; if (x->x_precision = precision) sprintf(x->x_format, "%%.%dg", precision); x->x_indices = indices; x->x_szindices = szindices; x->x_nindices = nindices; x->x_nblock = 64; /* redundant */ x->x_buffer = buffer; x->x_bufsize = bufsize; x->x_filehandle = hammerfile_new((t_pd *)x, 0, 0, capture_writehook, 0); capture_clear(x); } else if (indices) freebytes(indices, szindices * sizeof(*indices)); return (x); }