Commit c9906dbf authored by Jonathan Wilkes's avatar Jonathan Wilkes

allow all classes to instantiate without any arguments

parent 9e77f069
......@@ -1076,9 +1076,9 @@ void *buffet_new(t_symbol *msg, short argc, t_atom *argv)
if(! x->sr )
x->sr = 44100;
if(argc < 1){
error("%s: you must provide a valid buffer name",OBJECT_NAME);
return 0;
if(argc <= 1 || argv[0].a_type != A_SYMBOL) {
post("%s: warning: no array name provided: defaulting to empty symbol",
OBJECT_NAME);
}
atom_arg_getsym(&x->wavename,0,argc,argv);
atom_arg_getfloat(&x->minframes,1,argc,argv);
......
......@@ -44,15 +44,19 @@ void *epluribus_new(t_symbol *msg, int argc, t_atom *argv)
int i;
x = (t_epluribus *)pd_new(epluribus_class);
x->incount = (int) atom_getfloatarg(0,argc,argv);
if(x->incount < 2 || x->incount > 256 ){
int defcount = x->incount < 2 ? 2 : 256;
post("%s: warning: there must be between 2 and 256 input vectors",
OBJECT_NAME);
post("defaulting to %d", defcount);
x->incount = defcount;
}
for(i = 0; i < x->incount - 1; i++){
inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("signal"),gensym("signal"));
}
outlet_new(&x->x_obj, gensym("signal"));
outlet_new(&x->x_obj, gensym("signal"));
if(x->incount < 2 || x->incount > 256 ){
error("%s: there must be between 2 and 256 input vectors", OBJECT_NAME);
return (NULL);
}
x->inverse = 0; // by default don't do inverse behaviour
return (x);
}
......
......@@ -127,12 +127,12 @@ void *player_new(t_symbol *msg, short argc, t_atom *argv)
t_player *x = (t_player *)pd_new(player_class);
inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
outlet_new(&x->x_obj, gensym("signal") );
if(argc < 1 || argv[0].a_type != A_SYMBOL){
post("%s: warning: no buffer name given: defaulting to "
"empty symbol",OBJECT_NAME);
}
x->wavename = atom_getsymbolarg(0,argc,argv);
x->b_nchans = 1;
if(argc < 1){
error("%s: must specify buffer name",OBJECT_NAME);
return 0;
}
x->overlap_max = atom_getfloatarg(2,argc,argv);
if(x->overlap_max <= 0 || x->overlap_max > 128){
x->overlap_max = DEFAULT_MAX_OVERLAP;
......
......@@ -238,14 +238,27 @@ void samm_tempo(t_samm *x, t_floatarg f)
void *samm_new(t_symbol *msg, short argc, t_atom *argv)
{
int i,j;
int i,j, default_tempo = 120;
double divisor;
t_samm *x;
t_atom sane_defaults[2];
if(argc < 2){
// If no args, set some sane defaults
if (!argc){
post("%s: warning: no tempo or beat streams provided: setting "
"tempo to 120 BPM and 1 stream to '1'");
SETFLOAT(sane_defaults, default_tempo);
SETFLOAT(sane_defaults+1, 1.);
argc = 2;
argv = sane_defaults;
}
else
{
error("%s: there must be at least 1 beat stream",OBJECT_NAME);
return (void *)NULL;
}
}
if(argc > MAXBEATS + 1)
{
error("%s: exceeded maximum of %d beat values",OBJECT_NAME, MAXBEATS);
......@@ -277,8 +290,8 @@ void *samm_new(t_symbol *msg, short argc, t_atom *argv)
}
if( x->tempo <= 0.0 ){
x->tempo = 120;
post("tempo autoset to 120 BPM");
x->tempo = default_tempo;
post("tempo autoset to %d BPM", default_tempo);
}
x->onebeat_samps = (60.0/x->tempo) * x->sr;
......
......@@ -44,9 +44,13 @@ void *shoehorn_new(t_symbol *s, int argc, t_atom *argv)
t_shoehorn *x = (t_shoehorn *)pd_new(shoehorn_class);
x->inChans = (long) atom_getfloatarg(0,argc,argv);
x->outChans = (long) atom_getfloatarg(1,argc,argv);
if( x->outChans < 2 || x->inChans < 2){
error("%s: illegal channel count: [in = %d] [out = %d]",OBJECT_NAME,x->inChans,x->outChans);
return NULL;
if(x->inChans < 2){
post("%s: warning: defaulting to 2 in channels", OBJECT_NAME);
x->inChans = 2;
}
if(x->outChans < 2){
post("%s: warning: defaulting to 2 out channels", OBJECT_NAME);
x->outChans = 2;
}
for(i = 0; i < x->inChans - 1; i++){
inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("signal"),gensym("signal"));
......
......@@ -149,9 +149,9 @@ void stutter_setarray(t_stutter *x)
x->theBuffer = b;
garray_usedindsp(b);
}
if(! x->b_valid ){
post("stutter~ got invalid buffer");
}
//if(! x->b_valid ){
// post("stutter~ got invalid buffer");
//}
}
t_int *stutter_perform(t_int *w)
......@@ -397,8 +397,8 @@ void *stutter_new(t_symbol *msg, short argc, t_atom *argv)
srand(time(0));
if(argc<1){
error("stutter~ requires a buffer name");
return NULL;
post("stutter~: warning: no array name given (defaulting to "
"empty symbol)");
}
x->bufchans = 1;
x->bufname = atom_getsymbolarg(0,argc,argv);
......
......@@ -332,11 +332,10 @@ t_int *vdb_perform(t_int *w)
return (w + b_nchans * 2 + 5);
}
void *vdb_new(t_symbol *s, int argc, t_atom *argv)
{
}
void *vdb_new(t_symbol *s, int argc, t_atom *argv)
{
int i;
int user_chans;
......@@ -344,9 +343,16 @@ t_int *vdb_perform(t_int *w)
x->sr = sys_getsr();
if(argc < 2){
error("%s: you must provide a valid buffer name and channel count",OBJECT_NAME);
if (!argc)
{
post("%s: warning: no array name given: defaulting to empty symbol",
OBJECT_NAME);
} else {
error("%s: you must provide a valid buffer name and channel count",
OBJECT_NAME);
return (void *)NULL;
}
}
if(!x->sr){
error("zero sampling rate - set to 44100");
......@@ -387,7 +393,7 @@ t_int *vdb_perform(t_int *w)
vdb_init(x,0);
return (x);
}
}
void vdb_free(t_vdb *x)
{
......
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