Example #1
0
static void preset_store(t_presetobj *x, float f)
{
    int index = (int)f;
    if(index >= 1 && index < CREAM_MAXITEMS)
    {
        index -= 1;
        char id[MAXPDSTRING];
        t_atom av[2];

        t_binbuf *b = x->f_binbuf[index];
        if(binbuf_getnatom(b))
        {
            binbuf_clear(b);
        }
        /*
        for(t_gobj *y = eobj_getcanvas(x)->gl_list; y; y = y->g_next)
        {
            t_ebox *z = (t_ebox *)y;
            t_gotfn mpreset = zgetfn(&y->g_pd, cream_sym_preset);
            if(mpreset && z->b_preset_id)
            {
                if(z->b_preset_id != cream_sym_nothing)
                {
                    sprintf(id, "@%s", z->b_preset_id->s_name);
                    atom_setsym(av, gensym(id));
                    atom_setsym(av+1, eobj_getclassname(z));
                    binbuf_add(b, 2, av);
                    mpreset(z, b);
                }
            }
            mpreset = NULL;
        }
         */
    }
}
Example #2
0
File: mtr.c Project: EQ4/PdPulpito
static void mtrack_setmode(t_mtrack *tp, int newmode)
{
    if (tp->tr_mode == MTR_PLAYMODE)
    {
	clock_unset(tp->tr_clock);
	tp->tr_ixnext = 0;
    }
    switch (tp->tr_mode = newmode)
    {
    case MTR_STEPMODE:
	break;
    case MTR_RECMODE:
	binbuf_clear(tp->tr_binbuf);
	tp->tr_prevtime = clock_getlogicaltime();
	break;
    case MTR_PLAYMODE:
	tp->tr_atdelta = 0;
	tp->tr_ixnext = 0;
	tp->tr_prevtime = 0.;
	mtrack_donext(tp);
	break;
    default:
	loudbug_bug("mtrack_setmode");
    }
}
Example #3
0
static void import_emend(t_port *x, t_symbol *state, t_symbol *name)
{
    import_emcheckend(x, state, name);
    x->x_emstate = 0;
    x->x_emname = 0;
    x->x_emsize = 0;
    x->x_emcount = 0;
    binbuf_clear(x->x_embb);
}
Example #4
0
static void hammereditor_end(t_hammerfile *f)
{
    if (f->f_editorfn)
    {
	(*f->f_editorfn)(f->f_master, 0, binbuf_getnatom(f->f_binbuf),
			 binbuf_getvec(f->f_binbuf));
	binbuf_clear(f->f_binbuf);
    }
}
Example #5
0
static void import_emstart(t_port *x, t_symbol *state, t_symbol *name, int size)
{
    if (x->x_emstate) import_embroken(x, state->s_name);
    x->x_emstate = state;
    binbuf_clear(x->x_embb);
    x->x_emname = name;
    x->x_emsize = size;
    x->x_emcount = 0;
}
Example #6
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();
    }
}
Example #7
0
static void preset_clearall(t_presetobj *x)
{
    for(int i = 0; i < CREAM_MAXITEMS; i++)
    {
        binbuf_clear(x->f_binbuf[i]);
    }
    x->f_binbuf_selected = 0;
    ebox_invalidate_layer((t_ebox *)x, cream_sym_background_layer);
    ebox_redraw((t_ebox *)x);
}
Example #8
0
static void import_emflush(t_port *x, t_symbol *state, t_symbol *name)
{
    int ac = binbuf_getnatom(x->x_embb);
    if (import_emcheckend(x, state, name) && ac)
	binbuf_add(x->x_outbb, ac, binbuf_getvec(x->x_embb));
    x->x_emstate = 0;
    x->x_emname = 0;
    x->x_emsize = 0;
    x->x_emcount = 0;
    if (ac) binbuf_clear(x->x_embb);
    binbuf_addv(x->x_outbb, "ss;", gensym("#C"), gensym("restore"));
}
Example #9
0
static void preset_clear(t_presetobj *x, float f)
{
    int index = (int)f;
    if(index >= 1 && index < CREAM_MAXITEMS)
    {
        index -= 1;
        if(x->f_binbuf_selected == index)
        {
            x->f_binbuf_selected = 0;
        }
        binbuf_clear(x->f_binbuf[index]);

        ebox_invalidate_layer((t_ebox *)x, cream_sym_background_layer);
        ebox_redraw((t_ebox *)x);
    }
}
Example #10
0
static int readbinmessage(t_binbuf *b)
{
    binbuf_clear(b);
    while (1)
    {
        t_atom at;
        if (!pd_tilde_getatom(&at, stdin))
        {
            fprintf(stderr, "pd-extern: EOF on input\n");
            return (0);
        }
        else if (at.a_type == A_SEMI)
            return (1);
        else binbuf_add(b, 1, &at);
    }
}
Example #11
0
// Force output even if eof has not been received
static void from_ascii_code_bang(t_from_ascii_code *x) {
	
	if ( x->size ) {
		binbuf_clear(from_ascii_code_binbuf);
		binbuf_text(from_ascii_code_binbuf, x->text, x->size);
		t_atom *argv = binbuf_getvec(from_ascii_code_binbuf);
		int     argc = binbuf_getnatom(from_ascii_code_binbuf);
		if ( argc) {
			if ( (argv->a_type == A_SYMBOL)	) {
				outlet_anything(x->outlet_left,atom_getsymbol(argv),argc-1,argv+1);
			} else {
				outlet_anything(x->outlet_left,&s_list,argc,argv);
			}
		}
		x->size = 0;
	}
}
Example #12
0
static void preset_init(t_presetobj *x, t_binbuf *d)
{
	int check;
    long index;
    int ac = binbuf_getnatom(d);
    t_atom* av = binbuf_getvec(d);
    for(int i = 0; i < ac; i++)
    {
        if(atom_gettype(av+i) == A_SYMBOL && atom_getsymbol(av+i) == cream_sym_atpreset)
        {
            for(;i < ac; i++)
            {
                if(atom_gettype(av+i) == A_SYMBOL && atom_getsymbol(av+i) == cream_sym_atindex)
                {
                    i++;
                    if(i+1 < ac && atom_gettype(av+i) == A_FLOAT)
                    {
                        index = atom_getlong(av+i);
                        binbuf_clear(x->f_binbuf[index]);
                        i++;
                        check = 1;
                        for(; i < ac && check; i++)
                        {
                            if(atom_gettype(av+i) == A_SYMBOL && atom_getsymbol(av+i) == cream_sym_atindex)
                            {
                                i -=  2;
                                check = 0;
                            }
                            else if(atom_gettype(av+i) == A_SYMBOL && atom_getsymbol(av+i) == cream_sym_right_bracket)
                            {
                                return;
                            }
                            else
                            {
                                binbuf_add(x->f_binbuf[index], 1, av+i);
                            }
                        }

                    }
                }
            }
        }
    }

}
Example #13
0
static int readasciimessage(t_binbuf *b)
{
    int fill = 0, c;

    binbuf_clear(b);
    while ((c = getchar()) != EOF)
    {
        if (c == ';')
        {
            binbuf_text(b, ascii_inbuf, fill);
            return (1);
        }
        else if (fill < BUFSIZE)
            ascii_inbuf[fill++] = c;
        else if (fill == BUFSIZE)
            fprintf(stderr, "pd-extern: input buffer overflow\n");
    }
    return (0);
}
Example #14
0
static void gobj_stowconnections(t_glist *gl, t_gobj *ob, t_binbuf *bb)
{
    t_linetraverser lt;
    t_outconnect *oc;
    binbuf_clear(bb);
    linetraverser_start(&lt, gl);
    while (oc = linetraverser_next(&lt))
    {
        if ((t_gobj *)lt.tr_ob == ob || (t_gobj *)lt.tr_ob2 == ob)
            binbuf_addv(bb, "ssiiii;",
                        gensym("#X"), gensym("connect"),
                        gobj_getindex(gl, (t_gobj *)lt.tr_ob), lt.tr_outno,
                        gobj_getindex(gl, (t_gobj *)lt.tr_ob2), lt.tr_inno);
    }
#ifdef FRINGE_DEBUG
    fprintf(stderr, "packed connections:\n");
    binbuf_print(bb);
#endif
}
Example #15
0
File: a2s.c Project: Angeldude/pd
void a2s_list(t_pd_obj_a2s *x, t_symbol *s, int argc, t_atom *argv)
{
  char      buffer[MAXPDSTRING] ;
  char     *a_string    ;
  int       a_string_l  ;
  t_binbuf *bbuf        ;
  int       i,l=0,k=0   ;
  
  bbuf = binbuf_new() ;
  for (i=0;i<argc;i++)
  {
    binbuf_clear(bbuf);
    binbuf_add(bbuf, 1, argv++);
    binbuf_gettext(bbuf, &a_string, &a_string_l);
    memcpy(&buffer[k],a_string,a_string_l) ;
    freebytes(a_string,a_string_l);
    k+=a_string_l ;
  }  
  buffer[k]=0;
  outlet_symbol(x->x_obj.ob_outlet,gensym(&buffer[0]));
  binbuf_free(bbuf);  
}
Example #16
0
static void canvasargs_list(t_canvasargs *x, t_symbol*s, int argc, t_atom*argv)
{
  t_binbuf*b=0;
  t_atom name[1];

  if(!x || !x->x_canvas) return;
  b=x->x_canvas->gl_obj.te_binbuf;

  if(!b)return;

  /* if this method is called with a non-special selector, we *rename* the object */
  if(s==0 || s==gensym("") || s==&s_list || s==&s_bang || s==&s_float || s==&s_symbol || s==&s_) {
    /* keep the given name */
    t_atom*ap=binbuf_getvec(b);
    s=atom_getsymbol(ap);
  }
  SETSYMBOL(name, s);
  
  binbuf_clear(b);
  binbuf_add(b, 1, name);
  binbuf_add(b, argc, argv);
}
Example #17
0
static void convert_toany(t_toany_atoms *dst, t_toany_char_code *src, t_binbuf *x_binbuf){
    int bb_is_tmp = 0;                                      // create temporary binbuf?
    if(!x_binbuf){
        x_binbuf = binbuf_new();
        bb_is_tmp = 1;
    }
    binbuf_clear(x_binbuf);                                 // populate binbuf
    binbuf_text(x_binbuf, (char*)src->b_buf, src->b_len);   // populate atom list
    if(bb_is_tmp){                                          // temporary binbuf: copy atoms
        t_atom *argv = binbuf_getvec(x_binbuf);
        int     argc = binbuf_getnatom(x_binbuf);
        if(dst->a_alloc < (size_t)argc)                     // reallocate?
            toany_atoms_realloc(dst, argc + 256);
        memcpy(dst->a_buf, argv, argc*sizeof(t_atom));      // copy
        dst->a_len = argc;
        binbuf_free(x_binbuf);                              // cleanup
    }
    else if(dst){                                           // permanent binbuf: clobber dst
        dst->a_buf = binbuf_getvec(x_binbuf);
        dst->a_len = binbuf_getnatom(x_binbuf);
        dst->a_alloc = 0;                                   // don't try to free this
    }
}
Example #18
0
static void to_ascii_code_anything(t_to_ascii_code *x, t_symbol *s, int ac, t_atom *av) {
	
	binbuf_clear(to_ascii_code_binbuf);
	// Add selector if it is not standard
	if ( s != &s_list && s !=  &s_float && s != &s_symbol && s != &s_) {
		t_atom a;
		SETSYMBOL(&a, s);
		binbuf_add(to_ascii_code_binbuf,1,&a);
	}
	// Add all the atoms to the binbuf
	binbuf_add(to_ascii_code_binbuf, ac, av);
	
	
	
	// Get the contents as a text
	int size=0;
	binbuf_gettext(to_ascii_code_binbuf, &to_ascii_code_text, &size); //void binbuf_gettext(t_binbuf *x, char **bufp, int *lengthp);
	
	// Convert to a list of floats
	
	t_atom *list_floats = getbytes((size+1)*sizeof(*list_floats));	// Add some space for the eof character 
	int i;
	for ( i=0; i < size; i++ ) {
		SETFLOAT(list_floats+i,(t_float)to_ascii_code_text[i]);
	}
	if ( x->eof_is_set ) { // Append eof if set
		SETFLOAT(list_floats+size, x->eof);
		//outlet_float(x->outlet_right,size+1);
		outlet_list(x->outlet_left,&s_list,size+1,list_floats);
	} else {
		//outlet_float(x->outlet_right,size);
		outlet_list(x->outlet_left,&s_list,size,list_floats);
	}
	freebytes(list_floats, (size+1)*sizeof(*list_floats));
	
}
Example #19
0
File: xeq.c Project: pure-data/xeq
static void xeq_clear(t_xeq *x)
{
    xeq_rewind(x);
    binbuf_clear(x->x_binbuf);
}
Example #20
0
File: mtr.c Project: EQ4/PdPulpito
static void mtrack_clear(t_mtrack *tp)
{
    binbuf_clear(tp->tr_binbuf);
}
Example #21
0
File: mtr.c Project: EQ4/PdPulpito
static void mtr_doread(t_mtr *x, t_mtrack *target, t_symbol *fname)
{
    char path[MAXPDSTRING];
    FILE *fp;
    /* FIXME use open_via_path() */
    if (x->x_glist)
	canvas_makefilename(x->x_glist, fname->s_name, path, MAXPDSTRING);
    else
    {
    	strncpy(path, fname->s_name, MAXPDSTRING);
    	path[MAXPDSTRING-1] = 0;
    }
    /* CHECKED no global message */
    if (fp = sys_fopen(path, "r"))
    {
	t_mtrack *tp = 0;
	char linebuf[MTR_FILEBUFSIZE];
	t_binbuf *bb = binbuf_new();
	while (fgets(linebuf, MTR_FILEBUFSIZE, fp))
	{
	    char *line = linebuf;
	    int linelen;
	    while (*line && (*line == ' ' || *line == '\t')) line++;
	    if (linelen = strlen(line))
	    {
		if (tp)
		{
		    if (!strncmp(line, "end;", 4))
		    {
			post("ok");
			tp = 0;
		    }
		    else
		    {
			int ac;
			binbuf_text(bb, line, linelen);
			if (ac = binbuf_getnatom(bb))
			{
			    t_atom *ap = binbuf_getvec(bb);
			    if (!binbuf_getnatom(tp->tr_binbuf))
			    {
				if (ap->a_type != A_FLOAT)
				{
				    t_atom at;
				    SETFLOAT(&at, 0.);
				    binbuf_add(tp->tr_binbuf, 1, &at);
				}
				else if (ap->a_w.w_float < 0.)
				    ap->a_w.w_float = 0.;
			    }
			    binbuf_add(tp->tr_binbuf, ac, ap);
			}
		    }
		}
		else if (!strncmp(line, "track ", 6))
		{
		    int id = strtol(line + 6, 0, 10);
		    startpost("Track %d... ", id);
		    if (id < 1 || id > x->x_ntracks)
			post("no such track");  /* LATER rethink */
		    else if (target)
		    {
			if (id == target->tr_id)
			    tp = target;
			post("skipped");  /* LATER rethink */
		    }
		    else tp = x->x_tracks[id - 1];
		    if (tp)
		    {
			binbuf_clear(tp->tr_binbuf);
		    }
		}
	    }
	}
	fclose(fp);
	binbuf_free(bb);
    }
    else
    {
	/* CHECKED no complaint, open dialog not presented... */
	/* LATER rethink */
	hammerpanel_open(target ? target->tr_filehandle : x->x_filehandle, 0);
    }
}
Example #22
0
static void plusproxy_qlist_symbol(t_plusproxy_qlist *pp, t_symbol *s)
{
    t_plustot_qlist *x = pp->pp_master;
    Tcl_Interp *interp = 0;
    if (plustag_isvalid(s, 0))
    {
	t_plustin *tin;
	Tcl_Obj *ob;
	if ((tin = plustag_tobtin(s, PLUSBOB_OWNER)) &&
	    (ob = plustob_getvalue((t_plustob *)s)))
	{
	    t_binbuf *bb;
	    if (bb = plustot_qlist_usurp(x))
	    {
		int nlists;
		Tcl_Obj **lists;
		interp = plustin_getinterp(tin);
		if (Tcl_ListObjGetElements(interp, ob,
					   &nlists, &lists) == TCL_OK)
		{
		    int lc;
		    Tcl_Obj **lp;
		    binbuf_clear(bb);
		    for (lc = 0, lp = lists; lc < nlists; lc++, lp++)
		    {
			int natoms;
			Tcl_Obj **atoms;
			if (Tcl_ListObjGetElements(interp, *lp,
						   &natoms, &atoms) == TCL_OK)
			{
			    int ac;
			    Tcl_Obj **ap;
			    for (ac = 0, ap = atoms; ac < natoms; ac++, ap++)
			    {
				double d;
				int len;
				char *ptr;
				Tcl_IncrRefCount(*ap);
				if (Tcl_GetDoubleFromObj(interp,
							 *ap, &d) == TCL_OK)
				{
				    t_atom at;
				    SETFLOAT(&at, (float)d);
				    binbuf_add(bb, 1, &at);
				}
				else if ((ptr = Tcl_GetStringFromObj(*ap, &len))
					 && len)
				{
				    t_atom at;
				    if (ptr[len - 1])
				    {
					char buf[MAXPDSTRING];
					if (len > MAXPDSTRING - 1)
					    len = MAXPDSTRING - 1;
					strncpy(buf, ptr, len);
					buf[len] = 0;
					ptr = buf;
				    }
				    SETSYMBOL(&at, gensym(ptr));
				    binbuf_add(bb, 1, &at);
				}
				/* FIXME else */
				Tcl_DecrRefCount(*ap);
			    }
			    binbuf_addsemi(bb);
			}
			else
			{
			    binbuf_clear(bb);
			    goto notalist;
			}
		    }
		}
		else goto notalist;
	    }
	}
    }
    return;
notalist:
    if (interp) plusloud_tclerror((t_pd *)x, interp, "not a list");
}
static void qlist_clear(t_qlist *x)
{
    qlist_rewind(x);
    binbuf_clear(x->x_binbuf);
}