[xiph-commits] r13410 - trunk/ghost/libghost

jm at svn.xiph.org jm at svn.xiph.org
Mon Jul 30 21:47:28 PDT 2007


Author: jm
Date: 2007-07-30 21:47:28 -0700 (Mon, 30 Jul 2007)
New Revision: 13410

Modified:
   trunk/ghost/libghost/ghost.c
   trunk/ghost/libghost/sinusoids.c
Log:
Using hanning as analysis, rect at synthesis


Modified: trunk/ghost/libghost/ghost.c
===================================================================
--- trunk/ghost/libghost/ghost.c	2007-07-30 22:40:33 UTC (rev 13409)
+++ trunk/ghost/libghost/ghost.c	2007-07-31 04:47:28 UTC (rev 13410)
@@ -32,7 +32,7 @@
 
 #define PCM_BUF_SIZE 2048
 
-#define SINUSOIDS 30
+#define SINUSOIDS 5
 #define MASK_LPC_ORDER 12
 
 void fir_mem2(const spx_sig_t *x, const spx_coef_t *num, spx_sig_t *y, int N, int ord, spx_mem_t *mem)
@@ -82,7 +82,7 @@
    st->lpc_length = 384;
    st->lpc_order = MASK_LPC_ORDER;
    st->pcm_buf = calloc(PCM_BUF_SIZE,sizeof(float));
-#if 0
+#if 1
    /* pre-analysis window centered around the current frame */
    st->current_frame = st->pcm_buf + PCM_BUF_SIZE/2 - st->length/2;
 #else
@@ -111,8 +111,10 @@
    }
    for (i=0;i<st->overlap;i++)
    {
-      st->synthesis_window[i] = .5-.5*cos(M_PI*i/st->overlap);
-      st->synthesis_window[st->length-i-1] = .5-.5*cos(M_PI*(i+1)/st->overlap);
+      //st->analysis_window[i] = .5-.5*cos(M_PI*i/st->overlap);
+      //st->analysis_window[st->length-i-1] = .5-.5*cos(M_PI*(i+1)/st->overlap);
+      st->analysis_window[i] = ((float)i)/st->overlap;
+      st->analysis_window[st->length-i-1] = ((float)i+1)/st->overlap;
    }
 #if 1
    for (i=0;i<st->lpc_length;i++)
@@ -194,11 +196,11 @@
       for (i=0;i<st->overlap;i++)
       {
          st->new_noise[i] = st->new_noise[i]*st->synthesis_window[i+st->length-st->overlap] + 
-               (st->current_frame[i]-y[i])*st->synthesis_window[i];
+               (x[i]-y[i])*st->synthesis_window[i];
       }
       for (i=st->overlap;i<st->length;i++)
       {
-         st->new_noise[i] = st->current_frame[i]-y[i];
+         st->new_noise[i] = x[i]-y[i];
       }
       
       /*for (i=0;i<st->overlap;i++)
@@ -296,7 +298,7 @@
       pcm[i] = st->current_frame[i]-st->new_noise[i];*/
       
       for (i=0;i<st->advance;i++)
-         pcm[i] = st->current_frame[i]-st->new_noise[i] /*+ noise[i]*/;
+         pcm[i] = /*st->current_frame[i]-*/st->new_noise[i] /*+ noise[i]*/;
       
    }
    

Modified: trunk/ghost/libghost/sinusoids.c
===================================================================
--- trunk/ghost/libghost/sinusoids.c	2007-07-30 22:40:33 UTC (rev 13409)
+++ trunk/ghost/libghost/sinusoids.c	2007-07-31 04:47:28 UTC (rev 13410)
@@ -284,6 +284,10 @@
             cos_table[i][j] = re;
             sin_table[i][j] = im;
          }
+         for (j=0;j<L2;j++)
+            cos_table[i][j] *= window[j+L2];
+         for (j=0;j<L2;j++)
+            sin_table[i][j] *= window[j+L2];
          /* Compute energy of basis functions. There may be a closed-form solution for that
             or we could tabulate it. */
          for (j=0;j<L2;j++)



More information about the commits mailing list