diff --git a/README.md b/README.md index 577684e..851bf39 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,10 @@ Performs a windowing function on the values array. The possible windowing option * FFT_WIN_TYP_HAMMING * FFT_WIN_TYP_HANN * FFT_WIN_TYP_TRIANGLE + * FFT_WIN_TYP_NUTTALL * FFT_WIN_TYP_BLACKMAN + * FFT_WIN_TYP_BLACKMAN_NUTTALL + * FFT_WIN_TYP_BLACKMAN_HARRIS * FFT_WIN_TYP_FLT_TOP * FFT_WIN_TYP_WELCH * **Exponent**(uint16_t value); diff --git a/keywords.txt b/keywords.txt index 7c2f303..3a25dd3 100644 --- a/keywords.txt +++ b/keywords.txt @@ -31,6 +31,9 @@ FFT_WIN_TYP_RECTANGLE LITERAL1 FFT_WIN_TYP_HAMMING LITERAL1 FFT_WIN_TYP_HANN LITERAL1 FFT_WIN_TYP_TRIANGLE LITERAL1 +FFT_WIN_TYP_NUTTALL LITERAL1 FFT_WIN_TYP_BLACKMAN LITERAL1 +FFT_WIN_TYP_BLACKMAN_NUTTALL LITERAL1 +FFT_WIN_TYP_BLACKMAN_HARRIS LITERAL1 FFT_WIN_TYP_FLT_TOP LITERAL1 FFT_WIN_TYP_WELCH LITERAL1 diff --git a/src/arduinoFFT.cpp b/src/arduinoFFT.cpp index 37d47d9..c44d4d9 100644 --- a/src/arduinoFFT.cpp +++ b/src/arduinoFFT.cpp @@ -199,9 +199,18 @@ void arduinoFFT::Windowing(uint8_t windowType, uint8_t dir) case FFT_WIN_TYP_TRIANGLE: // triangle (Bartlett) weighingFactor = 1.0 - ((2.0 * abs(indexMinusOne - (samplesMinusOne / 2.0))) / samplesMinusOne); break; - case FFT_WIN_TYP_BLACKMAN: // blackmann + case FFT_WIN_TYP_NUTTALL: // nuttall + weighingFactor = 0.355768 - (0.487396 * (cos(twoPi * ratio))) + (0.144232 * (cos(fourPi * ratio))) - (0.012604 * (cos(sixPi * ratio))); + break; + case FFT_WIN_TYP_BLACKMAN: // blackman weighingFactor = 0.42323 - (0.49755 * (cos(twoPi * ratio))) + (0.07922 * (cos(fourPi * ratio))); break; + case FFT_WIN_TYP_BLACKMAN_NUTTALL: // blackman nuttall + weighingFactor = 0.3635819 - (0.4891775 * (cos(twoPi * ratio))) + (0.1365995 * (cos(fourPi * ratio))) - (0.0106411 * (cos(sixPi * ratio))); + break; + case FFT_WIN_TYP_BLACKMAN_HARRIS: // blackman harris + weighingFactor = 0.35875 - (0.48829 * (cos(twoPi * ratio))) + (0.14128 * (cos(fourPi * ratio))) - (0.01168 * (cos(sixPi * ratio))); + break; case FFT_WIN_TYP_FLT_TOP: // flat top weighingFactor = 0.2810639 - (0.5208972 * cos(twoPi * ratio)) + (0.1980399 * cos(fourPi * ratio)); break; @@ -244,9 +253,18 @@ void arduinoFFT::Windowing(double *vData, uint16_t samples, uint8_t windowType, case FFT_WIN_TYP_TRIANGLE: // triangle (Bartlett) weighingFactor = 1.0 - ((2.0 * abs(indexMinusOne - (samplesMinusOne / 2.0))) / samplesMinusOne); break; - case FFT_WIN_TYP_BLACKMAN: // blackmann + case FFT_WIN_TYP_NUTTALL: // nuttall + weighingFactor = 0.355768 - (0.487396 * (cos(twoPi * ratio))) + (0.144232 * (cos(fourPi * ratio))) - (0.012604 * (cos(sixPi * ratio))); + break; + case FFT_WIN_TYP_BLACKMAN: // blackman weighingFactor = 0.42323 - (0.49755 * (cos(twoPi * ratio))) + (0.07922 * (cos(fourPi * ratio))); break; + case FFT_WIN_TYP_BLACKMAN_NUTTALL: // blackman nuttall + weighingFactor = 0.3635819 - (0.4891775 * (cos(twoPi * ratio))) + (0.1365995 * (cos(fourPi * ratio))) - (0.0106411 * (cos(sixPi * ratio))); + break; + case FFT_WIN_TYP_BLACKMAN_HARRIS: // blackman harris + weighingFactor = 0.35875 - (0.48829 * (cos(twoPi * ratio))) + (0.14128 * (cos(fourPi * ratio))) - (0.01168 * (cos(sixPi * ratio))); + break; case FFT_WIN_TYP_FLT_TOP: // flat top weighingFactor = 0.2810639 - (0.5208972 * cos(twoPi * ratio)) + (0.1980399 * cos(fourPi * ratio)); break; diff --git a/src/arduinoFFT.h b/src/arduinoFFT.h index e65eb17..3b8c203 100644 --- a/src/arduinoFFT.h +++ b/src/arduinoFFT.h @@ -48,12 +48,16 @@ #define FFT_WIN_TYP_HAMMING 0x01 /* hamming */ #define FFT_WIN_TYP_HANN 0x02 /* hann */ #define FFT_WIN_TYP_TRIANGLE 0x03 /* triangle (Bartlett) */ -#define FFT_WIN_TYP_BLACKMAN 0x04 /* blackmann */ -#define FFT_WIN_TYP_FLT_TOP 0x05 /* flat top */ -#define FFT_WIN_TYP_WELCH 0x06 /* welch */ +#define FFT_WIN_TYP_NUTTALL 0x04 /* nuttall */ +#define FFT_WIN_TYP_BLACKMAN 0x05 /* blackman */ +#define FFT_WIN_TYP_BLACKMAN_NUTTALL 0x06 /* blackman nuttall */ +#define FFT_WIN_TYP_BLACKMAN_HARRIS 0x07 /* blackman harris*/ +#define FFT_WIN_TYP_FLT_TOP 0x08 /* flat top */ +#define FFT_WIN_TYP_WELCH 0x09 /* welch */ /*Mathematial constants*/ #define twoPi 6.28318531 #define fourPi 12.56637061 +#define sixPi 18.84955593 class arduinoFFT { public: