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