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

jm at svn.xiph.org jm at svn.xiph.org
Mon Jan 16 16:01:28 PST 2006


Author: jm
Date: 2006-01-16 16:01:25 -0800 (Mon, 16 Jan 2006)
New Revision: 10732

Modified:
   trunk/ghost/libghost/ghost.c
   trunk/ghost/libghost/ghost.h
Log:
using a rectangular analysis window for sinusoid matching


Modified: trunk/ghost/libghost/ghost.c
===================================================================
--- trunk/ghost/libghost/ghost.c	2006-01-16 17:22:38 UTC (rev 10731)
+++ trunk/ghost/libghost/ghost.c	2006-01-17 00:01:25 UTC (rev 10732)
@@ -42,16 +42,20 @@
    st->advance = 192;
    st->overlap = 64;
    st->pcm_buf = calloc(PCM_BUF_SIZE,sizeof(float));
-   st->window = calloc(st->length,sizeof(float));
+   st->analysis_window = calloc(st->length,sizeof(float));
+   st->synthesis_window = calloc(st->length,sizeof(float));
    st->big_window = calloc(PCM_BUF_SIZE,sizeof(float));
    st->syn_memory = calloc(st->overlap,sizeof(float));
    st->current_pcm = st->pcm_buf + PCM_BUF_SIZE - st->length;
    for (i=0;i<st->length;i++)
-      st->window[i] = 1;
+   {
+      st->analysis_window[i] = 1;
+      st->synthesis_window[i] = 1;
+   }
    for (i=0;i<st->overlap;i++)
    {
-      st->window[i] = .5-.5*cos(M_PI*i/st->overlap);
-      st->window[st->length-i-1] = .5-.5*cos(M_PI*(i+1)/st->overlap);
+      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->big_fft = spx_fft_init(PCM_BUF_SIZE);
    for (i=0;i<PCM_BUF_SIZE;i++)
@@ -99,9 +103,12 @@
       }
       fprintf (stderr, "\n");*/
       for (i=0;i<st->length;i++)
-         x[i] = st->window[i]*st->current_pcm[i-896];
+         x[i] = st->analysis_window[i]*st->current_pcm[i-896];
       //extract_sinusoids(x, wi, st->window, ai, bi, y, SINUSOIDS, st->length);
-      extract_modulated_sinusoids(x, wi, st->window, ai, bi, ci, di, y, nb_sinusoids, st->length);
+      extract_modulated_sinusoids(x, wi, st->analysis_window, ai, bi, ci, di, y, nb_sinusoids, st->length);
+      for (i=0;i<st->length;i++)
+         y[i] *= st->synthesis_window[i];
+
       /*for (i=0;i<st->length;i++)
       y[i] = x[i];*/
       short out[st->advance];

Modified: trunk/ghost/libghost/ghost.h
===================================================================
--- trunk/ghost/libghost/ghost.h	2006-01-16 17:22:38 UTC (rev 10731)
+++ trunk/ghost/libghost/ghost.h	2006-01-17 00:01:25 UTC (rev 10732)
@@ -26,7 +26,8 @@
 typedef struct {
    float *pcm_buf;
    float *current_pcm;
-   float *window;
+   float *analysis_window;
+   float *synthesis_window;
    float *big_window;
    float *syn_memory;
    int length;



More information about the commits mailing list