Package wellen.analysis
Class FFT
java.lang.Object
wellen.analysis.FFT
Wrapper for calling a hopefully Fast Fourier transform. Makes it easy to switch FFT algorithm with minimal overhead.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
backwardsTransform
(float[] data) Computes inverse DFT.double
binToHz
(int binIndex, float sampleRate) void
forwardTransform
(float[] data) Computes forward DFT.void
modulus
(float[] data, float[] amplitudes) Calculates the the modulus for each element in data and stores the result in amplitudes.float
modulus
(float[] data, int index) Returns the modulus of the element at index bufferCount.void
powerAndPhaseFromFFT
(float[] data, float[] power, float[] phase) Returns magnitude (or power) and phase for the FFT transformed data.
-
Constructor Details
-
FFT
public FFT(int size) - Parameters:
size
- size of buffer
-
-
Method Details
-
forwardTransform
public void forwardTransform(float[] data) Computes forward DFT.- Parameters:
data
- data to transform.
-
backwardsTransform
public void backwardsTransform(float[] data) Computes inverse DFT.- Parameters:
data
- data to transform
-
binToHz
public double binToHz(int binIndex, float sampleRate) - Parameters:
binIndex
- index of the binsampleRate
- sample rate- Returns:
- frequency of bin in Hz
-
modulus
public float modulus(float[] data, int index) Returns the modulus of the element at index bufferCount. The modulus, magnitude or absolute value is (a²+b²) ^ 0.5 with a being the real part and b the imaginary part of a complex number.- Parameters:
data
- The FFT transformed data.index
- The index of the element.- Returns:
- The modulus, magnitude or absolute value of the element at index bufferCount
-
modulus
public void modulus(float[] data, float[] amplitudes) Calculates the the modulus for each element in data and stores the result in amplitudes.- Parameters:
data
- The input data.amplitudes
- The output modulus info or amplitude.
-
powerAndPhaseFromFFT
public void powerAndPhaseFromFFT(float[] data, float[] power, float[] phase) Returns magnitude (or power) and phase for the FFT transformed data.- Parameters:
data
- The FFT transformed data.power
- The array where the magnitudes or powers are going to be stored. It is half the length of data (FFT size).phase
- The array where the phases are going to be stored. It is half the length of data (FFT size).
-