From c0c2687135013a6d656bd98b92d9d09dd666dfdc Mon Sep 17 00:00:00 2001 From: liuyihui Date: Mon, 24 Apr 2023 21:07:51 +0800 Subject: [PATCH] feat: hanning17 --- include/fft/table.h | 1 + src/fft/fft.c | 14 +++++++------- src/fft/table.c | 4 ++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/fft/table.h b/include/fft/table.h index 855f04b..6a89254 100644 --- a/include/fft/table.h +++ b/include/fft/table.h @@ -2,6 +2,7 @@ #include "fft.h" +extern const q15_t hanning_17[]; extern const q15_t hanning_160[]; extern const uint16_t bitrevTable[]; diff --git a/src/fft/fft.c b/src/fft/fft.c index 1dcdefb..71d4f76 100644 --- a/src/fft/fft.c +++ b/src/fft/fft.c @@ -8,6 +8,8 @@ #define Re(x) 2 * x #define Im(x) 2 * x + 1 +static q15_t res[N * 2]; + static inline void bitreversal(q31_t *data) { q31_t tmp; uint16_t n1 = N >> 1; @@ -83,16 +85,14 @@ static inline void butterfly(q15_t *data) { } int FFT(q15_t *data) { - q15_t out[N * 2]; - for (uint16_t i = 0; i < N; i++) { - out[Re(i)] = data[i]; // real - out[Im(i)] = 0; // imaginary + res[Re(i)] = data[i]; // real + res[Im(i)] = 0; // imaginary } - butterfly(out); - bitreversal((q31_t *)out); - for (uint16_t i = 0; i < N; i++) data[i] = (q15_t)abs(out[2 * i]); + butterfly(res); + bitreversal((q31_t *)res); + for (uint16_t i = 0; i < N; i++) data[i] = (q15_t)abs(res[Re(i)]); return 0; } diff --git a/src/fft/table.c b/src/fft/table.c index 4cb20a8..142667d 100644 --- a/src/fft/table.c +++ b/src/fft/table.c @@ -1,5 +1,9 @@ #include "fft/table.h" +const q15_t hanning_17[] = { + 0, 1247, 4799, 10114, 16384, 22654, 27969, 31521, 32767, 31521, 27969, 22654, 16384, 10114, 4799, 1247, 0, +}; + const q15_t hanning_160[] = { 0, 13, 51, 115, 204, 319, 458, 623, 812, 1025, 1263, 1524, 1808, 2115, 2444, 2795, 3167, 3560, 3973, 4405, 4856, 5325, 5811, 6314, 6832, 7366, 7913, 8474, 9047, 9631, 10226, 10831,