Skip to content

SingUp009/Moderato.Mathematics.FFT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Moderato Logo - White

Moderato.Mathematics.FFT

Fast Fourier Transform (FFT) in Unity using Burst Compiler & C# Job System.

Table of Contents

Getting started

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);
}

Arguments

source : [Required]

float[] or double[] or System.Numerics.Complex[]
Input waveform.

Note

The length of the array need not be a power of 2.


window : [Optional]

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.


enableLowPassFilter : [Optional]

bool
Low-pass Filter.

Note

Default is false.


threshold : Optional

double
Low-pass filter threshold.

Note

[0, 1] Default is 0d. Also, this value is never read if enableLowPassFilter is false.


return

System.Numerics.Complex[]
Output Spectrum.

Important

The length of the array is half the next power of 2 of the source.

UPM Package

Install via git URL

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...

License

This library is under the MIT License.

About

Fast Fourier Transform (FFT) in Unity using Burst Compiler & C# Job System.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors