-
Notifications
You must be signed in to change notification settings - Fork 159
- The object name is now capitalized and the constructor requires a floating-point data type, e.g. "ArduinoFFT" instead of "arduinoFFT".
- All function names are camelCase case now (start with lower-case character), e.g. "windowing()" instead of "Windowing()".
The number of samples MUST ALWAYS be a power of 2. Any other value will produce an infinite loop during the computing phase. Acceptable values are: 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384.
There is a bug causing an overflow when samples==2048
or samples==4096
and the dominant frequency is not properly detected. Don't use those values until further notice.
Simplest constructor possible. Returns an arduinoFFT object that will operate on arguments of the type T
where T
is either float
or double
.
This constructor was kept for backwards compatibility with and using it demands using the functions that at the very least receive the following parameters:
- Pointers to the data arrays of type
T
- Number of samples
- Sampling frequency
ArduinoFFT<T>(T *vReal, T *vImag, uint_fast16_t samples, T samplingFrequency, bool windowingFactors)
Returns an arduinoFFT object that will operate on arguments of the type T
where T
is either float
or double
.
-
vReal
Pointer to a data array of sizesamples
and typeT
where the integer part of the data is stored and will be processed. -
vImag
Pointer to a data array of sizesamples
and typeT
where the imaginary part of the data is stored and will be processed. -
samples
Size of the data array in number of elements. -
samplingFrequency
floating point value of typeT
indicating the frequency in Hz at which the data sampling was performed. -
windowingFactors
(optional) (Since v2.0) Boolean factor to enable internal storage of the windowing factors, streamlining subsequent windowing operations. Defaults to false.
Processes the computed data and calculates magnitudes from complex numbers. The output will overwrite the first half of the integer data array.
Processes the computed data and calculates magnitudes from complex numbers. The output will overwrite the first half of the integer data array.
-
vReal
Pointer to a data array of sizesamples
and typeT
where the integer part of the data is stored and will be processed. -
vImag
Pointer to a data array of sizesamples
and typeT
where the imaginary part of the data is stored and will be processed. -
samples
Size of the data array in number of elements.
Performs the Fast Fourier Transformation using the Cooley–Tukey algorithm.
-
dir
Direction on which to perform the transformation. Accepted values are FFTDirection::Forward or FFTDirection::Reverse
Performs the Fast Fourier Transformation using the Cooley–Tukey algorithm.
-
vReal
Pointer to a data array of sizesamples
and typeT
where the integer part of the data is stored and will be processed. -
vImag
Pointer to a data array of sizesamples
and typeT
where the imaginary part of the data is stored and will be processed. -
samples
Size of the data array in number of elements. -
dir
Direction on which to perform the transformation. Accepted values are FFTDirection::Forward or FFTDirection::Reverse
Performs the Fast Fourier Transformation using the Cooley–Tukey algorithm.
-
vReal
Pointer to a data array of sizesamples
and typeT
where the integer part of the data is stored and will be processed. -
vImag
Pointer to a data array of sizesamples
and typeT
where the imaginary part of the data is stored and will be processed. -
samples
Size of the data array in number of elements. -
power
Log base 2 ofsamples
. -
dir
Direction on which to perform the transformation. Accepted values are FFTDirection::Forward or FFTDirection::Reverse
Offsets the sampled signal so that it is centered around the X-axis of a plot, removing any DC offset that could have been present during sampling.
Offsets the sampled signal so that it is centered around the X-axis of a plot, removing any DC offset that could have been present during sampling. ** This is the version that must be used when using the simple constructor. **
-
vData
Pointer to a data array of sizesamples
and typeT
where the integer part of the data is stored and will be processed. -
samples
Size of the data array in number of elements.
Returns an estimation of the dominant frequency according to the interpolation of the biggest peak found on the magnitude array.
Computes an estimation of the dominant frequency through interpolation of the magnitude array and its magnitude in arbitrary units.
-
frequency
Pointer to a variable of typeT
where the interpolated frequency value will be stored. -
magnitude
Pointer to a variable of typeT
where the magnitude in arbitrary units will be stored.
Returns an estimation of the dominant frequency according to the interpolation of the biggest peak found on the magnitude array.
-
vData
Pointer to a data array of sizesamples
and typeT
where the integer part of the data is stored and will be processed. -
samples
Size of the data array in number of elements. -
samplingFrequency
floating point value of typeT
indicating the frequency in Hz at which the data sampling was performed.
Computes an estimation of the dominant frequency through interpolation of the magnitude array and its magnitude in arbitrary units.
-
vData
Pointer to a data array of sizesamples
and typeT
where the integer part of the data is stored and will be processed. -
samples
Size of the data array in number of elements. -
samplingFrequency
floating point value of typeT
indicating the frequency in Hz at which the data sampling was performed. -
frequency
Pointer to a variable of typeT
where the interpolated frequency value will be stored. -
magnitude
Pointer to a variable of typeT
where the magnitude in arbitrary units will be stored.
Returns an estimation of the dominant frequency according to interpolation through the parabola equation of the biggest peak found on the magnitude array.
Computes the interpolated frequency value of the biggest peak found on the magnitude array and its magnitude in arbitrary units using the parabola equation.
-
frequency
Pointer to a variable of typeT
where the interpolated frequency value will be stored. -
magnitude
Pointer to a variable of typeT
where the magnitude in arbitrary units will be stored.
Returns an estimation of the dominant frequency according to interpolation through the parabola equation of the biggest peak found on the magnitude array.
-
vData
Pointer to a data array of sizesamples
and typeT
where the integer part of the data is stored and will be processed. -
samples
Size of the data array in number of elements. -
samplingFrequency
floating point value of typeT
indicating the frequency in Hz at which the data sampling was performed.
void majorPeakParabola(T *vData, uint_fast16_t samples, T samplingFrequency, T *frequency, T *magnitude)
Computes the interpolated frequency value of the biggest peak found on the magnitude array and its magnitude in arbitrary units using the parabola equation.
-
vData
Pointer to a data array of sizesamples
and typeT
where the integer part of the data is stored and will be processed. -
samples
Size of the data array in number of elements. -
samplingFrequency
floating point value of typeT
indicating the frequency in Hz at which the data sampling was performed. -
frequency
Pointer to a variable of typeT
where the interpolated frequency value will be stored. -
magnitude
Pointer to a variable of typeT
where the magnitude in arbitrary units will be stored.
Performs a windowing operation on the data to give more or less weight to different data sections.
-
windowType
Which windowing operation should be performed on the data. Accepted values are:- FFTWindow::Rectangle
- FFTWindow::Hamming
- FFTWindow::Hann
- FFTWindow::Triangle
- FFTWindow::Nuttall
- FFTWindow::Blackman
- FFTWindow::Blackman_Nuttall
- FFTWindow::Blackman_Harris
- FFTWindow::Flat_top
- FFTWindow::Welch
-
dir
Direction on which to perform the windowing operation, aka apply/remove windowing factors. Accepted values are:- FFTDirection::Forward Apply the windowing.
- FFTDirection::Reverse Remove the windowing.
-
withCompensation
(optional) (Since v2.0) Boolean value regarding the use of compensation factors to correct how the signal is modified during windowing. Defaults to false.
void windowing(T *vData, uint_fast16_t samples, FFTWindow windowType, FFTDirection dir, T *windowingFactors, bool withCompensation)
Performs a windowing operation on the data to give more or less weight to different data sections.
-
windowType
Which windowing operation should be performed on the data. Accepted values are:- FFTWindow::Rectangle
- FFTWindow::Hamming
- FFTWindow::Hann
- FFTWindow::Triangle
- FFTWindow::Nuttall
- FFTWindow::Blackman
- FFTWindow::Blackman_Nuttall
- FFTWindow::Blackman_Harris
- FFTWindow::Flat_top
- FFTWindow::Welch
-
dir
Direction on which to perform the windowing operation, aka apply/remove windowing factors. Accepted values are:- FFTDirection::Forward Apply the windowing.
- FFTDirection::Reverse Remove the windowing.
-
withCompensation
(optional) (Since v2.0) Boolean value regarding the use of compensation factors to correct how the signal is modified during windowing. Defaults to false.
See Windowing for more information regarding the window types.
Returns the current revision of the arduinoFFT library with the format 0xMn where M is the mayor version number and n is the minor version number. For example 0x15 corresponds to version 1.5.
Replaces the internal data array pointers with new pointers.
-
vReal
Pointer to a data array of sizesamples
and typeT
where the integer part of the data is stored and will be processed. -
vImag
Pointer to a data array of sizesamples
and typeT
where the imaginary part of the data is stored and will be processed. -
samples
(optional) Size of the data array in number of elements. Only necessary if the number of elements has changed since object creation.