summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--WasmAudio/main.c17
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();