[PD-cvs] externals/miXed/shared/common port.c,1.9,1.10 rand.c,1.1.1.1,1.2 rand.h,1.1.1.1,1.2

Krzysztof Czaja krzyszcz at users.sourceforge.net
Tue Apr 20 15:55:30 CEST 2004


Update of /cvsroot/pure-data/externals/miXed/shared/common
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31807/shared/common

Modified Files:
	port.c rand.c rand.h 
Log Message:
importing tables

Index: port.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/port.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** port.c	17 Apr 2004 17:45:28 -0000	1.9
--- port.c	20 Apr 2004 13:55:28 -0000	1.10
***************
*** 15,18 ****
--- 15,19 ----
  #endif
  #include <stdio.h>
+ #include <stdarg.h>
  #include <string.h>
  #include "m_pd.h"
***************
*** 78,87 ****
      int        x_dumping;
      /* class-specifics, LATER find a better way */
-     int        x_tablerange;
-     int        x_tableleft;
-     int        x_tabletop;
-     int        x_tableright;
-     int        x_tablebottom;
-     int        x_tableflags;
      FILE      *x_pictfp;
      int        x_pictno;
--- 79,82 ----
***************
*** 343,346 ****
--- 338,387 ----
  }
  
+ static int import_emadd(t_port *x, t_symbol *state, int ac, t_atom *av)
+ {
+     if (import_emcheck(x, state))
+     {
+ 	t_atom at;
+ 	SETSYMBOL(&at, gensym("#C"));
+ 	binbuf_add(x->x_embb, 1, &at);
+ 	binbuf_add(x->x_embb, ac, av);
+ 	binbuf_addsemi(x->x_embb);
+ 	return (1);
+     }
+     else return (0);
+ }
+ 
+ static int import_emaddv(t_port *x, t_symbol *state, char *fmt, ...)
+ {
+     va_list ap;
+     t_atom arg[64], *at = arg;
+     int nargs = 0;
+     char *fp = fmt;
+     va_start(ap, fmt);
+     SETSYMBOL(at, gensym("#C"));
+     at++; nargs++;
+     if (import_emcheck(x, state)) while (1)
+     {
+ 	switch(*fp++)
+ 	{
+ 	case 'i': SETFLOAT(at, va_arg(ap, t_int)); break;
+ 	case 'f': SETFLOAT(at, va_arg(ap, double)); break;
+ 	case 's': SETSYMBOL(at, va_arg(ap, t_symbol *)); break;
+ 	case ';': SETSEMI(at); break;
+ 	case 0: goto done;
+ 	default: nargs = 0; goto done;
+ 	}
+ 	at++; nargs++;
+     }
+ done:
+     va_end(ap);
+     if (nargs > 1)
+     {
+ 	binbuf_add(x->x_embb, nargs, arg);
+ 	return (1);
+     }
+     else return (0);
+ }
+ 
  static void import_addclassname(t_port *x, char *outname, t_atom *inatom)
  {
***************
*** 431,447 ****
  static int imaction_N1_vtable(t_port *x, char *arg)
  {
      import_emstart(x, portps_vtable, port_getsymbol(x, 9), port_getint(x, 2));
-     x->x_tablerange = port_getint(x, 8);
-     x->x_tableleft = port_getint(x, 3);
-     x->x_tabletop = port_getint(x, 4);
-     x->x_tableright = port_getint(x, 5);
-     x->x_tablebottom = port_getint(x, 6);
-     x->x_tableflags = port_getint(x, 7);
  #ifdef PORT_DEBUG
      post("vtable \"%s\": size %d, range %d, coords %d %d %d %d, flags %d",
! 	 x->x_emname->s_name, x->x_emsize, x->x_tablerange,
! 	 x->x_tableleft, x->x_tabletop, x->x_tableright, x->x_tablebottom,
! 	 x->x_tableflags);
  #endif
      return (PORT_NEXT);
  }
--- 472,495 ----
  static int imaction_N1_vtable(t_port *x, char *arg)
  {
+     int range = port_getint(x, 8),
+ 	left = port_getint(x, 3),
+ 	top = port_getint(x, 4),
+ 	right = port_getint(x, 5),
+ 	bottom = port_getint(x, 6),
+ 	flags = port_getint(x, 7);
      import_emstart(x, portps_vtable, port_getsymbol(x, 9), port_getint(x, 2));
  #ifdef PORT_DEBUG
      post("vtable \"%s\": size %d, range %d, coords %d %d %d %d, flags %d",
! 	 x->x_emname->s_name, x->x_emsize,
! 	 range, left, top, right, bottom, flags);
  #endif
+     import_emaddv(x, portps_vtable, "si;", gensym("size"), x->x_emsize);
+     import_emaddv(x, portps_vtable, "siiii;", gensym("flags"),
+ 		  /* CHECKED */
+ 		  (flags & 16) != 0, (flags & 4) != 0,
+ 		  (flags & 8) != 0, (flags & 2) != 0);
+     import_emaddv(x, portps_vtable, "si;", gensym("tabrange"), range);
+     import_emaddv(x, portps_vtable, "siiiii;", gensym("_coords"),
+ 		  left, top, right, bottom, flags & 1);
      return (PORT_NEXT);
  }

Index: rand.h
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/rand.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** rand.h	23 May 2003 12:29:52 -0000	1.1.1.1
--- rand.h	20 Apr 2004 13:55:28 -0000	1.2
***************
*** 1,3 ****
! /* Copyright (c) 2002-2003 krzYszcz and others.
   * For information on usage and redistribution, and for a DISCLAIMER OF ALL
   * WARRANTIES, see the file, "LICENSE.txt," in this distribution.  */
--- 1,3 ----
! /* Copyright (c) 2002-2004 krzYszcz and others.
   * For information on usage and redistribution, and for a DISCLAIMER OF ALL
   * WARRANTIES, see the file, "LICENSE.txt," in this distribution.  */
***************
*** 10,14 ****
  void rand_seed(unsigned int *statep, unsigned int seed);
  int rand_int(unsigned int *statep, int range);
! float rand_float(unsigned int *statep);
  
  #endif
--- 10,15 ----
  void rand_seed(unsigned int *statep, unsigned int seed);
  int rand_int(unsigned int *statep, int range);
! float rand_unipolar(unsigned int *statep);
! float rand_bipolar(unsigned int *statep);
  
  #endif

Index: rand.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/rand.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** rand.c	23 May 2003 12:29:52 -0000	1.1.1.1
--- rand.c	20 Apr 2004 13:55:28 -0000	1.2
***************
*** 1,3 ****
! /* Copyright (c) 1997-2003 Miller Puckette, krzYszcz, and others.
   * For information on usage and redistribution, and for a DISCLAIMER OF ALL
   * WARRANTIES, see the file, "LICENSE.txt," in this distribution.  */
--- 1,3 ----
! /* Copyright (c) 1997-2004 Miller Puckette, krzYszcz, and others.
   * For information on usage and redistribution, and for a DISCLAIMER OF ALL
   * WARRANTIES, see the file, "LICENSE.txt," in this distribution.  */
***************
*** 52,61 ****
  }
  
  /* borrowed from d_osc.c, LATER rethink */
! float rand_float(unsigned int *statep)
  {
!     float result = ((float)((*statep & 0x7fffffff) - 0x40000000))
  	* (float)(1.0 / 0x40000000);
!     *statep = *statep * 435898247 + 382842987;
      return (result);
  }
--- 52,69 ----
  }
  
+ float rand_unipolar(unsigned int *statep)
+ {
+     float result;
+     *statep = *statep * 472940017 + 832416023;
+     result = (float)((double)*statep * (1./4294967296.));
+     return (result);
+ }
+ 
  /* borrowed from d_osc.c, LATER rethink */
! float rand_bipolar(unsigned int *statep)
  {
!     float result = ((float)(((int)*statep & 0x7fffffff) - 0x40000000))
  	* (float)(1.0 / 0x40000000);
!     *statep = (unsigned)((int)*statep * 435898247 + 382842987);
      return (result);
  }





More information about the Pd-cvs mailing list