Ejemplo n.º 1
0
static void *netsend_new(t_symbol *s, int argc, t_atom *argv)
{
    t_netsend *x = (t_netsend *)pd_new(netsend_class);
    outlet_new(&x->x_obj, &s_float);
    x->x_protocol = SOCK_STREAM;
    x->x_bin = 0;
    if (argc && argv->a_type == A_FLOAT)
    {
        x->x_protocol = (argv->a_w.w_float != 0 ? SOCK_DGRAM : SOCK_STREAM);
        argc = 0;
    }
    else while (argc && argv->a_type == A_SYMBOL &&
        *argv->a_w.w_symbol->s_name == '-')
    {
        if (!strcmp(argv->a_w.w_symbol->s_name, "-b"))
            x->x_bin = 1;
        else if (!strcmp(argv->a_w.w_symbol->s_name, "-u"))
            x->x_protocol = SOCK_DGRAM;
        else
        {
            pd_error(x, "netsend: unknown flag ...");
            postatom(argc, argv); endpost();
        }
        argc--; argv++;
    }
    if (argc)
    {
        pd_error(x, "netsend: extra arguments ignored:");
        postatom(argc, argv); endpost();
    }
    x->x_sockfd = -1;
    if (x->x_protocol == SOCK_STREAM)
        x->x_msgout = outlet_new(&x->x_obj, &s_anything);
    return (x);
}
Ejemplo n.º 2
0
static int list_equals(int count, t_atom*a1, t_atom*a2)
{
  int i=0;
  DEBUGFUN(post("list(%d) equals?", count));
  DEBUGFUN(postatom(count, a1));
  DEBUGFUN(endpost());
  DEBUGFUN(postatom(count, a2));
  DEBUGFUN(endpost());
  DEBUGFUN(endpost());

  for(i=0; i<count; i++, a1++, a2++) {
    if(a1->a_type!=a2->a_type) {
      DEBUGFUN(post("atomtypes do not match!"));
      return 0;
    }
    if(A_FLOAT==a1->a_type) {
      if(atom_getfloat(a1)!=atom_getfloat(a2)) {
        return 0;
      }
    } else if(a1->a_w.w_symbol!=a2->a_w.w_symbol) { /* is it that simple? */
      DEBUGFUN(post("atom values do not match: %x != %x",
                    a1->a_w.w_symbol,
                    a2->a_w.w_symbol
                   ));
      return 0;
    }
  }
  DEBUGFUN(post("lists match"));
  return 1;
}
Ejemplo n.º 3
0
static void *netreceive_new(t_symbol *s, int argc, t_atom *argv)
{
    t_netreceive *x = (t_netreceive *)pd_new(netreceive_class);
    int portno = 0;
    x->x_ns.x_protocol = SOCK_STREAM;
    x->x_old = 0;
    x->x_ns.x_bin = 0;
    x->x_nconnections = 0;
    x->x_connections = (int *)t_getbytes(0);
    x->x_ns.x_sockfd = -1;
    if (argc && argv->a_type == A_FLOAT)
    {
        portno = atom_getfloatarg(0, argc, argv);
        x->x_ns.x_protocol = (atom_getfloatarg(1, argc, argv) != 0 ?
            SOCK_DGRAM : SOCK_STREAM);
        x->x_old = (!strcmp(atom_getsymbolarg(2, argc, argv)->s_name, "old"));
        argc = 0;
    }
    else 
    {
        while (argc && argv->a_type == A_SYMBOL &&
            *argv->a_w.w_symbol->s_name == '-')
        {
            if (!strcmp(argv->a_w.w_symbol->s_name, "-b"))
                x->x_ns.x_bin = 1;
            else if (!strcmp(argv->a_w.w_symbol->s_name, "-u"))
                x->x_ns.x_protocol = SOCK_DGRAM;
            else
            {
                pd_error(x, "netreceive: unknown flag ...");
                postatom(argc, argv); endpost();
            }
            argc--; argv++;
        }
    }
    if (argc && argv->a_type == A_FLOAT)
        portno = argv->a_w.w_float, argc--, argv++;
    if (argc)
    {
        pd_error(x, "netreceive: extra arguments ignored:");
        postatom(argc, argv); endpost();
    }
    if (x->x_old)
    {
        /* old style, nonsecure version */
        x->x_ns.x_msgout = 0;
    }
    else x->x_ns.x_msgout = outlet_new(&x->x_ns.x_obj, &s_anything);
        /* create a socket */
    if (portno > 0)
        netreceive_listen(x, portno);

    return (x);
}
Ejemplo n.º 4
0
static void canvas_readerror(int natoms, t_atom *vec, int message,
    int nline, char *s)
{
    error("%s", s);
    startpost("line was:");
    postatom(nline, vec + message);
    endpost();
}
Ejemplo n.º 5
0
static void pddplink_anything(t_pddplink *x, t_symbol *s, int ac, t_atom *av)
{
    if (x->x_ishit)
    {
	startpost("pddplink: internal error (%s", (s ? s->s_name : ""));
	postatom(ac, av);
	post(")");
    }
}
Ejemplo n.º 6
0
static void canvas_readerror(int natoms, t_atom *vec, int message,
                             int nline, char *s)
{
#ifdef ROCKBOX
    (void) natoms;
#endif
    error(s);
    startpost("line was:");
    postatom(nline, vec + message);
    endpost();
}
Ejemplo n.º 7
0
static void hammergui_anything(t_hammergui *snk,
			       t_symbol *s, int ac, t_atom *av)
{
    /* Dummy method, filtering out messages from gui to the masters.  This is
       needed in order to keep Pd's message system happy in a ``gray period''
       -- after last master is unbound, and before gui bindings are cleared. */
#ifdef HAMMERGUI_DEBUG
    /* FIXME */
    startpost("%s", s->s_name);
    postatom(ac, av);
    post(" (sink %x)", (int)snk);
#endif
}
Ejemplo n.º 8
0
static void mtx_print(t_mtxprint *x, t_symbol *s, int argc, t_atom *argv)
{
  int col, row;
  if(iemmatrix_check(x, argc, argv, 0))return;
  row = atom_getfloat(argv++);
  col = atom_getfloat(argv++);
  post("%s:", x->x_s->s_name);
  while(row--) {
    postatom(col, argv);
    argv+=col;
    endpost();
  }
  endpost();
}
Ejemplo n.º 9
0
static void audiosettings_setparams(t_audiosettings *x, t_symbol*s, int argc, t_atom*argv) {
/*
  PLAN:
    several messages that accumulate to a certain settings, and then "apply" them
*/
  int apply=1;
  int advance=0;
  t_paramtype param=PARAM_INVALID;

  audiosettings_params_init (x); /* re-initialize to what we got */

  advance=audiosettings_setparams_next(argc, argv);
  while((argc-=advance)>0) {
    argv+=advance;
    s=atom_getsymbol(argv);
    param=audiosettings_setparams_id(s);

    argv++;
    argc--;

    switch(param) {
    case PARAM_RATE:
      advance=audiosettings_setparams_rate(x, argc, argv);
      break;
    case PARAM_ADVANCE:
      advance=audiosettings_setparams_advance(x, argc, argv);
      break;
    case PARAM_CALLBACK:
      advance=audiosettings_setparams_callback(x, argc, argv);
      break;
    case PARAM_INPUT:
      advance=audiosettings_setparams_input(x, argc, argv);
      break;
    case PARAM_OUTPUT:
      advance=audiosettings_setparams_output(x, argc, argv);
      break;
    default:
      pd_error(x, "unknown parameter"); postatom(1, argv);endpost();
      break;
    }

    argc-=advance;
    argv+=advance;
    advance=audiosettings_setparams_next(argc, argv);
  }
  if(apply) {
    audiosettings_params_apply(x);
  }
}
Ejemplo n.º 10
0
void binbuf_print(t_binbuf *x)
{
    int i, startedpost = 0, newline = 1;
    for (i = 0; i < x->b_n; i++)
    {
    	if (newline)
	{
	    if (startedpost) endpost();
	    startpost("");
	    startedpost = 1;
    	}
	postatom(1, x->b_vec + i);
	if (x->b_vec[i].a_type == A_SEMI)
	    newline = 1;
	else newline = 0; 
    }
    if (startedpost) endpost();
}
Ejemplo n.º 11
0
void binbuf_add(t_binbuf *x, int argc, t_atom *argv)
{
    int newsize = x->b_n + argc, i;
    t_atom *ap;
    if((ap = t_resizebytes(x->b_vec, x->b_n * sizeof(*x->b_vec),
	newsize * sizeof(*x->b_vec))))
	    x->b_vec = ap;
    else
    {
    	error("binbuf_addmessage: out of space");
    	return;
    }
#if 0
    startpost("binbuf_add: ");
    postatom(argc, argv);
    endpost();
#endif
    for (ap = x->b_vec + x->b_n, i = argc; i--; ap++)
    	*ap = *(argv++);
    x->b_n = newsize;
}
Ejemplo n.º 12
0
static void mtx_print(t_mtxprint *x, t_symbol *s, int argc, t_atom *argv)
{
  int col, row;
  if (argc<2){
    post("mtx_print : crippled matrix");
    return;
  }
  row = atom_getfloat(argv++);
  col = atom_getfloat(argv++);
  if(row*col>argc-2){
    post("mtx_print : sparse matrices not yet supported : use \"mtx_check\"");
    return;
  }
  post("%s:", x->x_s->s_name);
  while(row--){
    postatom(col, argv);
    argv+=col;
    endpost();
  }
  endpost();
}
Ejemplo n.º 13
0
Archivo: mfbb.c Proyecto: pure-data/xeq
/* LATER analyse various cases of mixed (midi/nonmidi) binbufs and try to
   find a better way of adjusting time in such cases */
static int mfbb_parse(t_binbuf *x, t_mifi_stream *stp, t_squtt *tt,
		      t_mfbb_parsinghook hook)
{
    t_mifi_event *evp = stp->s_auxeve;
    t_mfbb_parsinghook thehook = (hook ? hook : mfbb_analyse_hook);
    int natoms = x->b_n;
    t_atom *ap= x->b_vec;
    uint32 thisticks = 0, pastticks = 0;
    int track, hookresult;
    t_symbol *tname = 0;

    if (!hook)
    {
	/* LATER make sure we are called after mifi_stream_new()
	   or after reinitialization */
    }
    while (natoms >= MFBB_PARTICLE_SIZE)
    {
	t_atom *ap1 = ap;
	t_float f, delaytime = 0;
	if (ap1->a_type != A_FLOAT || (delaytime = ap1->a_w.w_float) < 0)
	    goto nextmessage;
	ap1++;
#if 1  /* assume folded time */
	thisticks += (uint32)(delaytime * stp->s_timecoef);
#else  /* but keep unfolded version ready */
	thisticks = (uint32)(delaytime * stp->s_timecoef);
#endif
	if (!(track = squtt_checkatom(tt, ap1)))
	    goto nextmessage;
	tname = ap1->a_w.w_symbol;
	ap1++;
	if (mfbb_parse_status(ap1, evp)) ap1++;
	else goto nextmessage;
	if (mfbb_parse_data(ap1, evp, 0)) ap1++;
	else goto nextmessage;
	if (MIFI_ONE_DATABYTE(evp->e_status))
	{
	    if (mfbb_parse_channel(ap1, evp)) ap1++;
	    else goto nextmessage;
	    evp->e_data[1] = 0, ap1++;  /* accept this being just anything... */
	}
	else {
	    if (mfbb_parse_data(ap1, evp, 1)) ap1++;
	    else goto nextmessage;
	    if (mfbb_parse_channel(ap1, evp)) ap1++;
	    else goto nextmessage;
	}
	if (ap1->a_type != A_SEMI)  /* ...but this is required */
	    goto nextmessage;

	evp->e_delay = thisticks - pastticks;
	if (!(hookresult = thehook(stp, evp, track, tname)))
	    return (0);
	if (hookresult > 0) pastticks = thisticks;

	natoms -= MFBB_PARTICLE_SIZE;
	ap += MFBB_PARTICLE_SIZE;
	continue;

    nextmessage:
#ifdef MFBB_DEBUG
	if (!hook)
	{  /* print this only once, i.e. during a default (analysis) pass */
	    startpost("skip"); postatom(1, ap);
	    poststring("with"); postatom(6, ap+1);
	    poststring("bad"); postatom(1, ap1);
	    endpost();
	}
#endif
	while (natoms-- > MFBB_PARTICLE_SIZE && (ap++)->a_type != A_SEMI);
    }
    return (1);
}
Ejemplo n.º 14
0
static void *array_define_new(t_symbol *s, int argc, t_atom *argv)
{
    t_symbol *arrayname = &s_;
    float arraysize = 100;
    t_glist *x;
    int keep = 0;
    float ylo = -1, yhi = 1;
    float xpix = 500, ypix = 300;
    while (argc && argv->a_type == A_SYMBOL &&
        *argv->a_w.w_symbol->s_name == '-')
    {
        if (!strcmp(argv->a_w.w_symbol->s_name, "-k"))
            keep = 1;
        else if (!strcmp(argv->a_w.w_symbol->s_name, "-yrange") &&
            argc >= 3 && argv[1].a_type == A_FLOAT &&
                argv[2].a_type == A_FLOAT)
        {
            ylo = atom_getfloatarg(1, argc, argv);
            yhi = atom_getfloatarg(2, argc, argv);
            if (ylo == yhi)
                ylo = -1, yhi = 1;
            argc -= 2; argv += 2;
        }
        else if (!strcmp(argv->a_w.w_symbol->s_name, "-pix") &&
            argc >= 3 && argv[1].a_type == A_FLOAT &&
                argv[2].a_type == A_FLOAT)
        {
            if ((xpix = atom_getfloatarg(1, argc, argv)) < 10)
                xpix = 10;
            if ((ypix = atom_getfloatarg(2, argc, argv)) < 10)
                ypix = 10;
            argc -= 2; argv += 2;
        }
        else
        {
            error("array define: unknown flag ...");
            postatom(argc, argv); endpost();
        }
        argc--; argv++;
    }
    if (argc && argv->a_type == A_SYMBOL)
    {
        arrayname = argv->a_w.w_symbol;
        argc--; argv++;
    }
    if (argc && argv->a_type == A_FLOAT)
    {
        arraysize = argv->a_w.w_float;
        argc--; argv++;
    }
    if (argc)
    {
        post("warning: array define ignoring extra argument: ");
        postatom(argc, argv); endpost();
    }
    x = (t_glist *)table_donew(arrayname, arraysize, keep, xpix, ypix);

        /* bash the class to "array define".  We don't do this earlier in
        part so that canvas_getcurrent() will work while the glist and
        garray are being created.  There may be other, unknown side effects. */
    x->gl_obj.ob_pd = array_define_class;
    array_define_yrange(x, ylo, yhi);
    outlet_new(&x->gl_obj, &s_pointer);
    return (x);
}