|
20 | 20 |
|
21 | 21 | #include <Arduino.h> |
22 | 22 |
|
23 | | -#define FFT_BIN(num, fs, size) (num*((float)fs/(float)size)) ///< return the center frequency of FFT bin 'num' based on the sample rate and FFT stize |
24 | | -#define FFT_INDEX(freq, fs, size) ((int)((float)freq/((float)fs/(float)size))) ///< return the bin index where the specified frequency 'freq' can be found based on the passed sample rate and FFT size |
| 23 | +#define FFT_BIN(num, fs, size) \ |
| 24 | + (num * \ |
| 25 | + ((float)fs / (float)size)) ///< return the center frequency of FFT bin 'num' |
| 26 | + ///< based on the sample rate and FFT stize |
| 27 | +#define FFT_INDEX(freq, fs, size) \ |
| 28 | + ((int)((float)freq / \ |
| 29 | + ((float)fs / \ |
| 30 | + (float)size))) ///< return the bin index where the specified frequency |
| 31 | + ///< 'freq' can be found based on the passed sample |
| 32 | + ///< rate and FFT size |
25 | 33 |
|
26 | 34 | #ifndef ALIGN4 |
27 | | -#define ALIGN4 __attribute__ ((aligned (4))) ///< align to 4 bytes |
| 35 | +#define ALIGN4 __attribute__((aligned(4))) ///< align to 4 bytes |
28 | 36 | #endif |
29 | 37 |
|
30 | 38 | #ifndef q15_t |
|
42 | 50 | #define ZERO_FFT_MAX 4096 ///< the maximum allowed FFT size |
43 | 51 |
|
44 | 52 | #ifdef __cplusplus |
45 | | -extern "C"{ |
| 53 | +extern "C" { |
46 | 54 | #endif // __cplusplus |
47 | 55 |
|
48 | 56 | /**************************************************************************/ |
49 | 57 | /*! |
50 | 58 | @brief run an FFT on an int16_t array. Note that this is run in place. |
51 | 59 | @param source the data to FFT |
52 | | - @param length the length of the data. This must be a power of 2 and less than or equal to ZERO_FFT_MAX |
| 60 | + @param length the length of the data. This must be a power of 2 and less |
| 61 | + than or equal to ZERO_FFT_MAX |
53 | 62 | @return 0 on success, -1 on failure |
54 | | - @note The FFT is run in place on the data. A hanning window is applied to the input data. The complex portion is discarded, and the real values are returned. |
| 63 | + @note The FFT is run in place on the data. A hanning window is applied to |
| 64 | + the input data. The complex portion is discarded, and the real values are |
| 65 | + returned. |
55 | 66 | */ |
56 | 67 | /**************************************************************************/ |
57 | 68 | extern int ZeroFFT(q15_t *source, uint16_t length); |
58 | 69 |
|
59 | | -extern const q15_t window_hanning_16[]; ///< a hanning window of length 16 |
60 | | -extern const q15_t window_hanning_32[]; ///< a hanning window of length 32 |
61 | | -extern const q15_t window_hanning_64[]; ///< a hanning window of length 64 |
62 | | -extern const q15_t window_hanning_128[]; ///< a hanning window of length 128 |
63 | | -extern const q15_t window_hanning_256[]; ///< a hanning window of length 256 |
64 | | -extern const q15_t window_hanning_512[]; ///< a hanning window of length 512 |
| 70 | +extern const q15_t window_hanning_16[]; ///< a hanning window of length 16 |
| 71 | +extern const q15_t window_hanning_32[]; ///< a hanning window of length 32 |
| 72 | +extern const q15_t window_hanning_64[]; ///< a hanning window of length 64 |
| 73 | +extern const q15_t window_hanning_128[]; ///< a hanning window of length 128 |
| 74 | +extern const q15_t window_hanning_256[]; ///< a hanning window of length 256 |
| 75 | +extern const q15_t window_hanning_512[]; ///< a hanning window of length 512 |
65 | 76 | extern const q15_t window_hanning_1024[]; ///< a hanning window of length 1024 |
66 | 77 | extern const q15_t window_hanning_2048[]; ///< a hanning window of length 2048 |
67 | 78 | extern const q15_t window_hanning_4096[]; ///< a hanning window of length 4096 |
|
0 commit comments