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);
......
......@@ -40,19 +40,23 @@ void epluribus_inverse(t_epluribus *x, t_floatarg tog)
void *epluribus_new(t_symbol *msg, int argc, t_atom *argv)
{
t_epluribus *x;
t_epluribus *x;
int i;
x = (t_epluribus *)pd_new(epluribus_class);
x->incount = (int) atom_getfloatarg(0,argc,argv);
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,18 +238,31 @@ 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){
error("%s: there must be at least 1 beat stream",OBJECT_NAME);
return (void *)NULL;
}
if(argc > MAXBEATS + 1)
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);
return (void *)NULL;
error("%s: exceeded maximum of %d beat values",OBJECT_NAME, MAXBEATS);
return (void *)NULL;
}
x = (t_samm *)pd_new(samm_class);
......@@ -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);
......
......@@ -166,16 +166,16 @@ t_int *vdb_perform(t_int *w)
// DSP config
t_vdb *x = (t_vdb *)(w[1]);
int n;
float fdelay;
float insamp; //, insamp2;
float outsamp;
float frac;
t_word *delay_line = x->b_samples;
int phs = x->phs;
long maxdelay_len = x->maxdelay_len;
float feedback = x->feedback;
short *connections = x->connections;
float sr = x->sr;
......@@ -332,62 +332,68 @@ t_int *vdb_perform(t_int *w)
return (w + b_nchans * 2 + 5);
}
}
void *vdb_new(t_symbol *s, int argc, t_atom *argv)
{
int i;
int user_chans;
t_vdb *x = (t_vdb *)pd_new(vdb_class);
x->sr = sys_getsr();
if(argc < 2){
error("%s: you must provide a valid buffer name and channel count",OBJECT_NAME);
void *vdb_new(t_symbol *s, int argc, t_atom *argv)
{
int i;
int user_chans;
t_vdb *x = (t_vdb *)pd_new(vdb_class);
x->sr = sys_getsr();
if(argc < 2){
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");
x->sr = 44100;
}
// DSP CONFIG
// SET DEFAULTS
x->maxdelay = 50.0; // milliseconds
x->feedback = 0.5;
x->delay_time = 0.0;
// args: name channels [max delay, initial delay, feedback, interpolation_flag]
if(!x->sr){
error("zero sampling rate - set to 44100");
x->sr = 44100;
}
// DSP CONFIG
// SET DEFAULTS
x->maxdelay = 50.0; // milliseconds
x->feedback = 0.5;
x->delay_time = 0.0;
// args: name channels [max delay, initial delay, feedback, interpolation_flag]
x->buffername = atom_getsymbolarg(0,argc,argv);
x->buffername = atom_getsymbolarg(0,argc,argv);
user_chans = 1; // in Pd buffers always mono...
x->maxdelay = atom_getfloatarg(1,argc,argv);
x->delay_time = atom_getfloatarg(2,argc,argv);
x->feedback = atom_getfloatarg(3,argc,argv);
x->interpolate = atom_getfloatarg(4,argc,argv);
x->b_nchans = user_chans;
x->redraw_flag = 1;
user_chans = 1; // in Pd buffers always mono...
x->maxdelay = atom_getfloatarg(1,argc,argv);
x->delay_time = atom_getfloatarg(2,argc,argv);
x->feedback = atom_getfloatarg(3,argc,argv);
x->interpolate = atom_getfloatarg(4,argc,argv);
x->b_nchans = user_chans;
x->redraw_flag = 1;
/* need data checking here */
x->inlet_count = x->b_nchans + 2;
x->outlet_count = x->b_nchans;
x->delay_inlet = x->b_nchans;
x->feedback_inlet = x->delay_inlet + 1;
/* need data checking here */
x->inlet_count = x->b_nchans + 2;
x->outlet_count = x->b_nchans;
x->delay_inlet = x->b_nchans;
x->feedback_inlet = x->delay_inlet + 1;
for(i = 0; i < x->inlet_count - 1; i++){
inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
}
outlet_new(&x->x_obj, gensym("signal") );
for(i = 0; i < x->inlet_count - 1; i++){
inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
}
outlet_new(&x->x_obj, gensym("signal") );
vdb_init(x,0);
return (x);
}
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