[PD-cvs] pd/src desire.c,1.1.2.217.2.153,1.1.2.217.2.154

Mathieu Bouchard matju at users.sourceforge.net
Wed Jul 11 21:39:50 CEST 2007


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23655

Modified Files:
      Tag: desiredata
	desire.c 
Log Message:
cleanup


Index: desire.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v
retrieving revision 1.1.2.217.2.153
retrieving revision 1.1.2.217.2.154
diff -C2 -d -r1.1.2.217.2.153 -r1.1.2.217.2.154
*** desire.c	11 Jul 2007 18:32:46 -0000	1.1.2.217.2.153
--- desire.c	11 Jul 2007 19:39:45 -0000	1.1.2.217.2.154
***************
*** 1918,1922 ****
  }
  
! /* sum of Fourier components; called from routines below */
  static void garray_dofo(t_garray *x, int npoints, float dcval, int nsin, t_float *vsin, int sineflag) {
      double phase, fj;
--- 1918,1922 ----
  }
  
! /* sum of Fourier components; called from functions below */
  static void garray_dofo(t_garray *x, int npoints, float dcval, int nsin, t_float *vsin, int sineflag) {
      double phase, fj;
***************
*** 2499,2516 ****
  */
  
! /*
! Routines to read and write canvases to files:
! canvas_savetofile() writes a root canvas to a "pd" file.  (Reading "pd" files
! is done simply by passing the contents to the pd message interpreter.)
! Alternatively, the  glist_read() and glist_write() routines read and write
! "data" from and to files (reading reads into an existing canvas), using a
! file format as in the dialog window for data.
! */
! 
  static t_class *declare_class;
  void canvas_savedeclarationsto(t_canvas *x, t_binbuf *b);
  
! /* the following routines read "scalars" from a file into a canvas. */
! 
  static int canvas_scanbinbuf(int natoms, t_atom *vec, int *p_indexout, int *p_next) {
      int i;
--- 2499,2510 ----
  */
  
! /* fucntions to read and write canvases to files: canvas_savetofile() writes a root canvas to a "pd" file.
!    (Reading "pd" files is done simply by passing the contents to the pd message interpreter.)
!    Alternatively, the  glist_read() and glist_write() functions read and write "data" from and to files
!    (reading reads into an existing canvas), using a file format as in the dialog window for data. */
  static t_class *declare_class;
  void canvas_savedeclarationsto(t_canvas *x, t_binbuf *b);
  
! /* the following functions read "scalars" from a file into a canvas. */
  static int canvas_scanbinbuf(int natoms, t_atom *vec, int *p_indexout, int *p_next) {
      int i;
***************
*** 2522,2528 ****
      return i-indexwas;
  }
- 
  static int canvas_readscalar(t_canvas *x, int natoms, t_atom *vec, int *p_nextmsg, int selectit);
- 
  static void canvas_readerror(int natoms, t_atom *vec, int message, int nline, char *s) {
      error(s);
--- 2516,2520 ----
***************
*** 2852,2856 ****
  }
  
! /* ------ routines to save and restore canvases (patches) recursively. ----*/
  
  /* save to a binbuf, called recursively; cf. canvas_savetofile() which
--- 2844,2848 ----
  }
  
! /* ------ functions to save and restore canvases (patches) recursively. ----*/
  
  /* save to a binbuf, called recursively; cf. canvas_savetofile() which
***************
*** 2982,2987 ****
      t_float *read;
      int hop;
!     /* if not reblocking, the next slot communicates the parent's inlet
!        signal from the prolog to the DSP routine: */
      t_signal *directsignal;
      t_resample updown; /* IOhannes */
--- 2974,2978 ----
      t_float *read;
      int hop;
!     /* if not reblocking, the next slot communicates the parent's inlet signal from the prolog to the DSP routine: */
      t_signal *directsignal;
      t_resample updown; /* IOhannes */
***************
*** 3071,3077 ****
      /* prolog code: loads buffer from parent patch */
  t_int *vinlet_doprolog(t_int *w) {
!     t_vinlet *x = (t_vinlet *)(w[1]);
!     t_float *in = (t_float *)(w[2]);
!     int n = (int)(w[3]);
      t_float *out = x->fill;
      if (out == x->endbuf) {
--- 3062,3068 ----
      /* prolog code: loads buffer from parent patch */
  t_int *vinlet_doprolog(t_int *w) {
!     t_vinlet *x = (t_vinlet *)w[1];
!     t_float *in = (t_float *)w[2];
!     int n = int(w[3]);
      t_float *out = x->fill;
      if (out == x->endbuf) {
***************
*** 3199,3208 ****
      t_float *write;       /* next to write in to buffer */
      int hop;              /* hopsize */
!         /* vice versa from the inlet, if we don't block, this holds the
!         parent's outlet signal, valid between the prolog and the dsp setup
!         routines.  */
      t_signal *directsignal;
!         /* and here's a flag indicating that we aren't blocked but have to
!         do a copy (because we're switched). */
      char justcopyout;
      t_resample updown; /* IOhannes */
--- 3190,3197 ----
      t_float *write;       /* next to write in to buffer */
      int hop;              /* hopsize */
!     /* vice versa from the inlet, if we don't block, this holds the
!        parent's outlet signal, valid between the prolog and the dsp setup functions.  */
      t_signal *directsignal;
!         /* and here's a flag indicating that we aren't blocked but have to do a copy (because we're switched). */
      char justcopyout;
      t_resample updown; /* IOhannes */
***************
*** 3248,3254 ****
  /* LATER optimize for non-overlapped case where the "+=" isn't needed */
  t_int *voutlet_perform(t_int *w) {
!     t_voutlet *x = (t_voutlet *)(w[1]);
!     t_float *in = (t_float *)(w[2]);
!     int n = (int)(w[3]);
      t_float *out = x->write, *outwas = out, *end = x->endbuf;
      while (n--) {
--- 3237,3243 ----
  /* LATER optimize for non-overlapped case where the "+=" isn't needed */
  t_int *voutlet_perform(t_int *w) {
!     t_voutlet *x = (t_voutlet *)w[1];
!     t_float *in = (t_float *)w[2];
!     int n = int(w[3]);
      t_float *out = x->write, *outwas = out, *end = x->endbuf;
      while (n--) {
***************
*** 3287,3294 ****
  extern "C" int outlet_getsignalindex(t_outlet *x);
  
! /* prolog for outlets -- store pointer to the outlet on the
!    parent, which, if "reblock" is false, will want to refer
!    back to whatever we see on our input during the "dsp" method
!    called later.  */
  extern "C" void voutlet_dspprolog(t_voutlet *x, t_signal **parentsigs, int myvecsize, int calcsize, int phase, int period,
  int frequency, int downsample, int upsample, int reblock, int switched) {
--- 3276,3281 ----
  extern "C" int outlet_getsignalindex(t_outlet *x);
  
! /* prolog for outlets -- store pointer to the outlet on the parent, which, if "reblock" is false, will want to refer
!    back to whatever we see on our input during the "dsp" method called later.  */
  extern "C" void voutlet_dspprolog(t_voutlet *x, t_signal **parentsigs, int myvecsize, int calcsize, int phase, int period,
  int frequency, int downsample, int upsample, int reblock, int switched) {
***************
*** 3370,3376 ****
          }
      }
!         /* if we aren't blocked but we are switched, the epilog code just
!         copies zeros to the output.  In this case the blocking code actually
!         jumps over the epilog if the block is running. */
      else if (switched) {
          if (parentsigs) {
--- 3357,3362 ----
          }
      }
!     /* if we aren't blocked but we are switched, the epilog code just
!        copies zeros to the output.  In this case the blocking code actually jumps over the epilog if the block is running. */
      else if (switched) {
          if (parentsigs) {
***************
*** 3393,3399 ****
       * maybe indeces would be better...
       * up till now we provide several upsampling methods and 1 single downsampling method (no filtering !) */
!     if (s){
        char c=*s->name;
!       switch(c){
        case 'h': case 'H': x->updown.method=RESAMPLE_HOLD; break; /* up: sample and hold */
        case 'l': case 'L': x->updown.method=RESAMPLE_LINEAR; break; /* up: linear interpolation */
--- 3379,3385 ----
       * maybe indeces would be better...
       * up till now we provide several upsampling methods and 1 single downsampling method (no filtering !) */
!     if (s) {
        char c=*s->name;
!       switch(c) {
        case 'h': case 'H': x->updown.method=RESAMPLE_HOLD; break; /* up: sample and hold */
        case 'l': case 'L': x->updown.method=RESAMPLE_LINEAR; break; /* up: linear interpolation */
***************
*** 3419,3431 ****
  
  /* This file defines the "scalar" object, which is not a text object, just a
! "gobj".  Scalars have templates which describe their structures, which
! can contain numbers, sublists, and arrays.
! 
! */
! 
! /* IOhannes changed the canvas_restore, so that it might accept $args as well (like "pd $0_test")
!  * so you can make multiple & distinguishable templates; added Krzysztof Czajas fix to avoid crashing...
! */
! 
  t_class *scalar_class;
  
--- 3405,3411 ----
  
  /* This file defines the "scalar" object, which is not a text object, just a
!    "gobj".  Scalars have templates which describe their structures, which can contain numbers, sublists, and arrays.
!    IOhannes changed the canvas_restore, so that it might accept $args as well (like "pd $0_test")
!    so you can make multiple & distinguishable templates; added Krzysztof Czajas fix to avoid crashing... */
  t_class *scalar_class;
  
***************
*** 3763,3767 ****
  /* --------------- CONFORMING TO CHANGES IN A TEMPLATE ------------ */
  
! /* the following routines handle updating scalars to agree with changes
  in their template.  The old template is assumed to be the "installed" one
  so we can delete old items; but making new ones we have to avoid scalar_new
--- 3743,3747 ----
  /* --------------- CONFORMING TO CHANGES IN A TEMPLATE ------------ */
  
! /* the following functions handle updating scalars to agree with changes
  in their template.  The old template is assumed to be the "installed" one
  so we can delete old items; but making new ones we have to avoid scalar_new
***************
*** 4221,4231 ****
      char *classname = classsym->name;
      int flags = 0;
-     int nxy, i;
-     t_slot *fd;
      x->canvas = canvas_getcurrent();
!     if (classname[0] == 'f') {
!         classname += 6;
!         flags |= CLOSED;
!     } else classname += 4;
      slot_setfloat_const(&x->vis, 1);
      if (classname[0] == 'c') flags |= BEZ;
--- 4201,4206 ----
      char *classname = classsym->name;
      int flags = 0;
      x->canvas = canvas_getcurrent();
!     if (classname[0] == 'f') {classname += 6; flags |= CLOSED;} else classname += 4;
      slot_setfloat_const(&x->vis, 1);
      if (classname[0] == 'c') flags |= BEZ;
***************
*** 4247,4254 ****
      FIELDSET(float,width,1);
      if (argc < 0) argc = 0;
!     nxy = argc + (argc&1);
      x->npoints = nxy>>1;
      x->vec = (t_slot *)getbytes(nxy * sizeof(t_slot));
!     for (i = 0, fd = x->vec; i < argc; i++, fd++, argv++) slot_setfloatarg(fd, 1, argv);
      if (argc & 1) slot_setfloat_const(fd, 0);
      return x;
--- 4222,4230 ----
      FIELDSET(float,width,1);
      if (argc < 0) argc = 0;
!     int nxy = argc + (argc&1);
      x->npoints = nxy>>1;
      x->vec = (t_slot *)getbytes(nxy * sizeof(t_slot));
!     t_slot *fd = x->vec;
!     for (int i=0; i<argc; i++, fd++, argv++) slot_setfloatarg(fd, 1, argv);
      if (argc & 1) slot_setfloat_const(fd, 0);
      return x;
***************
*** 4256,4265 ****
  
  static void curve_float(t_curve *x, t_floatarg f) {
-     int viswas;
      if (x->vis.type != A_FLOAT || x->vis.var) {
          pd_error(x, "global vis/invis for a template with variable visibility");
          return;
      }
!     viswas = x->vis.f!=0;
      if ((f!=0 && viswas) || (f==0 && !viswas)) return;
      canvas_redrawallfortemplatecanvas(x->canvas, 2);
--- 4232,4240 ----
  
  static void curve_float(t_curve *x, t_floatarg f) {
      if (x->vis.type != A_FLOAT || x->vis.var) {
          pd_error(x, "global vis/invis for a template with variable visibility");
          return;
      }
!     int viswas = x->vis.f!=0;
      if ((f!=0 && viswas) || (f==0 && !viswas)) return;
      canvas_redrawallfortemplatecanvas(x->canvas, 2);
***************
*** 4344,4353 ****
  t_array *ap, float basex, float basey, int xpix, int ypix, int shift, int alt, int dbl, int doit) {
      t_curve *x = (t_curve *)z;
-     int n = x->npoints;
      int bestn = -1;
      int besterror = 0x7fffffff;
      t_slot *f = x->vec;
      if (!slot_getfloat(&x->vis, t, data, 0)) return 0;
!     for (int i=0; i<n; i++, f += 2) {
          int xval = (int)slot_getcoord(f  , t, data, 0), xloc = canvas_xtopixels(canvas, basex + xval);
          int yval = (int)slot_getcoord(f+1, t, data, 0), yloc = canvas_ytopixels(canvas, basey + yval);
--- 4319,4327 ----
  t_array *ap, float basex, float basey, int xpix, int ypix, int shift, int alt, int dbl, int doit) {
      t_curve *x = (t_curve *)z;
      int bestn = -1;
      int besterror = 0x7fffffff;
      t_slot *f = x->vec;
      if (!slot_getfloat(&x->vis, t, data, 0)) return 0;
!     for (int i=0; i<x->npoints; i++, f += 2) {
          int xval = (int)slot_getcoord(f  , t, data, 0), xloc = canvas_xtopixels(canvas, basex + xval);
          int yval = (int)slot_getcoord(f+1, t, data, 0), yloc = canvas_ytopixels(canvas, basey + yval);
***************
*** 4381,4388 ****
  }
  
- static void curve_free(t_curve *x) {
-     free(x->vec);
- }
- 
  t_class *plot_class;
  
--- 4355,4358 ----
***************
*** 4511,4516 ****
      float linewidth, xloc, xinc, yloc, style, xsum, yval, vis, scalarvis;
      t_array *array;
-     int nelem;
-     char *elem;
      if (plot_readownertemplate(x, data, t, &elemtemplatesym, &array, &linewidth, &xloc, &xinc, &yloc, &style, &vis, &scalarvis)) return;
      t_slot *xslot = &x->xpoints, *yslot = &x->ypoints, *wslot = &x->wpoints;
--- 4481,4484 ----
***************
*** 4518,4523 ****
      if (array_getfields(elemtemplatesym, &elemtemplatecanvas, &elemtemplate, &elemsize,
  	xslot, yslot, wslot, &xonset, &yonset, &wonset)) return;
!     nelem = array->n;
!     elem = (char *)array->vec;
      if (tovis) {
          if (style == PLOTSTYLE_POINTS) {
--- 4486,4491 ----
      if (array_getfields(elemtemplatesym, &elemtemplatecanvas, &elemtemplate, &elemsize,
  	xslot, yslot, wslot, &xonset, &yonset, &wonset)) return;
!     int nelem = array->n;
!     char *elem = (char *)array->vec;
      if (tovis) {
          if (style == PLOTSTYLE_POINTS) {
***************
*** 4533,4539 ****
                      inextx = ixpix + 2;
                  } else {
!                     float usexloc = xsum;
!                     xsum += xinc;
!                     ixpix  = canvas_xtopixels(canvas, slot_cvttocoord(xslot, usexloc));
                      inextx = canvas_xtopixels(canvas, slot_cvttocoord(xslot, xsum));
                  }
--- 4501,4505 ----
                      inextx = ixpix + 2;
                  } else {
!                     ixpix  = canvas_xtopixels(canvas, slot_cvttocoord(xslot, xsum)); xsum += xinc;
                      inextx = canvas_xtopixels(canvas, slot_cvttocoord(xslot, xsum));
                  }
***************
*** 4856,4860 ****
      class_addcreator2("template",gtemplate_new_old,"*");
  
!     curve_class = class_new2("drawpolygon",curve_new,curve_free,sizeof(t_curve),0,"*");
      class_setdrawcommand(curve_class);
      class_addcreator2("drawcurve",    curve_new,"*");
--- 4822,4826 ----
      class_addcreator2("template",gtemplate_new_old,"*");
  
!     curve_class = class_new2("drawpolygon",curve_new,0,sizeof(t_curve),0,"*");
      class_setdrawcommand(curve_class);
      class_addcreator2("drawcurve",    curve_new,"*");





More information about the Pd-cvs mailing list