Example #1
0
static void *urn_new(t_symbol *s, int argc, t_atom *argv)
{
  t_urn *x = (t_urn *)pd_new(urn_class);
  t_float f=0.;
  ZEXY_USEVAR(s);

  inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym(""));
  x->x_floatout=outlet_new(&x->x_obj, gensym("float"));
  x->x_bangout =outlet_new(&x->x_obj, gensym("bang"));

  x->x_seed = makeseed();
  x->x_noauto = 0;

  while(argc--){
    if (argv->a_type==A_SYMBOL) {
      if (atom_getsymbol(argv)==gensym("no_auto")) {
	x->x_noauto=1;
      }
    } else f = atom_getfloat(argv);
    argv++;
  }

  if (f<1.0)f=1.0;
  makestate(x, f);
  x->x_range = f;
  urn_clear(x);

  return (x);
}
Example #2
0
File: index.c Project: Tzero2/pd
static void *index_new(t_symbol *s, int argc, t_atom *argv)
{
  t_index *x = (t_index *)pd_new(index_class);
  t_symbol** buf;

  int maxentries = 0, automod=0;

  ZEXY_USEVAR(s);

  if (argc--) {
    maxentries = (int)atom_getfloat(argv++);
    if (argc) automod = (int)atom_getfloat(argv++);
  }

  if (maxentries<1) maxentries=128;

  buf = (t_symbol **)getbytes(sizeof(t_symbol *) * maxentries);


  x->entries = 0;
  x->maxentries = maxentries;
  x->names = buf;
  x->auto_mode = !(!automod);
  x->auto_resize = 1;

  while (maxentries--) buf[maxentries]=0;

  outlet_new(&x->x_obj, &s_float);

  return (x);
}
Example #3
0
File: date.c Project: Tzero2/pd
static void help_date(t_date *x)
{
  ZEXY_USEVAR(x);
  post("\n%c date\t\t:: get the current system date", HEARTSYMBOL);
  post("\noutputs are\t: year / month / day / day of week /day of year / daylightsaving (1/0)");
  post("\ncreation\t::'date [GMT]': show local date or GMT");
}
Example #4
0
static void *relay_new(t_symbol *s, int argc, t_atom *argv)
{
    int n;
    t_relayelement *e;
    t_relay *x = (t_relay *)pd_new(relay_class);
    t_atom a;
    ZEXY_USEVAR(s);
    if (argc == 0)
    {
        argc = 1;
        SETFLOAT(&a, 0);
        argv = &a;
    }
    x->x_type = argv[0].a_type;
    x->x_nelement = argc;
    x->x_vec = (t_relayelement *)getbytes(argc * sizeof(*x->x_vec));
    for (n = 0, e = x->x_vec; n < argc; n++, e++)
    {
        e->e_outlet = outlet_new(&x->x_obj, &s_list);
        if (x->x_type == A_FLOAT)
            e->e_w.w_float = atom_getfloatarg(n, argc, argv);
        else e->e_w.w_symbol = atom_getsymbolarg(n, argc, argv);
    }
    x->x_rejectout = outlet_new(&x->x_obj, &s_list);
    return (x);
}
Example #5
0
File: index.c Project: Tzero2/pd
/* delete a symbol from the map (if it is in there) */
static void index_delete(t_index *x, t_symbol *s, int argc, t_atom*argv)
{
  int idx=-1;
  ZEXY_USEVAR(s);
  if(argc!=1){
    error("index :: delete what ?");
    return;
  } else {
    if(argv->a_type==A_FLOAT){
      idx=atom_getint(argv)-1;
    } else if (argv->a_type==A_SYMBOL){
      idx=find_item(atom_getsymbol(argv),x->names, x->maxentries);
    } else {
      error("index :: delete what ?");
      return;    
    }
  }

  if ( idx >= 0 && idx < x->maxentries) {
    x->names[idx]=0;
    x->entries--;
    outlet_float(x->x_obj.ob_outlet, 0.0);
  } else {
    z_verbose(1, "index :: couldn't find element");
    outlet_float(x->x_obj.ob_outlet, -1.0);
  }
}
Example #6
0
static void mavg_set(t_mavg *x, t_symbol *s, int argc, t_atom *argv)
{
  int i = x->size;
  t_float *dummy = x->buf;
  t_float f=(argc)?atom_getfloat(argv):x->avg;
  ZEXY_USEVAR(s);

  while (i--) *dummy++=f;

  x->wp = x->buf;
}
Example #7
0
static void *repeat_new(t_symbol*s, int argc, t_atom*argv)
{
  t_repeat *x = (t_repeat *)pd_new(repeat_class);
  ZEXY_USEVAR(s);
  if(argc){
    if(A_FLOAT==argv->a_type)
      x->fcount = atom_getfloat(argv);
    else return 0;
  } else x->fcount=2;
  floatinlet_new(&x->x_obj, &x->fcount);
  outlet_new(&x->x_obj, 0);
  return (x);
}
Example #8
0
static void lifop_list(t_lifop *x, t_symbol *s, int argc, t_atom *argv)
{
  t_lifop_prioritylist*plifo=0;
  ZEXY_USEVAR(s);
  if(!(plifo=lifop_genprioritylist(x, x->priority))) {
    error("[lifop]: couldn't get priority lifo");
    return;
  }
  if(!add2lifo(plifo, argc, argv)) 
    { 
      x->counter++;
    }

}
Example #9
0
static void *symbol2list_new(t_symbol *s, int argc, t_atom *argv)
{
  t_symbol2list *x = (t_symbol2list *)pd_new(symbol2list_class);
  ZEXY_USEVAR(s);

  outlet_new(&x->x_obj, 0);
  inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("symbol"), gensym(""));

  x->argc=0;
  x->argnum=16;
  x->argv=getbytes(x->argnum*sizeof(t_atom));
  symbol2list_delimiter(x, (argc)?atom_getsymbol(argv):gensym(" "));
  
  return (x);
}
Example #10
0
static void *listfind_new(t_symbol *s, int argc, t_atom *argv)
{
  t_listfind *x = (t_listfind *)pd_new(listfind_class);
  ZEXY_USEVAR(s);

  outlet_new(&x->x_obj, 0);
  x->x_listin=inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("list"), gensym("lst2"));

  x->x_argc=0;
  x->x_argv=0;

  listfind_list2(x, gensym("list"), argc, argv);

  return (x);
}
Example #11
0
static void tabminmax_list(t_tabminmax *x, t_symbol*s,int argc, t_atom*argv)
{
  int a,b;
  ZEXY_USEVAR(s);
  switch(argc){
  case 2:
    a=atom_getint(argv);
    b=atom_getint(argv+1);
    x->startindex=(a<b)?a:b;
    x->stopindex =(a>b)?a:b;
    tabminmax_bang(x);
    break;
  default:
    error("tabminmax: list must be 2 floats (is %d atoms)", argc);
  }
}
Example #12
0
static void wrap_set(t_wrap *x, t_symbol *s, int argc, t_atom *argv){
  t_float f1, f2;
  ZEXY_USEVAR(s);
  switch (argc){
  case 0:
    f1=0.0;
    f2=1.0;
    break;
  case 1:
    f1=0.0;
    f2 = atom_getfloat(argv);
    break;
  default:
    f1 = atom_getfloat(argv);
    f2 = atom_getfloat(argv+1);
  }
  x->f_lower=(f1<f2)?f1:f2;
  x->f_upper=(f1>f2)?f1:f2;
}
Example #13
0
static void minmax_list(t_minmax *x, t_symbol *s, int argc, t_atom *argv)
{
  ZEXY_USEVAR(s);
  if(argc){
    t_float min = atom_getfloat(argv++);
    t_float max=min;
    argc--;
    
    while(argc--){
      t_float f = atom_getfloat(argv++);
      if (f<min)min=f;
      else if (f>max)max=f;
    }
    
    x->min=min;
    x->max=max;
  }
  minmax_bang(x);
}
Example #14
0
File: date.c Project: Tzero2/pd
static void *date_new(t_symbol *s, int argc, t_atom *argv)
{
  t_date *x = (t_date *)pd_new(date_class);
  char buf[5];
  ZEXY_USEVAR(s);
 
  x->GMT=0;
  if (argc) {
    atom_string(argv, buf, 5);
    if (buf[0]=='G' && buf[1]=='M' && buf[2]=='T')
      x->GMT = 1;
  }
  
  x->x_outlet1 = outlet_new(&x->x_obj, &s_float);
  x->x_outlet2 = outlet_new(&x->x_obj, &s_float);
  x->x_outlet3 = outlet_new(&x->x_obj, &s_float);
  x->x_outlet4 = outlet_new(&x->x_obj, &s_float);
  x->x_outlet5 = outlet_new(&x->x_obj, &s_float);
  x->x_outlet6 = outlet_new(&x->x_obj, &s_float);
  
  return (x);
}
Example #15
0
static void atoi_list(t_atoi *x, t_symbol *s, int argc, t_atom *argv)
{
    int base=10;
    const char* c;
    ZEXY_USEVAR(s);

    if (argv->a_type==A_FLOAT) {
        x->i=atom_getfloat(argv);
        outlet_float(x->x_obj.ob_outlet, (t_float)x->i);
        return;
    }

    if (argc>1) {
        base=atom_getfloat(argv+1);
        if (base<2) {
            error("atoi: setting base to 10");
            base=10;
        }
    }
    c=atom_getsymbol(argv)->s_name;
    x->i=strtol(c, 0, base);
    outlet_float(x->x_obj.ob_outlet, (t_float)x->i);
}
Example #16
0
static void repack_list(t_repack *x, t_symbol *s, int argc, t_atom *argv)
{
  int remain = x->outputsize - x->current;
  t_atom *ap = argv;
  ZEXY_USEVAR(s);

  if (argc >= remain) {
    memcpy(x->buffer+x->current, ap, remain * sizeof(t_atom));
    ap   += remain;
    argc -= remain;
    outlet_list(x->x_obj.ob_outlet, gensym("list"), x->outputsize, x->buffer);
    x->current = 0;
  }

  while (argc >= x->outputsize) {
    outlet_list(x->x_obj.ob_outlet, gensym("list"), x->outputsize, ap);
    ap += x->outputsize;
    argc -= x->outputsize;
  }

  memcpy(x->buffer + x->current, ap, argc * sizeof(t_atom));
  x->current += argc;
}