[PD] no reverb or delwrite~, delread~ working with -nogui onUbuntu 10.04

Mathieu Bouchard matju at artengine.ca
Sun May 16 23:58:13 CEST 2010


On Sun, 16 May 2010, brandt at subnet.at wrote:

> Thanks to all of you and thank you mathieu for the workaround

you actually don't need this workaround, because here's the fix :

--- d_delay.c	(révision 13558)
+++ d_delay.c	(copie de travail)
@@ -24,6 +24,7 @@
  {
      t_object x_obj;
      t_symbol *x_sym;
+    t_float x_deltime;  /* delay in msec */
      t_delwritectl x_cspace;
      int x_sortno;   /* DSP sort number at which this was last put on chain */
      int x_rsortno;  /* DSP sort # for first delread or write in chain */
@@ -34,6 +35,21 @@
  #define XTRASAMPS 4
  #define SAMPBLK 4

+static void sigdelwrite_updatesr (t_sigdelwrite *x, t_float sr)
+{
+    int nsamps = x->x_deltime * sr * (t_float)(0.001f);
+    if (nsamps < 1) nsamps = 1;
+    nsamps += ((- nsamps) & (SAMPBLK - 1));
+    nsamps += DEFDELVS;
+    if (x->x_cspace.c_n != nsamps) {
+      x->x_cspace.c_vec = (t_sample *)resizebytes(x->x_cspace.c_vec,
+        (x->x_cspace.c_n + XTRASAMPS) * sizeof(t_sample),
+        (         nsamps + XTRASAMPS) * sizeof(t_sample));
+      x->x_cspace.c_n = nsamps;
+      x->x_cspace.c_phase = XTRASAMPS;
+    }
+}
+
      /* routine to check that all delwrites/delreads/vds have same vecsize */
  static void sigdelwrite_checkvecsize(t_sigdelwrite *x, int vecsize)
  {
@@ -54,19 +70,13 @@

  static void *sigdelwrite_new(t_symbol *s, t_floatarg msec)
  {
-    int nsamps;
      t_sigdelwrite *x = (t_sigdelwrite *)pd_new(sigdelwrite_class);
      if (!*s->s_name) s = gensym("delwrite~");
      pd_bind(&x->x_obj.ob_pd, s);
      x->x_sym = s;
-    nsamps = msec * sys_getsr() * (t_float)(0.001f);
-    if (nsamps < 1) nsamps = 1;
-    nsamps += ((- nsamps) & (SAMPBLK - 1));
-    nsamps += DEFDELVS;
-    x->x_cspace.c_n = nsamps;
-    x->x_cspace.c_vec =
-        (t_sample *)getbytes((nsamps + XTRASAMPS) * sizeof(t_sample));
-    x->x_cspace.c_phase = XTRASAMPS;
+    x->x_deltime = msec;
+    x->x_cspace.c_n = 0;
+    x->x_cspace.c_vec = getbytes(XTRASAMPS * sizeof(t_sample));
      x->x_sortno = 0;
      x->x_vecsize = 0;
      x->x_f = 0;
@@ -109,6 +119,7 @@
      dsp_add(sigdelwrite_perform, 3, sp[0]->s_vec, &x->x_cspace, sp[0]->s_n);
      x->x_sortno = ugen_getsortno();
      sigdelwrite_checkvecsize(x, sp[0]->s_n);
+    sigdelwrite_updatesr(x, sp[0]->s_sr);
  }

  static void sigdelwrite_free(t_sigdelwrite *x)
@@ -180,6 +191,7 @@
      int delsamps = *(int *)(w[3]);
      int n = (int)(w[4]);
      int phase = c->c_phase - delsamps, nsamps = c->c_n;
+
      t_sample *vp = c->c_vec, *bp, *ep = vp + (c->c_n + XTRASAMPS);
      if (phase < 0) phase += nsamps;
      bp = vp + phase;
@@ -197,6 +209,7 @@
      t_sigdelwrite *delwriter =
          (t_sigdelwrite *)pd_findbyclass(x->x_sym, sigdelwrite_class);
      x->x_sr = sp[0]->s_sr * 0.001;
+    sigdelwrite_updatesr(delwriter, sp[0]->s_sr);
      x->x_n = sp[0]->s_n;
      if (delwriter)
      {
@@ -206,8 +219,7 @@
          sigdelread_float(x, x->x_deltime);
          dsp_add(sigdelread_perform, 4,
              sp[0]->s_vec, &delwriter->x_cspace, &x->x_delsamps, sp[0]->s_n);
-    }
-    else if (*x->x_sym->s_name)
+    } else if (*x->x_sym->s_name)
          error("delread~: %s: no such delwrite~",x->x_sym->s_name);
  }

  _ _ __ ___ _____ ________ _____________ _____________________ ...
| Mathieu Bouchard, Montréal, Québec. téléphone: +1.514.383.3801


More information about the Pd-list mailing list