コード例 #1
0
ファイル: flite.c プロジェクト: Angeldude/pd
/*--------------------------------------------------------------------
 * flite_text : set text-buffer
 *--------------------------------------------------------------------*/
void flite_text(t_flite *x, MOO_UNUSED t_symbol *s, int argc, t_atom *argv) {
  int i, alen, buffered;
  t_symbol *asym;

  // -- allocate initial text-buffer if required
  if (x->textbuf == NULL) {
    x->bufsize = DEFAULT_BUFSIZE;
    x->textbuf = getbytes(x->bufsize);
  }
  if (x->textbuf == NULL) {
    pd_error(x,"flite: allocation failed for text buffer");
    x->bufsize = 0;
    return;
  }

  // -- convert args to strings
  buffered = 0;
  for (i = 0; i < argc; i++) {
    asym = atom_gensym(argv);
    alen = 1+strlen(asym->s_name);

    // -- reallocate if necessary
    while (buffered + alen > x->bufsize) {
      x->textbuf = resizebytes(x->textbuf,x->bufsize,x->bufsize+DEFAULT_BUFSTEP);
      x->bufsize = x->bufsize+DEFAULT_BUFSTEP;
      if (x->textbuf == NULL) {
	pd_error(x,"flite: allocation failed for text buffer");
	x->bufsize = 0;
	return;
      }
    }
    
    // -- append arg-string to text-buf
    if (i == 0) {
      strcpy(x->textbuf+buffered, asym->s_name);
      buffered += alen-1;
    } else {
      *(x->textbuf+buffered) = ' ';
      strcpy(x->textbuf+buffered+1, asym->s_name);
      buffered += alen;
    }
    
    // -- increment/decrement
    argv++;
  }

#ifdef FLITE_DEBUG
  post("flite_debug: got text='%s'", x->textbuf);
#endif
}
コード例 #2
0
ファイル: g_graph.c プロジェクト: amurtet/pure-data
static void graph_ylabel(t_glist *x, t_symbol *s, int argc, t_atom *argv)
{
    int i;
    if (argc < 1) error("graph_ylabel: no x value given");
    else
    {
        x->gl_ylabelx = atom_getfloat(argv);
        argv++; argc--;
        x->gl_ylabel = (t_symbol **)t_resizebytes(x->gl_ylabel,
            x->gl_nylabels * sizeof (t_symbol *), argc * sizeof (t_symbol *));
        x->gl_nylabels = argc;
        for (i = 0; i < argc; i++) x->gl_ylabel[i] = atom_gensym(&argv[i]);
    }
    glist_redraw(x);
}
コード例 #3
0
void *odowncast_new(t_symbol *msg, short argc, t_atom *argv)
{
	t_odowncast *x;
	if((x = (t_odowncast *)object_alloc(odowncast_class))){
		x->outlet = outlet_new((t_object *)x, gensym("FullPacket"));
		x->timetag_address = NULL;
		x->doubles = x->ints = x->bundles = x->timetags = 1;
        
        
        /*
         CLASS_ATTR_SYM(c, "headertimetag", 0, t_odowncast, timetag_address);
         CLASS_ATTR_LONG(c, "doubles", 0, t_odowncast, doubles);
         CLASS_ATTR_LONG(c, "ints", 0, t_odowncast, ints);
         CLASS_ATTR_LONG(c, "bundles", 0, t_odowncast, bundles);
         CLASS_ATTR_LONG(c, "timetags", 0, t_odowncast, timetags);
         */
        

        int i;
        for(i = 0; i < argc; i++)
        {
            if(atom_gettype(argv + i) == A_SYM)
            {
                t_symbol *attribute = atom_gensym(argv+i);
                if(attribute == gensym("@headertimetag")){
                    if(atom_gettype(argv+(++i)) == A_SYMBOL)
                    {
                        x->timetag_address = atom_getsym(argv+i);
                    } else {
                        post("@headertimetag value must be an address symbol");
                        return 0;
                    }
                } else if(attribute == gensym("@doubles")){
                    if(atom_gettype(argv+(++i)) == A_FLOAT)
                    {
                        x->doubles = (long)(atom_getfloat(argv+i) != 0);
                    } else {
                        post("@doubles flag must be a number (0/1)");
                        return 0;
                    }
                } else if(attribute == gensym("@ints")){
                    if(atom_gettype(argv+(++i)) == A_FLOAT)
                    {
                        x->ints = (long)(atom_getfloat(argv+i) != 0);
                    } else {
                        post("@ints flag must be a number (0/1)");
                        return 0;
                    }
                } else if(attribute == gensym("@bundles")){
                    if(atom_gettype(argv+(++i)) == A_FLOAT)
                    {
                        x->bundles = (long)(atom_getfloat(argv+i) != 0);
                    } else {
                        post("@bundles flag must be a number (0/1)");
                        return 0;
                    }
                } else if(attribute == gensym("@timetags")){
                    if(atom_gettype(argv+(++i)) == A_FLOAT)
                    {
                        x->timetags = (long)(atom_getfloat(argv+i) != 0);
                    } else {
                        post("@timetags flag must be a number (0/1)");
                        return 0;
                    }
                } else if(attribute->s_name[0] == '@') {
                    post("unknown attribute");
                }  else {
                    post("o.downcast optional attributes are: @headertimetag, @doubles, @ints, @bundles, and @timetags");
                }
                
            } else {
                post("o.downcast optional attributes are: @headertimetag, @doubles, @ints, @bundles, and @timetags");
                return 0;
            }
            
            
        }

	}
	return x;
}