Commit f2f04f3d authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

make all cyclone classes instantiate when no arguments are provided

parent fab23d62
......@@ -142,7 +142,6 @@ void Clip_setup(void)
(t_method)clip_free,
sizeof(t_clip), 0,
A_GIMME, 0);
class_addcreator((t_newmethod)clip_new, gensym("clip"), A_GIMME, 0);
class_addcreator((t_newmethod)clip_new, gensym("cyclone/clip"), A_GIMME, 0);
class_addfloat(clip_class, clip_float);
class_addlist(clip_class, clip_list);
......
......@@ -395,9 +395,16 @@ static void pv_free(t_pv *x)
static void *pv_new(t_symbol *s, int ac, t_atom *av)
{
t_pv *x = 0;
t_atom sane_default;
if (ac && av->a_type == A_SYMBOL)
s = av->a_w.w_symbol;
else s = 0;
else
{
post("pv: warning: no symbol argument provided: defaulting to 'dummy'");
SETSYMBOL(&sane_default, gensym("dummy"));
ac = 1;
av = &sane_default;
}
if (s && s != &s_)
{
t_glist *gl = canvas_getcurrent();
......
......@@ -55,7 +55,6 @@ void Clip_tilde_setup(void)
clip_class = class_new(gensym("Clip~"),
(t_newmethod)clip_new, 0,
sizeof(t_clip), 0, A_GIMME, 0);
class_addcreator((t_newmethod)clip_new, gensym("clip~"), A_GIMME, 0);
class_addcreator((t_newmethod)clip_new, gensym("cyclone/clip~"), A_GIMME, 0);
sic_setup(clip_class, clip_dsp, SIC_FLOATTOSIGNAL);
}
......
......@@ -323,7 +323,6 @@ void Line_tilde_setup(void)
(t_newmethod)line_new,
(t_method)line_free,
sizeof(t_line), 0, A_DEFFLOAT, 0);
class_addcreator((t_newmethod)line_new, gensym("line~"), A_DEFFLOAT, 0);
class_addcreator((t_newmethod)line_new, gensym("cyclone/line~"), A_DEFFLOAT, 0);
sic_setup(line_class, line_dsp, SIC_NOMAINSIGNALIN);
class_addfloat(line_class, line_float);
......
......@@ -148,7 +148,6 @@ void Snapshot_tilde_setup(void)
(t_method)snapshot_free,
sizeof(t_snapshot), 0,
A_DEFFLOAT, A_DEFFLOAT, 0);
class_addcreator((t_newmethod)snapshot_new, gensym("snapshot~"), A_DEFFLOAT, A_DEFFLOAT, 0);
class_addcreator((t_newmethod)snapshot_new, gensym("cyclone/snapshot~"), A_DEFFLOAT, A_DEFFLOAT, 0);
sic_setup(snapshot_class, snapshot_dsp, snapshot_float);
class_addbang(snapshot_class, snapshot_bang);
......
......@@ -482,79 +482,89 @@ static void matrix_free(t_matrix *x)
static void *matrix_new(t_symbol *s, int ac, t_atom *av)
{
t_pd *z;
t_atom sane_defaults[3];
if (!fittermax_get() &&
(z = fragile_class_mutate(matrixps_matrixtilde,
(t_newmethod)matrix_new, ac, av)))
{
return (z);
}
if (!ac) // sane defaults if no arguments given
{
post("matrix~: warning: no arguments supplied: picking sane "
"defaults [matrix~ 1 1 0]");
SETFLOAT(sane_defaults, 1.);
SETFLOAT(sane_defaults, 1.);
SETFLOAT(sane_defaults, 0.);
ac = 3;
av = sane_defaults;
}
else if (ac < 2)
{
loud_error(0, "bad creation arguments for class '%s'",
matrixps_matrixtilde->s_name);
loud_errand(0, "missing number of %s", (ac ? "outlets" : "inlets"));
return (0); /* CHECKED */
loud_error(0, "bad creation arguments for class '%s'",
matrixps_matrixtilde->s_name);
loud_errand(0, "missing number of %s", (ac ? "outlets" : "inlets"));
return (0); /* CHECKED */
}
t_matrix *x = (t_matrix *)pd_new(matrix_class);
int i;
if (av[0].a_type == A_FLOAT)
{
if ((x->x_ninlets = (int)av[0].a_w.w_float) < 1)
x->x_ninlets = 1;
}
else x->x_ninlets = 1; /* CHECKED */
if (av[1].a_type == A_FLOAT)
{
if ((x->x_noutlets = (int)av[1].a_w.w_float) < 1)
x->x_noutlets = 1;
}
else x->x_noutlets = 1; /* CHECKED */
x->x_ncells = x->x_ninlets * x->x_noutlets;
x->x_ivecs = getbytes(x->x_ninlets * sizeof(*x->x_ivecs));
x->x_ovecs = getbytes(x->x_noutlets * sizeof(*x->x_ovecs));
x->x_nblock = x->x_maxblock = sys_getblksize();
x->x_osums = getbytes(x->x_noutlets * sizeof(*x->x_osums));
for (i = 0; i < x->x_noutlets; i++)
x->x_osums[i] = getbytes(x->x_maxblock * sizeof(*x->x_osums[i]));
x->x_cells = getbytes(x->x_ncells * sizeof(*x->x_cells));
matrix_clear(x);
if (ac >= 3)
{
if (av[2].a_type == A_FLOAT)
x->x_defgain = av[2].a_w.w_float;
else
x->x_defgain = MATRIX_DEFGAIN;
x->x_gains = getbytes(x->x_ncells * sizeof(*x->x_gains));
for (i = 0; i < x->x_ncells; i++)
x->x_gains[i] = x->x_defgain;
x->x_ramps = getbytes(x->x_ncells * sizeof(*x->x_ramps));
matrix_ramp(x, MATRIX_DEFRAMP);
x->x_coefs = getbytes(x->x_ncells * sizeof(*x->x_coefs));
for (i = 0; i < x->x_ncells; i++)
x->x_coefs[i] = 0.;
x->x_ksr = sys_getsr() * .001;
x->x_incrs = getbytes(x->x_ncells * sizeof(*x->x_incrs));
x->x_bigincrs = getbytes(x->x_ncells * sizeof(*x->x_bigincrs));
x->x_remains = getbytes(x->x_ncells * sizeof(*x->x_remains));
for (i = 0; i < x->x_ncells; i++)
x->x_remains[i] = 0;
}
else
{
t_matrix *x = (t_matrix *)pd_new(matrix_class);
int i;
if (av[0].a_type == A_FLOAT)
{
if ((x->x_ninlets = (int)av[0].a_w.w_float) < 1)
x->x_ninlets = 1;
}
else x->x_ninlets = 1; /* CHECKED */
if (av[1].a_type == A_FLOAT)
{
if ((x->x_noutlets = (int)av[1].a_w.w_float) < 1)
x->x_noutlets = 1;
}
else x->x_noutlets = 1; /* CHECKED */
x->x_ncells = x->x_ninlets * x->x_noutlets;
x->x_ivecs = getbytes(x->x_ninlets * sizeof(*x->x_ivecs));
x->x_ovecs = getbytes(x->x_noutlets * sizeof(*x->x_ovecs));
x->x_nblock = x->x_maxblock = sys_getblksize();
x->x_osums = getbytes(x->x_noutlets * sizeof(*x->x_osums));
for (i = 0; i < x->x_noutlets; i++)
x->x_osums[i] = getbytes(x->x_maxblock * sizeof(*x->x_osums[i]));
x->x_cells = getbytes(x->x_ncells * sizeof(*x->x_cells));
matrix_clear(x);
if (ac >= 3)
{
if (av[2].a_type == A_FLOAT)
x->x_defgain = av[2].a_w.w_float;
else
x->x_defgain = MATRIX_DEFGAIN;
x->x_gains = getbytes(x->x_ncells * sizeof(*x->x_gains));
for (i = 0; i < x->x_ncells; i++)
x->x_gains[i] = x->x_defgain;
x->x_ramps = getbytes(x->x_ncells * sizeof(*x->x_ramps));
matrix_ramp(x, MATRIX_DEFRAMP);
x->x_coefs = getbytes(x->x_ncells * sizeof(*x->x_coefs));
for (i = 0; i < x->x_ncells; i++)
x->x_coefs[i] = 0.;
x->x_ksr = sys_getsr() * .001;
x->x_incrs = getbytes(x->x_ncells * sizeof(*x->x_incrs));
x->x_bigincrs = getbytes(x->x_ncells * sizeof(*x->x_bigincrs));
x->x_remains = getbytes(x->x_ncells * sizeof(*x->x_remains));
for (i = 0; i < x->x_ncells; i++)
x->x_remains[i] = 0;
}
else
{
x->x_gains = 0;
x->x_ramps = 0;
x->x_coefs = 0;
x->x_incrs = 0;
x->x_bigincrs = 0;
x->x_remains = 0;
}
for (i = 1; i < x->x_ninlets; i++)
sic_newinlet((t_sic *)x, 0.);
for (i = 0; i < x->x_noutlets; i++)
outlet_new((t_object *)x, &s_signal);
x->x_dumpout = outlet_new((t_object *)x, &s_list);
return (x);
x->x_gains = 0;
x->x_ramps = 0;
x->x_coefs = 0;
x->x_incrs = 0;
x->x_bigincrs = 0;
x->x_remains = 0;
}
for (i = 1; i < x->x_ninlets; i++)
sic_newinlet((t_sic *)x, 0.);
for (i = 0; i < x->x_noutlets; i++)
outlet_new((t_object *)x, &s_signal);
x->x_dumpout = outlet_new((t_object *)x, &s_list);
return (x);
}
void matrix_tilde_setup(void)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment