Beispiel #1
0
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);
}
Beispiel #2
0
static void *hammer_new(void)
{
    t_hammer *x = (t_hammer *)pd_new(hammer_class);
    x->x_filehandle = hammerfile_new((t_pd *)x, 0, hammer_readhook, 0, 0);
    outlet_new((t_object *)x, &s_float);
    return (x);
}
Beispiel #3
0
static void *sickle_new(void)
{
    t_sickle *x = (t_sickle *)pd_new(sickle_class);
    x->x_filehandle = hammerfile_new((t_pd *)x, 0, sickle_readhook, 0, 0);
    outlet_new((t_object *)x, &s_float);
    return (x);
}
Beispiel #4
0
static void *maxmode_new(t_symbol *s, int ac, t_atom *av)
{
    t_maxmode *x = (t_maxmode *)pd_new(maxmode_class);
    int selective = ac;
    if (maxmode_withbanner && !ac)
    {
	post("this is maxmode %s, %s %s build",
	     CYCLONE_VERSION, loud_ordinal(CYCLONE_BUILD), CYCLONE_RELEASE);
	loud_warning(0, "maxmode",
 "creating maxmode object without loading cyclone components");
	maxmode_withbanner = 0;
    }
    if (selective)
    {
	/* a numeric argument is valid -- transparent object is created
	   (global mode is not set, nothing is registered) */
	while (ac--) if (av->a_type == A_SYMBOL)
	{
	    /* FIXME register into fitter for per-patch-file, selective
	       compatibility control */
	    av++;
	}
    }
    else if (!fittermax_get())
	fittermax_set();
    x->x_filehandle = hammerfile_new((t_pd *)x, 0, maxmode_readhook, 0, 0);
    outlet_new((t_object *)x, &s_float);
    x->x_modeout = outlet_new((t_object *)x, &s_symbol);
    return (x);
}
Beispiel #5
0
static void *prob_new(void)
{
    t_prob *x = (t_prob *)pd_new(prob_class);
    x->x_translist = 0;
    x->x_state = 0;
    x->x_default = 0;
    x->x_embedmode = 0;  /* CHECKED */
    x->x_silent = 0;
    rand_seed(&x->x_seed, 0);
    outlet_new((t_object *)x, &s_float);
    x->x_bangout = outlet_new((t_object *)x, &s_bang);
    x->x_filehandle = hammerfile_new((t_pd *)x, prob_embedhook, 0, 0, 0);
    return (x);
}
Beispiel #6
0
void *plustot_env_new(t_symbol *s, int ac, t_atom *av)
{
    t_plustot_env *x = 0;
    t_glist *gl = canvas_getcurrent();
    t_plustin *oldtin = plustin_glistfind(gl, PLUSTIN_GLIST_THIS);
    t_plustin *deftin = (oldtin ? 0 : plustin_glistfind(gl, PLUSTIN_GLIST_ANY));
    t_plustin *tin = 0;
    if ((tin = oldtin)
	|| (tin = plustin_glistprovide(gl, PLUSTIN_GLIST_THIS, 1)))
    {
	int warned = 0;
	x = (t_plustot_env *)plusobject_new(plustot_env_class, s, ac, av, 0);
	x->x_tin = tin;
	plusbob_preserve((t_plusbob *)tin);
	x->x_glist = gl;
	plusoutlet_new(&x->x_plusobject, &s_symbol);
	if (deftin)
	    /* true if both oldtin == 0 (we are first in this glist)
	       and plustin_default != 0 (bobs exist already) */
	    plustot_env_takeover(x->x_glist,
				 (t_plusbob *)deftin, (t_plusbob *)tin);
	x->x_filehandle = hammerfile_new((t_pd *)x, 0,
					 plustot_env_evalfilehook, 0, 0);
	while (ac--)
	{
	    if (av->a_type == A_SYMBOL)
		plustot_env_evalfile(x, av->a_w.w_symbol);
	    else if (!warned)
	    {
		loud_warning((t_pd *)x, 0, "bad atom");
		warned = 1;
	    }
	    av++;
	}
    }
    else loud_error(0, "+env: cannot initialize");
    return (x);
}
Beispiel #7
0
static void *funbuff_new(t_symbol *s)
{
    t_funbuff *x = (t_funbuff *)pd_new(funbuff_class);
    x->x_canvas = canvas_getcurrent();
    x->x_valueset = 0;
    x->x_pointer = 0;
    x->x_pointerset = 0;  /* CHECKME, rename to intraversal? */
    x->x_lastdelta = 0;
    x->x_embedflag = 0;
    hammertree_inittyped(&x->x_tree, HAMMERTYPE_FLOAT, 0);
    inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft1"));
    outlet_new((t_object *)x, &s_float);
    x->x_deltaout = outlet_new((t_object *)x, &s_float);
    x->x_bangout = outlet_new((t_object *)x, &s_bang);
    if (s && s != &s_)
    {
        x->x_defname = s;  /* CHECKME if 'read' changes this */
        funbuff_doread(x, s);
    }
    else x->x_defname = &s_;
    x->x_filehandle = hammerfile_new((t_pd *)x, funbuff_embedhook,
                                     funbuff_readhook, funbuff_writehook, 0);
    return (x);
}
Beispiel #8
0
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);
}
Beispiel #9
0
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);
}