Fast Fourier Transform (FFT) in Unity using Burst Compiler & C# Job System.
Install via UPM package with git reference
using Moderato.Mathematics;
using System.Numerics;
void Hoge()
{
float[] array_float = new float[100];
double[] array_double = new double[100];
Complex[] array_Complex = new Complex[100];
Complex[] result = FFT.Transform(array_float);
Complex[] result = FFT.Transform(array_double);
Complex[] result = FFT.Transform(array_Complex);
Complex[] result = FFT.Transform(source: array_float, window: Window.Rectangular, enableLowPassFilter: true, threshold: 0.5);
}float[] or double[] or System.Numerics.Complex[]
Input waveform.
Note
The length of the array need not be a power of 2.
Moderato.Mathematics.Window
Window function.
- Rectangular:
$W[n] = 1.0$ . - Triangle:
$W[n] = 1.0 - |(2.0 * n / N)|$ . - Hamming:
$W[n] = 0.54 - 0.46 * \cos (2.0 * \pi * n / N)$ . - Hanning:
$W[n] = (1.0 - \cos (2.0 * \pi * n / N)) / 2.0$ . - Blackman:
$W[n] = 0.42 - ( \cos (2.0 * \pi * n / N) / 2.0) + (0.08 * \cos (4.0 * \pi * n / N))$ . - BlackmanHarris:
$W[n] = 0.35875 - (0.48829 * \cos (2.0 * \pi * n / N)) + (0.14128 * \cos (4.0 * \pi * n / N)) - (0.01168 * \cos (6.0 * \pi * n / N))$ .
Note
Default is Rectangular.
bool
Low-pass Filter.
Note
Default is false.
double
Low-pass filter threshold.
Note
[0, 1]
Default is 0d.
Also, this value is never read if enableLowPassFilter is false.
System.Numerics.Complex[]
Output Spectrum.
Important
The length of the array is half the next power of 2 of the source.
You can add https://github.com/SingUp009/Moderato.Mathematics.FFT.git?path=Assets/Moderato to Package Manager.
Package Manager: Window -> Package Manager -> Add package from git URL...
This library is under the MIT License.
