Added libspeex to revision control, and updated Makefile to use it.
This commit is contained in:
parent
b5eaa94d03
commit
7b4a796e44
103 changed files with 27657 additions and 24 deletions
53
code/libspeex/testecho.c
Normal file
53
code/libspeex/testecho.c
Normal file
|
@ -0,0 +1,53 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include "speex/speex_echo.h"
|
||||
#include "speex/speex_preprocess.h"
|
||||
|
||||
|
||||
#define NN 128
|
||||
#define TAIL 1024
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
FILE *echo_fd, *ref_fd, *e_fd;
|
||||
short echo_buf[NN], ref_buf[NN], e_buf[NN];
|
||||
SpeexEchoState *st;
|
||||
SpeexPreprocessState *den;
|
||||
int sampleRate = 8000;
|
||||
|
||||
if (argc != 4)
|
||||
{
|
||||
fprintf(stderr, "testecho mic_signal.sw speaker_signal.sw output.sw\n");
|
||||
exit(1);
|
||||
}
|
||||
echo_fd = fopen(argv[2], "rb");
|
||||
ref_fd = fopen(argv[1], "rb");
|
||||
e_fd = fopen(argv[3], "wb");
|
||||
|
||||
st = speex_echo_state_init(NN, TAIL);
|
||||
den = speex_preprocess_state_init(NN, sampleRate);
|
||||
speex_echo_ctl(st, SPEEX_ECHO_SET_SAMPLING_RATE, &sampleRate);
|
||||
speex_preprocess_ctl(den, SPEEX_PREPROCESS_SET_ECHO_STATE, st);
|
||||
|
||||
while (!feof(ref_fd) && !feof(echo_fd))
|
||||
{
|
||||
fread(ref_buf, sizeof(short), NN, ref_fd);
|
||||
fread(echo_buf, sizeof(short), NN, echo_fd);
|
||||
speex_echo_cancellation(st, ref_buf, echo_buf, e_buf);
|
||||
speex_preprocess_run(den, e_buf);
|
||||
fwrite(e_buf, sizeof(short), NN, e_fd);
|
||||
}
|
||||
speex_echo_state_destroy(st);
|
||||
speex_preprocess_state_destroy(den);
|
||||
fclose(e_fd);
|
||||
fclose(echo_fd);
|
||||
fclose(ref_fd);
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue