From 3f86444151576bdea7ccbd5a3c146b22511ee275 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Tue, 15 Aug 2017 00:29:36 -0400 Subject: Wip (refactoring) --- src/denoise.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/denoise.c b/src/denoise.c index 9628a71..8530c2b 100644 --- a/src/denoise.c +++ b/src/denoise.c @@ -259,7 +259,7 @@ DenoiseState *rnnoise_create() { } -static int frame_analysis(DenoiseState *st, kiss_fft_cpx *X, float *Ex, float *features, const float *in) { +static int frame_analysis(DenoiseState *st, kiss_fft_cpx *X, kiss_fft_cpx *P, float *Ex, float *Ep, float *features, const float *in) { float x[WINDOW_SIZE]; int i; float E = 0; @@ -267,8 +267,7 @@ static int frame_analysis(DenoiseState *st, kiss_fft_cpx *X, float *Ex, float *f float spec_variability = 0; float Ly[NB_BANDS]; float p[WINDOW_SIZE]; - kiss_fft_cpx P[WINDOW_SIZE]; - float Ep[NB_BANDS], Exp[NB_BANDS]; + float Exp[NB_BANDS]; float pitch_buf[PITCH_BUF_SIZE>>1]; int pitch_index; float gain; @@ -280,6 +279,7 @@ static int frame_analysis(DenoiseState *st, kiss_fft_cpx *X, float *Ex, float *f apply_window(x); forward_transform(X, x); compute_band_energy(Ex, X); + if (features == NULL) return 1; RNN_MOVE(st->pitch_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]; @@ -299,7 +299,6 @@ static int frame_analysis(DenoiseState *st, kiss_fft_cpx *X, float *Ex, float *f compute_band_energy(Ep, P); compute_band_corr(Exp, X, P); for (i=0;imem_hp_x, in, b_hp, a_hp, FRAME_SIZE); - silence = frame_analysis(st, Y, Ey, features, x); + silence = frame_analysis(st, X, P, Ex, Ep, features, x); if (!silence) { compute_rnn(&st->rnn, g, &vad_prob, features); interp_band_gain(gf, g); #if 1 for (i=0;i 0) vad = 0.5f; else vad = 1.f; - frame_analysis(st, X, Ex, NULL, x); - frame_analysis(noise_state, N, En, NULL, n); + frame_analysis(st, X, NULL, Ex, NULL, NULL, x); + frame_analysis(noise_state, N, NULL, En, NULL, NULL, n); for (i=0;ilast_gain, noisy->last_period); for (i=0;i