From 8da0033faf8dacd4a227d3fee5d98a64abcb9c4f Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Sat, 16 Mar 2013 15:38:21 -0500 Subject: [PATCH] src/pitch/pitchyinfft.c: simplify a bit, preparing for #7 --- src/pitch/pitchyinfft.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/pitch/pitchyinfft.c b/src/pitch/pitchyinfft.c index b627ef2c..d4e9905d 100644 --- a/src/pitch/pitchyinfft.c +++ b/src/pitch/pitchyinfft.c @@ -109,17 +109,14 @@ aubio_pitchyinfft_do (aubio_pitchyinfft_t * p, fvec_t * input, fvec_t * output) p->winput->data[l] = p->win->data[l] * input->data[l]; } aubio_fft_do (p->fft, p->winput, p->fftout); - for (l = 0; l < p->fftout->length; l++) { + p->sqrmag->data[0] = SQR (p->fftout->norm[0]); + p->sqrmag->data[0] *= p->weight->data[0]; + for (l = 1; l < p->fftout->length; l++) { p->sqrmag->data[l] = SQR (p->fftout->norm[l]); p->sqrmag->data[l] *= p->weight->data[l]; + p->sqrmag->data[p->sqrmag->length - l] = p->sqrmag->data[l]; } - for (l = 1; l < p->fftout->length; l++) { - p->sqrmag->data[(p->fftout->length - 1) * 2 - l] = - SQR (p->fftout->norm[l]); - p->sqrmag->data[(p->fftout->length - 1) * 2 - l] *= - p->weight->data[l]; - } - for (l = 0; l < p->sqrmag->length / 2 + 1; l++) { + for (l = 0; l < p->fftout->length; l++) { sum += p->sqrmag->data[l]; } sum *= 2.; -- 2.26.2