From 8d015dd123cd6a8d16e69283ef3616103a2b5fcf Mon Sep 17 00:00:00 2001 From: Arturs Artamonovs Date: Wed, 28 Jul 2021 08:46:42 +0100 Subject: Update fir_filter --- WasmAudio/main.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'WasmAudio/main.c') diff --git a/WasmAudio/main.c b/WasmAudio/main.c index 5c9628a..6ee9f3b 100644 --- a/WasmAudio/main.c +++ b/WasmAudio/main.c @@ -329,9 +329,9 @@ void fir_filter(fir_t *fir, double *input, uint32_t ilength, double *output, uin int n; int k; - memcpy(&input[fir->num_taps-1], input, ilength*sizeof(double)); + memcpy(&input[fir->num_taps-1], input, (ilength-fir->num_taps)*sizeof(double)); - for (n=0; nnum_taps; n++) { coeffp = fir->fir_coef; inputp = &input[fir->num_taps - 1 + n]; @@ -345,7 +345,7 @@ void fir_filter(fir_t *fir, double *input, uint32_t ilength, double *output, uin output[n] = acc; } - memmove(&input[0], &input[ilength], (fir->num_taps-1)*sizeof(double)); + memmove(&input[0], &input[ilength-fir->num_taps], (fir->num_taps-1)*sizeof(double)); } #define MIN(x, y) (((x) < (y)) ? (x) : (y)) @@ -355,7 +355,7 @@ void fir_filter2(fir_t *fir, double *input, uint32_t ilength, double *output, ui double *inputp; int i,j; - //memcpy(&input[fir->num_taps-1], input, ilength*sizeof(double)); + memcpy(&input[fir->num_taps-1], input, (ilength-fir->num_taps)*sizeof(double)); /* for (n=0; nnum_taps;i++) { + for (i=0;inum_taps);i++) { acc = 0.0f; for (j=0;jnum_taps;j++) { - acc = fir->fir_coef[j]*input[ilength-j-1]; + acc += fir->fir_coef[j]*input[ilength-j-1+i]; } if (inum_taps-1)*sizeof(double)); + memmove(&input[0], &input[ilength-fir->num_taps], (fir->num_taps-1)*sizeof(double)); } uint32_t tick_start, tick_end,tick_1sec; @@ -453,8 +453,9 @@ int main_tick() { #if 1 fir_filter(&fir_lp, process_buf, PROCESS_BUF_SIZE, process_buf2, PROCESS_BUF_SIZE); + //fir_filter2(&fir_lp, process_buf, PROCESS_BUF_SIZE, process_buf2, PROCESS_BUF_SIZE); memcpy(process_buf,process_buf2,PROCESS_BUF_SIZE*sizeof(double)); - cut_up(); + //cut_up(); save_to_matlab("B2"); #endif convert_double_to_f32(); -- cgit v1.2.3