Esempio n. 1
0
/*------------------------------------ map2dCreate ---*/
static void *
map2dCreate(t_symbol * initialFile)
{
    Map2dData * xx = static_cast<Map2dData *>(object_alloc(gClass));
    
    if (xx)
    {
        xx->fVerbose = false;
        xx->fResultOut = static_cast<t_outlet *>(outlet_new(xx, NULL));
        xx->fFirstRange = xx->fLastRange = xx->fPreviousResult = NULL;
        setFOI2Integer(xx->fPreviousInput[0], 0);
        setFOI2Integer(xx->fPreviousInput[1], 0);
        xx->fRangeCount = 0;
        xx->fBuffer = static_cast<t_binbuf *>(binbuf_new());
        if (! (xx->fResultOut && xx->fBuffer))
        {
            LOG_ERROR_1(xx, OUTPUT_PREFIX "unable to create port for object")
            freeobject(reinterpret_cast<t_object *>(xx));
            xx = NULL;
        }
        else if (initialFile == gEmptySymbol)
        {
            LOG_POST_1(xx, OUTPUT_PREFIX "no initial map file")
        }
        else
        {
            LOG_POST_2(xx, OUTPUT_PREFIX "initial file: %s", initialFile->s_name)
            map2dLoadRangeList(xx, initialFile);
        }
    }
    return xx;
} // map2dCreate
Esempio n. 2
0
/*--------------------------------------------------------------------
 * new
 */
static void *any2bytes_new(MOO_UNUSED t_symbol *sel, int argc, t_atom *argv)
{
    t_any2bytes *x = (t_any2bytes *)pd_new(any2bytes_class);
    int bufsize = ANY2BYTES_DEFAULT_BUFLEN;

    //-- defaults
    x->x_eos      = 0;

    //-- args: 0: bufsize
    if (argc > 0) {
      int initial_bufsize = atom_getintarg(0, argc, argv);
      if (initial_bufsize > 0) { bufsize = initial_bufsize; }
    }
    //-- args: 1: eos
    if (argc > 1) {
      x->x_eos = atom_getfloatarg(1, argc, argv);
    }

    //-- allocate
    pdstring_bytes_init(&x->x_bytes, 0); //-- x_bytes gets clobbered by binbuf_gettext()
    pdstring_atoms_init(&x->x_atoms, bufsize);
    x->x_binbuf = binbuf_new();

    //-- inlets
    x->x_eos_in = floatinlet_new(&x->x_obj, &x->x_eos);

    //-- outlets
    x->x_outlet = outlet_new(&x->x_obj, &s_list);

    //-- report
    A2SDEBUG(post("any2bytes_new(): x=%p, eos=%d, binbuf=%p", x, x->x_eos, x->x_binbuf));

    return (void *)x;
}
Esempio n. 3
0
void glob_initfromgui(void *dummy, t_symbol *s, int argc, t_atom *argv)
{
    char *cwd = atom_getsymbolarg(0, argc, argv)->s_name;
    t_namelist *nl;
    unsigned int i;
    int did_fontwarning = 0;
    int j;
    sys_oldtclversion = atom_getfloatarg(1, argc, argv);
    if (argc != 2 + 3 * NZOOM * NFONT)
        bug("glob_initfromgui");
    for (j = 0; j < NZOOM; j++)
        for (i = 0; i < NFONT; i++)
    {
        int size   = atom_getfloatarg(3 * (i + j * NFONT) + 2, argc, argv);
        int width  = atom_getfloatarg(3 * (i + j * NFONT) + 3, argc, argv);
        int height = atom_getfloatarg(3 * (i + j * NFONT) + 4, argc, argv);
        if (!(size && width && height))
        {
            size   = (j+1)*sys_fontspec[i].fi_pointsize;
            width  = (j+1)*sys_fontspec[i].fi_width;
            height = (j+1)*sys_fontspec[i].fi_height;
            if (!did_fontwarning)
            {
                verbose(1, "ignoring invalid font-metrics from GUI");
                did_fontwarning = 1;
            }
        }
        sys_gotfonts[j][i].fi_pointsize = size;
        sys_gotfonts[j][i].fi_width = width;
        sys_gotfonts[j][i].fi_height = height;
#if 0
            fprintf(stderr, "font (%d %d %d)\n",
                sys_gotfonts[j][i].fi_pointsize, sys_gotfonts[j][i].fi_width,
                    sys_gotfonts[j][i].fi_height);
#endif
    }
        /* load dynamic libraries specified with "-lib" args */
    if (sys_oktoloadfiles(0))
    {
        for  (nl = STUFF->st_externlist; nl; nl = nl->nl_next)
            if (!sys_load_lib(0, nl->nl_string))
                post("%s: can't load library", nl->nl_string);
        sys_oktoloadfiles(1);
    }
        /* open patches specifies with "-open" args */
    for  (nl = sys_openlist; nl; nl = nl->nl_next)
        openit(cwd, nl->nl_string);
    namelist_free(sys_openlist);
    sys_openlist = 0;
        /* send messages specified with "-send" args */
    for  (nl = sys_messagelist; nl; nl = nl->nl_next)
    {
        t_binbuf *b = binbuf_new();
        binbuf_text(b, nl->nl_string, strlen(nl->nl_string));
        binbuf_eval(b, 0, 0, 0);
        binbuf_free(b);
    }
    namelist_free(sys_messagelist);
    sys_messagelist = 0;
}
Esempio n. 4
0
static void fudiformat_any(t_fudiformat *x, t_symbol*s, int argc, t_atom*argv) {
  char *buf;
  int length;
  int i;
  t_atom at;
  t_binbuf*bbuf = binbuf_new();
  SETSYMBOL(&at, s);
  binbuf_add(bbuf, 1, &at);

  binbuf_add(bbuf, argc, argv);

  if(!x->x_udp) {
    SETSEMI(&at);
    binbuf_add(bbuf, 1, &at);
  }
  binbuf_gettext(bbuf, &buf, &length);
  binbuf_free(bbuf);

  if((size_t)length>x->x_numatoms) {
    freebytes(x->x_atoms, sizeof(*x->x_atoms) * x->x_numatoms);
    x->x_numatoms = length;
    x->x_atoms = getbytes(sizeof(*x->x_atoms) * x->x_numatoms);
  }

  for(i=0; i<length; i++) {
    SETFLOAT(x->x_atoms+i, buf[i]);
  }
  freebytes(buf, length);
  outlet_list(x->x_msgout, 0, length, x->x_atoms);
}
Esempio n. 5
0
    /* a series of "data" messages rebuilds a scalar */
static void gfxstub_data(t_gfxstub *x, t_symbol *s, int argc, t_atom *argv)
{
    if (!gfxstub_binbuf)
        gfxstub_binbuf = binbuf_new();
    binbuf_add(gfxstub_binbuf, argc, argv);
    binbuf_addsemi(gfxstub_binbuf);
}
Esempio n. 6
0
void gobj_recreate(t_glist *gl, t_gobj *ob, t_binbuf *bb)
{
    /* LATER revisit all gobj calls, and sort out the gop case */
    t_text *newt;
    int xpix = ((t_text *)ob)->te_xpix, ypix = ((t_text *)ob)->te_ypix;
    t_binbuf *bb1 = binbuf_new();
    int ac = binbuf_getnatom(bb);
    t_atom *av = binbuf_getvec(bb);
    canvas_setcurrent(gl);
    gobj_totail(gl, ob);
    gobj_stowconnections(gl, ob, bb1);
    glist_delete(gl, ob);
    if (newt = (t_text *)forky_newobject(av->a_w.w_symbol, ac - 1, av + 1))
    {
        newt->te_binbuf = bb;
        newt->te_xpix = xpix;
        newt->te_ypix = ypix;
        newt->te_width = 0;
        newt->te_type = T_OBJECT;
        glist_add(gl, (t_gobj *)newt);
        gobj_restoreconnections(gl, bb1);
    }
    else bug("gobj_recreate");
    binbuf_free(bb1);
    canvas_unsetcurrent(gl);
}
Esempio n. 7
0
/*--------------------------------------------------------------------
 * new
 */
static void *bytes2any_new(MOO_UNUSED t_symbol *sel, int argc, t_atom *argv)
{
    t_bytes2any *x = (t_bytes2any *)pd_new(bytes2any_class);
    int bufsize    = BYTES2ANY_DEFAULT_BUFLEN;

    //-- defaults
    x->x_binbuf = binbuf_new();
    x->x_eos    = -1;

    //-- args: 0: bufsize
    if (argc > 0) {
      int initial_bufsize = atom_getintarg(0,argc,argv);
      if (initial_bufsize > 0) bufsize = initial_bufsize;
      x->x_eos = -1;   //-- backwards-compatibility hack: no default eos character if only bufsize is specified
    } 
    //-- args: 1: separator
    if (argc > 1) {
      x->x_eos = atom_getfloatarg(1,argc,argv);
    }

    //-- allocate x_bytes
    pdstring_bytes_init(&x->x_bytes, bufsize);

    //-- inlets
    x->x_eos_in = floatinlet_new(&x->x_obj, &x->x_eos);

    //-- outlets
    x->x_outlet      = outlet_new(&x->x_obj, &s_list);
    x->x_outlet_done = outlet_new(&x->x_obj, &s_bang);

    //-- debug
    S2ADEBUG(post("bytes2any_new: x=%p, binbuf=%p, bytes.alloc=%d", x, x->x_eos, x->x_binbuf, x->x_bytes.b_alloc));

    return (void *)x;
}
Esempio n. 8
0
File: xeq.c Progetto: pure-data/xeq
/* derive a host */
static t_xeq *xeq_derived_hostify(t_hyphen *x, int tablesize,
				  t_symbol *refname, t_method tickmethod)
{
    t_xeq *base = 0;
    t_binbuf *bb = 0;
    int i;
#ifdef XEQ_VERBOSE
    if (!refname || refname == &s_)
	post("hostifying %s without a reference name",
	     class_getname(*(t_pd *)x));
#endif
    if (!hyphen_multiderive(x, xeq_base_class, tablesize))
	return (0);
    base = XEQ_BASE(x);
    x->x_host = (t_hyphen *)base;
    bb = binbuf_new();
    /* initialize first base and attach a reference name to it,
       LATER use <id>-<refname> scheme */
    hyphen_initialize((t_hyphen *)base, xeq_base_class, 0);
    hyphen_attach((t_hyphen *)base, refname);
    for (i = 0; i < XEQ_NBASES(x); i++, base++)
    {
	xeq_newbase(base, bb, tickmethod);
    }
    hyphen_forallfriends((t_hyphen *)XEQ_BASE(x),
			 xeqhook_multicast_setbinbuf, 0);
    return (XEQ_BASE(x));
}
Esempio n. 9
0
void glob_initfromgui(void *dummy, t_symbol *s, int argc, t_atom *argv)
{
    char *cwd = atom_getsymbolarg(0, argc, argv)->s_name;
    t_namelist *nl;
    unsigned int i;
    int j;
    int nhostfont = (argc-2)/3;
    sys_oldtclversion = atom_getfloatarg(1, argc, argv);
    if (argc != 2 + 3 * nhostfont) bug("glob_initfromgui");
    for (i = 0; i < NFONT; i++)
    {
        int best = 0;
        int wantheight = sys_fontlist[i].fi_maxheight;
        int wantwidth = sys_fontlist[i].fi_maxwidth;
        for (j = 1; j < nhostfont; j++)
        {
            if (atom_getintarg(3 * j + 4, argc, argv) <= wantheight &&
                atom_getintarg(3 * j + 3, argc, argv) <= wantwidth)
                    best = j;
        }
            /* best is now the host font index for the desired font index i. */
        sys_fontlist[i].fi_hostfontsize =
            atom_getintarg(3 * best + 2, argc, argv);
        sys_fontlist[i].fi_width = atom_getintarg(3 * best + 3, argc, argv);
        sys_fontlist[i].fi_height = atom_getintarg(3 * best + 4, argc, argv);
    }
#if 0
    for (i = 0; i < 6; i++)
        fprintf(stderr, "font (%d %d %d) -> (%d %d %d)\n",
            sys_fontlist[i].fi_fontsize,
            sys_fontlist[i].fi_maxwidth,
            sys_fontlist[i].fi_maxheight,
            sys_fontlist[i].fi_hostfontsize,
            sys_fontlist[i].fi_width,
            sys_fontlist[i].fi_height);
#endif
        /* auto-load anything in that is in startupdir */
    if(!sys_nostartup)
        sys_loadstartup();
        /* load dynamic libraries specified with "-lib" args */
    for  (nl = sys_externlist; nl; nl = nl->nl_next)
        if (!sys_load_lib(0, nl->nl_string))
            post("%s: can't load library", nl->nl_string);
        /* open patches specifies with "-open" args */
    for  (nl = sys_openlist; nl; nl = nl->nl_next)
        openit(cwd, nl->nl_string);
    namelist_free(sys_openlist);
    sys_openlist = 0;
        /* send messages specified with "-send" args */
    for  (nl = sys_messagelist; nl; nl = nl->nl_next)
    {
        t_binbuf *b = binbuf_new();
        binbuf_text(b, nl->nl_string, strlen(nl->nl_string));
        binbuf_eval(b, 0, 0, 0);
        binbuf_free(b);
    }
    namelist_free(sys_messagelist);
    sys_messagelist = 0;
}
Esempio n. 10
0
/**
 * fetch a message
 */
static void _zmq_receive(t_zmq *x) {

   if ( ! _can_receive(x)) {
      return;
   }

   int r, err;
   char buf[MAXPDSTRING];
   t_binbuf *b;
   int msg;

   r=zmq_recv (x->zmq_socket, buf, MAXPDSTRING, ZMQ_DONTWAIT);
   if(r != -1) {
       if (r > MAXPDSTRING) r = MAXPDSTRING; // brutally cut off excessive bytes
       buf[r - 1] = 0; // terminate string
       if(r > 0) {
          b = binbuf_new();
          binbuf_text(b, buf, r);
          // the following code is cp'ed from x_net.c::netreceive_doit
          int natom = binbuf_getnatom(b);
          t_atom *at = binbuf_getvec(b);
          for (msg = 0; msg < natom;)
          {
              int emsg;
              for (emsg = msg; emsg < natom && at[emsg].a_type != A_COMMA
                      && at[emsg].a_type != A_SEMI; emsg++)
                  ;
              if (emsg > msg)
              {
                  int i;
                  for (i = msg; i < emsg; i++)
                      if (at[i].a_type == A_DOLLAR || at[i].a_type == A_DOLLSYM)
                      {
                          pd_error(x, "zmq_receive: got dollar sign in message");
                          goto nodice;
                      }
                  if (at[msg].a_type == A_FLOAT)
                  {
                      if (emsg > msg + 1)
                          outlet_list(x->s_out, 0, emsg-msg, at + msg);
                      else outlet_float(x->s_out, at[msg].a_w.w_float);
                  }
                  else if (at[msg].a_type == A_SYMBOL)
                      outlet_anything(x->s_out, at[msg].a_w.w_symbol,
                              emsg-msg-1, at + msg + 1);
              }
          nodice:
              msg = emsg + 1;
          }

       } else {
          outlet_bang(x->s_out);
       }
       if((err=zmq_errno())!=EAGAIN) {
          _zmq_error(err);
       }
   }
}
Esempio n. 11
0
t_binbuf* binbuf_via_atoms(int ac, t_atom *av)
{
    t_binbuf* dico = binbuf_new();
    if(dico)
    {
        binbuf_add(dico, ac, av);
    }
    return dico;
}
Esempio n. 12
0
DYN_EXPORT int dyn_NewMessageStr(int sched,dyn_id *oid,dyn_callback cb,dyn_id sid,const char *msg)
{
    t_binbuf *b = binbuf_new();
    binbuf_text(b,(char *)msg,strlen(msg));
    int argc = binbuf_getnatom(b);
    t_atom *argv = binbuf_getvec(b);
    int ret = dyn_NewMessage(sched,oid,cb,sid,argc,argv);
    binbuf_free(b);
    return ret;
}
Esempio n. 13
0
static void hammereditor_clear(t_hammerfile *f)
{
    if (f->f_editorfn)
    {
	if (f->f_binbuf)
	    binbuf_clear(f->f_binbuf);
	else
	    f->f_binbuf = binbuf_new();
    }
}
Esempio n. 14
0
static void netsend_send(t_netsend *x, t_symbol *s, int argc, t_atom *argv)
{
#ifdef ROCKBOX
    (void) x;
    (void) s;
    (void) argc;
    (void) argv;
#else /* ROCKBOX */
    if (x->x_fd >= 0)
    {
	t_binbuf *b = binbuf_new();
	char *buf, *bp;
	int length, sent;
	t_atom at;
	binbuf_add(b, argc, argv);
	SETSEMI(&at);
	binbuf_add(b, 1, &at);
	binbuf_gettext(b, &buf, &length);
	for (bp = buf, sent = 0; sent < length;)
	{
	    static double lastwarntime;
	    static double pleasewarn;
	    double timebefore = sys_getrealtime();
    	    int res = send(x->x_fd, buf, length-sent, 0);
    	    double timeafter = sys_getrealtime();
    	    int late = (timeafter - timebefore > 0.005);
    	    if (late || pleasewarn)
    	    {
    	    	if (timeafter > lastwarntime + 2)
    	    	{
    	    	     post("netsend blocked %d msec",
    	    	     	(int)(1000 * ((timeafter - timebefore) + pleasewarn)));
    	    	     pleasewarn = 0;
    	    	     lastwarntime = timeafter;
    	    	}
    	    	else if (late) pleasewarn += timeafter - timebefore;
    	    }
    	    if (res <= 0)
    	    {
    		sys_sockerror("netsend");
    		netsend_disconnect(x);
    		break;
    	    }
    	    else
    	    {
    		sent += res;
    		bp += res;
    	    }
	}
	t_freebytes(buf, length);
	binbuf_free(b);
    }
    else error("netsend: not connected");
#endif /* ROCKBOX */
}
Esempio n. 15
0
File: xeq.c Progetto: pure-data/xeq
static void *xeq_new(t_symbol *name)
{
    t_xeq *x = (t_xeq *)hyphen_new(xeq_class, 0);
    hyphen_attach((t_hyphen *)x, name);
    xeq_newbase(x, binbuf_new(), (t_method)xeq_tick);
    hyphen_forallfriends((t_hyphen *)x, xeqhook_multicast_setbinbuf, 0);
    outlet_new((t_object *)x, &s_list);
    x->x_midiout = outlet_new((t_object *)x, &s_float);
    x->x_bangout = outlet_new((t_object *)x, &s_bang);
    return (x);
}
Esempio n. 16
0
void ofxPd::sendRawMessage( const string& message )
{
	// senda  message to pd
	t_binbuf *b = binbuf_new();
	static char msg_buf[MAXPDSTRING+1];
	strncpy( msg_buf, message.c_str(), message.size() );
	binbuf_text(b, msg_buf, message.size() );
	sys_lock();
	binbuf_eval(b, 0, 0, 0);
	sys_unlock();
	binbuf_free(b);
}
Esempio n. 17
0
static void netdist_send(t_netdist *x, t_symbol *s, int argc, t_atom *argv)
{
	int i = 0;

	for(i = 0; i <= x->x_numconnect; i++)
	{
		if (x->x_fd[i] >= 0)
		{
			t_binbuf *b = binbuf_new();
			char *buf, *bp;
			int length, sent;
			t_atom at;
			binbuf_add(b, argc, argv);
			SETSEMI(&at);
			binbuf_add(b, 1, &at);
			binbuf_gettext(b, &buf, &length);
			for (bp = buf, sent = 0; sent < length;)
			{
				static double lastwarntime;
				static double pleasewarn;
				double timebefore = clock_getlogicaltime();
    				int res = send(x->x_fd[i], buf, length-sent, 0);
    				double timeafter = clock_getlogicaltime();
    				int late = (timeafter - timebefore > 0.005);
    				if (late || pleasewarn)
    				{
    	    			if (timeafter > lastwarntime + 2)
    	    			{
    	    				 post("netdist blocked %d msec",
    	    	     			(int)(1000 * ((timeafter - timebefore) + pleasewarn)));
    	    				 pleasewarn = 0;
    	    				 lastwarntime = timeafter;
    	    			}
    	    			else if (late) pleasewarn += timeafter - timebefore;
    				}
    				if (res <= 0)
    				{
    					sys_sockerror("netdist");
    					netdist_disconnect(x, gensym(x->x_hostname[i]), x->x_port[i]);
    					break;
    				}
    				else
    				{
    					sent += res;
    					bp += res;
    				}
			}
			t_freebytes(buf, length);
			binbuf_free(b);
		}
	}
	if(x->x_numconnect == -1) error("netdist: not connected");
}
// ------------- SEND ANYTHING
void broadcastsend_message_anything_method(t_broadcastsend *x, t_symbol *s, int argc, t_atom *argv){
   t_binbuf *b = binbuf_new();
   char *buf;
   int length;
   t_atom message;
   SETSYMBOL(&message, s);
   binbuf_add(b, 1, &message); // message name
   binbuf_add(b, argc, argv); // message parameters
   binbuf_gettext(b, &buf, &length);
   int size = sendto(x->socket, buf, length, 0,(struct sockaddr *) &x->their_addr, sizeof(x->their_addr));
   (void) size;
}
Esempio n. 19
0
static void funbuff_dowrite(t_funbuff *x, t_symbol *fn)
{
    t_binbuf *bb = binbuf_new();
    char buf[MAXPDSTRING];
    t_hammernode *np;
    binbuf_addv(bb, "s", atom_getsymbol(binbuf_getvec(x->x_ob.te_binbuf)));
    for (np = x->x_tree.t_first; np; np = np->n_next)
        binbuf_addv(bb, "if", np->n_key, HAMMERNODE_GETFLOAT(np));
    canvas_makefilename(x->x_canvas, fn->s_name, buf, MAXPDSTRING);
    binbuf_write(bb, buf, "", 0);
    binbuf_free(bb);
}
Esempio n. 20
0
void breakpoints_function(t_breakpoints *x, t_symbol* s, int argc, t_atom* argv)
{
    t_binbuf* b = binbuf_new();

    if(argc && argv)
    {
        binbuf_addv(b, "s", gensym("@points"));
        binbuf_add(b, argc, argv);
        breakpoints_init(x, b);
        binbuf_free(b);

    }
}
Esempio n. 21
0
void popen_setup(void )
{
	inbinbuf = binbuf_new();
    popen_class = class_new(gensym("popen"), (t_newmethod)popen_new,
    (t_method)popen_close,sizeof(t_popen), 0, A_GIMME, 0);
    class_addmethod(popen_class, (t_method)popen_close,
    	gensym("close"), 0);
    class_addmethod(popen_class, (t_method)popen_open,
    	gensym("open"), A_GIMME, 0);
    class_addmethod(popen_class, (t_method)popen_ropen,
    	gensym("ropen"), A_GIMME, 0);
    class_addlist(popen_class, popen_list);

}
Esempio n. 22
0
void binbuf_addbinbuf(t_binbuf *x, t_binbuf *y)
{
    t_binbuf *z = binbuf_new();
    int i;
    t_atom *ap;
    binbuf_add(z, y->b_n, y->b_vec);
    for (i = 0, ap = z->b_vec; i < z->b_n; i++, ap++)
    {
    	char tbuf[MAXPDSTRING];
    	switch (ap->a_type)
    	{
    	case A_FLOAT:
    	    break;
    	case A_SEMI:
    	    SETSYMBOL(ap, gensym(";"));
    	    break;
    	case A_COMMA:
    	    SETSYMBOL(ap, gensym(","));
    	    break;
    	case A_DOLLAR:
#ifdef ROCKBOX
            snprintf(tbuf, sizeof(tbuf), "$%d", ap->a_w.w_index);
#else /* ROCKBOX */
    	    sprintf(tbuf, "$%d", ap->a_w.w_index);
#endif /* ROCKBOX */
    	    SETSYMBOL(ap, gensym(tbuf));
    	    break;
    	case A_DOLLSYM:
#ifdef ROCKBOX
            snprintf(tbuf, sizeof(tbuf), "$%s", ap->a_w.w_symbol->s_name);
#else /* ROCKBOX */
    	    sprintf(tbuf, "$%s", ap->a_w.w_symbol->s_name);
#endif /* ROCKBOX */
    	    SETSYMBOL(ap, gensym(tbuf));
    	    break;
    	case A_SYMBOL:
    	    	/* FIXME make this general */
    	    if (!strcmp(ap->a_w.w_symbol->s_name, ";"))
    	    	SETSYMBOL(ap, gensym(";"));
    	    else if (!strcmp(ap->a_w.w_symbol->s_name, ","))
    	    	SETSYMBOL(ap, gensym(","));
    	    break;
    	default:
    	    bug("binbuf_addbinbuf");
    	}
    }
    
    binbuf_add(x, z->b_n, z->b_vec);
}
Esempio n. 23
0
static void *toany_new(t_symbol *sel, int argc, t_atom *argv){
    t_symbol *dummy = sel;
    dummy = NULL;
    t_toany *x = (t_toany *)pd_new(toany_class);
    int bufsize = 256;
    x->x_binbuf = binbuf_new();
    x->x_eos  = -1;
    if(argc)
        x->x_eos = atom_getfloatarg(0, argc, argv);
    toany_char_code_clear(&x->x_char_code);
    toany_char_code_realloc(&x->x_char_code, bufsize);
    x->x_eos_in = floatinlet_new(&x->x_obj, &x->x_eos);
    x->x_outlet = outlet_new(&x->x_obj, &s_list);
    return (void *)x;
}
Esempio n. 24
0
void breakpoints_write(t_breakpoints *x, t_symbol *s, int argc, t_atom *argv)
{
    t_binbuf *d = binbuf_new();
    if(d && argv && argc && atom_gettype(argv) == A_SYM)
    {
        breakpoints_save(x, d);
        if(binbuf_write(d, atom_getsym(argv)->s_name, "", 0))
        {
            object_error(x, "breakpoints : %s write failed", atom_getsym(argv)->s_name);
        }
    }
    if(d)
        binbuf_free(d);

}
Esempio n. 25
0
void from_ascii_code_setup(void)
{
	// create binbuf (no need to ever free)
	from_ascii_code_binbuf = binbuf_new();
	
	
	
    from_ascii_code_class = class_new(gensym("from_ascii_code"),
			    (t_newmethod)from_ascii_code_new, (t_method)from_ascii_code_free,
			    sizeof(t_from_ascii_code), 0, A_GIMME, 0);
    
    class_addbang(from_ascii_code_class, from_ascii_code_bang);
    class_addfloat(from_ascii_code_class, from_ascii_code_float);
    class_addlist(from_ascii_code_class, from_ascii_code_list);
    
    }
Esempio n. 26
0
static void autoabstraction_initialize(void)
{
  if(s_bb)
    binbuf_free(s_bb);

  s_bb=binbuf_new();

  /* try to read a template file */
  if(binbuf_read(s_bb, s_templatefilename, "", 0)) {
    /* if this fails, use the default template */
    size_t length=strlen(s_templatestring);

    binbuf_text(s_bb, s_templatestring, length);
  }
  s_state=1;
}
static void *qlist_new( void)
{
    t_symbol *name, *filename = 0;
    t_qlist *x = (t_qlist *)pd_new(qlist_class);
    x->x_binbuf = binbuf_new();
    x->x_clock = clock_new(x, (t_method)qlist_tick);
    outlet_new(&x->x_ob, &s_list);
    x->x_bangout = outlet_new(&x->x_ob, &s_bang);
    x->x_onset = 0x7fffffff;
    x->x_tempo = 1;
    x->x_whenclockset = 0;
    x->x_clockdelay = 0;
    x->x_canvas = canvas_getcurrent();
    x->x_reentered = 0;
    return (x);
}
static void *textfile_new( void)
{
    t_symbol *name, *filename = 0;
    t_textfile *x = (t_textfile *)pd_new(textfile_class);
    x->x_binbuf = binbuf_new();
    outlet_new(&x->x_ob, &s_list);
    x->x_bangout = outlet_new(&x->x_ob, &s_bang);
    x->x_onset = 0x7fffffff;
    x->x_reentered = 0;
    x->x_tempo = 1;
    x->x_whenclockset = 0;
    x->x_clockdelay = 0;
    x->x_clock = NULL;
    x->x_canvas = canvas_getcurrent();
    return (x);
}
Esempio n. 29
0
void to_ascii_code_setup(void)
{
	// create binbuf (no need to ever free)
	to_ascii_code_binbuf = binbuf_new();
	
	// create text (no need to ever free)
	to_ascii_code_text = getbytes(MAXPDSTRING*sizeof(*to_ascii_code_text));	
	
    to_ascii_code_class = class_new(gensym("to_ascii_code"),
			    (t_newmethod)to_ascii_code_new, 0,
			    sizeof(t_to_ascii_code), 0, A_GIMME, 0);
    
    class_addbang(to_ascii_code_class, to_ascii_code_bang);
    class_addanything(to_ascii_code_class, to_ascii_code_anything);
    
    
    }
Esempio n. 30
0
void breakpoints_read(t_breakpoints *x, t_symbol *s, int argc, t_atom *argv)
{
    t_binbuf *d = binbuf_new();
    if(d && argv && argc && atom_gettype(argv) == A_SYM)
    {
        if(binbuf_read(d, atom_getsym(argv)->s_name, "", 0))
        {
            object_error(x, "breakpoints : %s read failed", atom_getsym(argv)->s_name);
        }
        else
        {
            breakpoints_init(x, d);
        }
    }
    if(d)
        binbuf_free(d);
}