diff options
author | Arturs Artamonovs <arturs.artamonovs@protonmail.com> | 2021-07-28 08:46:42 +0100 |
---|---|---|
committer | Arturs Artamonovs <arturs.artamonovs@protonmail.com> | 2021-07-28 08:46:42 +0100 |
commit | 8d015dd123cd6a8d16e69283ef3616103a2b5fcf (patch) | |
tree | 8ac219129cd088310f56dd4732d3ea4b1c8b3512 /WasmAudio/main.c | |
parent | 6a725b5ac25e3cd4f7286d6071892432f52210af (diff) | |
download | WasmAudio-8d015dd123cd6a8d16e69283ef3616103a2b5fcf.tar.gz WasmAudio-8d015dd123cd6a8d16e69283ef3616103a2b5fcf.zip |
Update fir_filter
Diffstat (limited to 'WasmAudio/main.c')
-rw-r--r-- | WasmAudio/main.c | 17 |
1 files changed, 9 insertions, 8 deletions
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; n<ilength; n++) + for (n=0; n<ilength-fir->num_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; n<ilength; n++) { @@ -371,17 +371,17 @@ void fir_filter2(fir_t *fir, double *input, uint32_t ilength, double *output, ui output[n] = acc; } */ - for (i=0;i<ilength-fir->num_taps;i++) { + for (i=0;i<ilength-(fir->num_taps);i++) { acc = 0.0f; for (j=0;j<fir->num_taps;j++) { - acc = fir->fir_coef[j]*input[ilength-j-1]; + acc += fir->fir_coef[j]*input[ilength-j-1+i]; } if (i<olength) { output[i] = 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)); } 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(); |