Update of /cvsroot/audacity/lib-src/libnyquist
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv29331/lib-src/libnyquist

Modified Files:
        nyx.c 
Log Message:
Corrects the excessive memory usage when running Nyquist effects and introduces 
the *audacity-plugin-result-length* variable to allow "generate" type of 
plugins to supply the expected output length of the sound.

Index: nyx.c
===================================================================
RCS file: /cvsroot/audacity/lib-src/libnyquist/nyx.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- nyx.c       25 Jul 2009 06:54:17 -0000      1.13
+++ nyx.c       18 Sep 2009 08:18:49 -0000      1.14
@@ -74,6 +74,7 @@
 LOCAL int                 nyx_first_time = 1;
 LOCAL LVAL                nyx_obarray;
 LOCAL FLOTYPE             nyx_warp_stretch;
+LOCAL long                nyx_input_length = 0;
 
 /* Suspension node */
 typedef struct nyx_susp_struct {
@@ -509,6 +510,9 @@
    nyx_output_cb = NULL;
    nyx_os_cb = NULL;
 
+   // Reset vars
+   nyx_input_length = 0;
+
 #if defined(NYX_MEMORY_STATS) && NYX_MEMORY_STATS
    printf("\nnyx_cleanup\n");
    xmem();
@@ -590,6 +594,7 @@
    setvalue(xlenter("*SOUND-SRATE*"), flo);
 
    /* Bind selection len to "len" global */
+   nyx_input_length = len;
    flo = cvflonum(len);
    setvalue(xlenter("LEN"), flo);
 
@@ -844,6 +849,8 @@
 
    xlpop(); // unprotect expr
 
+   setvalue(xlenter("S"), NIL);
+
    gc();
 
 #if defined(NYX_MEMORY_STATS) && NYX_MEMORY_STATS
@@ -926,6 +933,18 @@
       goto finish;
    }
 
+   if (nyx_input_length == 0) {
+      LVAL val = getvalue(xlenter("*AUDACITY-PLUGIN-RESULT-LENGTH*"));
+      if (val != s_unbound) {
+         if (ntype(val) == FLONUM) {
+            nyx_input_length = (long) getflonum(val);
+         }
+         else if (ntype(val) == FIXNUM) {
+            nyx_input_length = (long) getfixnum(val);
+         }
+      }
+   }
+
    for (ch = 0; ch < num_channels; ch++) {
       if (num_channels == 1) {
          snd = getsound(nyx_result);
@@ -935,7 +954,7 @@
       }
       snds[ch] = snd;
       totals[ch] = 0;
-      lens[ch] = snd_length(snd, snd->stop);
+      lens[ch] = nyx_input_length;
    }
 
    while (result == 0) {
@@ -960,7 +979,7 @@
          }
 
          result = callback((float *)buffer, ch,
-                           totals[ch], cnt, lens[ch], userdata);
+                           totals[ch], cnt, lens[ch] ? lens[ch] : cnt, 
userdata);
 
          if (result != 0) {
             result = -1;


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Audacity-cvs mailing list
Audacity-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to