diff --git a/dnn/denoise.c b/dnn/denoise.c index 5b08bd27..db4d7c5f 100644 --- a/dnn/denoise.c +++ b/dnn/denoise.c @@ -305,7 +305,7 @@ int lowpass = FREQ_SIZE; int band_lp = NB_BANDS; #endif -static void frame_analysis(DenoiseState *st, float *lpc, kiss_fft_cpx *X, float *Ex, const float *in) { +static void frame_analysis(DenoiseState *st, signed char *iexc, float *lpc, kiss_fft_cpx *X, float *Ex, const float *in) { int i; float x[WINDOW_SIZE]; float x0[WINDOW_SIZE]; @@ -335,17 +335,21 @@ static void frame_analysis(DenoiseState *st, float *lpc, kiss_fft_cpx *X, float for(i=0;ipitch_buf, &st->pitch_buf[FRAME_SIZE], PITCH_BUF_SIZE-FRAME_SIZE); RNN_COPY(&st->pitch_buf[PITCH_BUF_SIZE-FRAME_SIZE], in, FRAME_SIZE); //pre[0] = &st->pitch_buf[0]; @@ -505,7 +509,7 @@ float rnnoise_process_frame(DenoiseState *st, float *out, const float *in) { static const float a_hp[2] = {-1.99599, 0.99600}; static const float b_hp[2] = {-2, 1}; biquad(x, st->mem_hp_x, in, b_hp, a_hp, FRAME_SIZE); - silence = compute_frame_features(st, X, P, Ex, Ep, Exp, features, x); + silence = compute_frame_features(st, NULL, X, P, Ex, Ep, Exp, features, x); if (!silence) { pitch_filter(X, P, Ex, Ep, Exp, g); @@ -549,13 +553,16 @@ int main(int argc, char **argv) { float mem_preemph=0; float x[FRAME_SIZE]; FILE *f1; + FILE *fexc; + signed char iexc[FRAME_SIZE]; DenoiseState *st; st = rnnoise_create(); - if (argc!=2) { - fprintf(stderr, "usage: %s \n", argv[0]); + if (argc!=3) { + fprintf(stderr, "usage: %s \n", argv[0]); return 1; } f1 = fopen(argv[1], "r"); + fexc = fopen(argv[2], "w"); while (1) { kiss_fft_cpx X[FREQ_SIZE], P[WINDOW_SIZE]; float Ex[NB_BANDS], Ep[NB_BANDS]; @@ -574,17 +581,17 @@ int main(int argc, char **argv) { biquad(x, mem_hp_x, x, b_hp, a_hp, FRAME_SIZE); preemphasis(x, &mem_preemph, x, PREEMPHASIS, FRAME_SIZE); - compute_frame_features(st, X, P, Ex, Ep, Exp, features, x); + compute_frame_features(st, iexc, X, P, Ex, Ep, Exp, features, x); pitch_filter(X, P, Ex, Ep, Exp, g); -#if 0 +#if 1 fwrite(features, sizeof(float), NB_FEATURES, stdout); - fwrite(g, sizeof(float), NB_BANDS, stdout); - fwrite(Ln, sizeof(float), NB_BANDS, stdout); + fwrite(iexc, sizeof(signed char), FRAME_SIZE, fexc); #endif count++; } //fprintf(stderr, "matrix size: %d x %d\n", count, NB_FEATURES + 2*NB_BANDS + 1); fclose(f1); + fclose(fexc); return 0; }