How can I use preprocessor standalone with a wav file?

"Alexander Lcd" <[email protected]>
Newsgroups gmane.comp.audio.compression.speex.devel
Message-ID <[email protected]>
I have been tyring to use the preprocessor standalone by feeding it pcm data from a headerless pcm file (mono, 22050hz) 
and then write the result to another file. Unfortunately, all I get back is noise (first frame is set to 0, rest is noise). 
Frame size is set to 440. 

I just modified testdenoise.c slightly to read/write from a file (see below) but I can't get useful results. What am I doing wrong? Do I need to perform additional initializations? 

I am using 1.2rc1, target platform is windows (using Visual Studio).

Thank you for your help. 

-----------------   Modified version of testdenoise.c   ----------------------

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <speex/speex_preprocess.h>
#include <stdio.h>

#define NN 440

int main()
{
   short in[NN];
   int i;
   SpeexPreprocessState *st;
   int count=0;
   float f;

   char *inFile = "C:\\Temp\\in.wav"; //.wav file containing only pcm data, no header info
   int close_in=0;
   char *outFile= "C:\\Temp\\out.wav"; 
   FILE *fin, *fout=NULL;

   fin = fopen(inFile, "rb");
      if (!fin)
      {
         perror(inFile);
         exit(1);
      }
   close_in=1;

   fout = fopen(outFile, "wb");
   if (!fout)
   {
      perror(outFile);
	  if (close_in == 1)
		  fclose(fin);
      exit(1);
   }

   st = speex_preprocess_state_init(NN, 22050);
   
   i=1;
   speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_AGC, &i);   //enabling AGC; denoise is enabled by default
   i=8000;
   speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_AGC_LEVEL, &i);   

   while (1)
   {
      int vad;
      fread(in, sizeof(short), NN, fin);
      if (feof(fin)) 
         break;
      vad = speex_preprocess_run(st, in);
       fwrite(in, sizeof(short), NN, fout);
      count++;
   }
   speex_preprocess_state_destroy(st);

   fclose(fin);
   fclose(fout);

   return 0;
}

-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.