feat: hanning17

This commit is contained in:
liuyihui 2023-04-24 21:07:51 +08:00
parent f1348dd584
commit c0c2687135
3 changed files with 12 additions and 7 deletions

View File

@ -2,6 +2,7 @@
#include "fft.h" #include "fft.h"
extern const q15_t hanning_17[];
extern const q15_t hanning_160[]; extern const q15_t hanning_160[];
extern const uint16_t bitrevTable[]; extern const uint16_t bitrevTable[];

View File

@ -8,6 +8,8 @@
#define Re(x) 2 * x #define Re(x) 2 * x
#define Im(x) 2 * x + 1 #define Im(x) 2 * x + 1
static q15_t res[N * 2];
static inline void bitreversal(q31_t *data) { static inline void bitreversal(q31_t *data) {
q31_t tmp; q31_t tmp;
uint16_t n1 = N >> 1; uint16_t n1 = N >> 1;
@ -83,16 +85,14 @@ static inline void butterfly(q15_t *data) {
} }
int FFT(q15_t *data) { int FFT(q15_t *data) {
q15_t out[N * 2];
for (uint16_t i = 0; i < N; i++) { for (uint16_t i = 0; i < N; i++) {
out[Re(i)] = data[i]; // real res[Re(i)] = data[i]; // real
out[Im(i)] = 0; // imaginary res[Im(i)] = 0; // imaginary
} }
butterfly(out); butterfly(res);
bitreversal((q31_t *)out); bitreversal((q31_t *)res);
for (uint16_t i = 0; i < N; i++) data[i] = (q15_t)abs(out[2 * i]); for (uint16_t i = 0; i < N; i++) data[i] = (q15_t)abs(res[Re(i)]);
return 0; return 0;
} }

View File

@ -1,5 +1,9 @@
#include "fft/table.h" #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[] = { const q15_t hanning_160[] = {
0, 13, 51, 115, 204, 319, 458, 623, 812, 1025, 1263, 1524, 1808, 2115, 2444, 2795, 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, 3167, 3560, 3973, 4405, 4856, 5325, 5811, 6314, 6832, 7366, 7913, 8474, 9047, 9631, 10226, 10831,