testdenoise.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifdef HAVE_CONFIG_H
  2. #include "config.h"
  3. #endif
  4. #include <speex/speex_preprocess.h>
  5. #include <stdio.h>
  6. #define NN 160
  7. int main()
  8. {
  9. short in[NN];
  10. int i;
  11. SpeexPreprocessState *st;
  12. int count=0;
  13. float f;
  14. st = speex_preprocess_state_init(NN, 8000);
  15. i=1;
  16. speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DENOISE, &i);
  17. i=0;
  18. speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_AGC, &i);
  19. i=8000;
  20. speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_AGC_LEVEL, &i);
  21. i=0;
  22. speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DEREVERB, &i);
  23. f=.0;
  24. speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DEREVERB_DECAY, &f);
  25. f=.0;
  26. speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &f);
  27. while (1)
  28. {
  29. int vad;
  30. fread(in, sizeof(short), NN, stdin);
  31. if (feof(stdin))
  32. break;
  33. vad = speex_preprocess_run(st, in);
  34. /*fprintf (stderr, "%d\n", vad);*/
  35. fwrite(in, sizeof(short), NN, stdout);
  36. count++;
  37. }
  38. speex_preprocess_state_destroy(st);
  39. return 0;
  40. }