Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About real-time processing #47

Open
panhu opened this issue Sep 18, 2023 · 1 comment
Open

About real-time processing #47

panhu opened this issue Sep 18, 2023 · 1 comment

Comments

@panhu
Copy link

panhu commented Sep 18, 2023

Hi:
I would like to ask if I encountered a problem when I was about to perform real-time processing validation. I extracted 128 corresponding data from two. sw files and processed them for echo cancellation, resulting in very small values around 0, which is different from the results obtained using. sw files for processing.I don't know why this is happening.

Test code:

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

#include "speex/speex_echo.h"
#include "speex/speex_preprocess.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdint.h>

#define NN 128
#define TAIL 1024

int test(short echo_buf[], short ref_buf[],short e_buf[])
{
SpeexEchoState *st;
SpeexPreprocessState *den;
int sampleRate = 8000;

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);

speex_echo_cancellation(st, echo_buf,ref_buf,e_buf);
speex_preprocess_run(den,  e_buf);

speex_echo_state_destroy(st);
speex_preprocess_state_destroy(den);

return 0;

}

int main(){
short a[128] = {76, -112, -42, -66, -86, 38, 30 ,92, 143 ,36, -85, -58, -34, -54, -61, -111, 51, 156, 51, -90, -223, -23 ,88, 11, 46, -2, 8, -99, -74, 192, 22, -105, 12,
-83, 127 ,274 ,-42, 33, 9, -38 ,6, -129, 169, -103, -142 ,302, -168, -4 ,137 ,-280, 73, 124, -29 ,168 ,105, -64, -21, 52, -121, -78 ,67, -50 ,43, 70,
-1, -14 ,-36, 188, -94, -366, 64 ,23 ,2, 189, -2, 26, 46, -100, -43 ,-23 ,-45, -15 ,-38, 85,179, 32, -110, -64 ,26, 0 ,55, -50, -93, 81, -93, -35, 99, -61, -35 ,-67, 22 ,41,
-61 ,76, 5, -152, -19, 129, -91, 28 ,232, -42, 8, -45, -183 ,-45, -17, 11 ,110 ,76 ,-86, 66, -17, -163, 249 ,135, -65, 128};

short b[128] = {-1092, -763, -479, -240, -38, 127 ,257, 359, 739, -10479, 2663, 2441, 2334, 1977 ,1763, 1562 ,14560, -1441, -1316, -1183, -1051, -929, -812,
                -705, 4991, 11916, -4122, -3613 ,-3132, -2689, -2283, -1909, -1061, -1372, -1096, -848, -630, -404, -291, -154 ,7945, 5695, -2728, -2328, -1453,
                -1728, -1418, -1138, -98 -793 -637 -453 ,13756, 10566 ,-5255 -4545 -3888 -3246 -2746 -2249 -1804 -1394 -1073 -772 -6 -395 -199,
                -34, 278 ,-12222 ,2738, 2522, 3095, 1962, 1720 ,1532 ,1530, -11245, 3466, 3042, 2674, 2259, 1916 ,1605, 14580, -1578, -1506, -1415 ,-1314, -1215,
                -1109, -1005, -903 ,-769 ,-717, -624 ,-543 ,-463 ,-393, -326, 6837, 11898, -4132, -3624, 10099 ,-5351, -4645, -3984 ,9873, -5467, -4668,
                -3930, 9980, -5300 ,-4466, -3701, -3015, -2402, -1861, -1385, 1066, -997, -694, -399, -150, 7269, -1226, -927};

short c[128];

printf("\n");
for (int i=0;i<2;i++){
    
}
test(a,b,c);

for(int i =0;i<128;i++){
    printf("%d",c[i]);
    printf(" ");
}

}

@panhu
Copy link
Author

panhu commented Sep 19, 2023

As mentioned above, I have found that once using “speex_ preprocess_ run (den, e_buf)"; It will change the results to all values around 0 or 0, and not using it is good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant