Godot FFT (Fast Fourier Transform)

An asset by tavurth
The page banner background of a mountain and forest
Godot FFT (Fast Fourier Transform) hero image

Quick Information

0 ratings
Godot FFT (Fast Fourier Transform) icon image
tavurth
Godot FFT (Fast Fourier Transform)

Fast Fourier Transform in GDScript

Supported Engine Version
4.0
Version String
0.1
License Version
MIT
Support Level
community
Modified Date
1 year ago
Git URL
Issue URL

README img

Table of Contents

  1. Installation
  2. Notes
  3. Reference
    1. Public methods
      1. FFT.fft(data: Array<float>) -> Array<Complex>
      2. FFT.ifft(data: Array<Complex>) -> Array<Complex>
      3. FFT.reals(data: Array<Complex>) -> Array<float>
      4. FFT.imags(data: Array<Complex>) -> Array<float>
      5. FFT.ensure_complex(data: Array<MaybeComplex>) -> Array<Complex>
    2. Internal methods
      1. FFT.conjugate(amplitudes: Array<Complex>) -> Array<Complex>
      2. FFT.keyed(data: Array<Dictionary>, key: String) -> Data<Any>

README img README img README img README img

Fast Fourier Transform in GDScript

Mostly modified from The javascript FFT on rosetta code.

Installation

  1. Install addon
  2. Enable plugin from the project-settings

The singleton FFT is autoloaded at your project start, so you can simply call the static functionality as shown below.

    var result = FFT.fft([1, 1, 1, 1, 0, 0, 0, 0])
    result = FFT.fft(result)

    for item in result:
        item.log()

Notes

This is an in-place modification for speed, so if you want to ensure functional purity you can duplicate your data array before passing it into the fft or ifft functionality. The data array is also returned.

    var my_arr = [1, 1, 1, 1, 0, 0, 0, 0]
    var result = FFT.fft(my_arr.duplicate(true))
    # my_arr remains unchanged

Reference

Public methods

FFT.fft(data: Array<float>) -> Array<Complex>

Forward transformation from data-space into fourier-space.

FFT.ifft(data: Array<Complex>) -> Array<Complex>

Reverse transformation from fourier-space into data-space.

FFT.reals(data: Array<Complex>) -> Array<float>

Returns the real part of each data point.

FFT.imags(data: Array<Complex>) -> Array<float>

Returns the imaginary part of each data point.

FFT.ensure_complex(data: Array<MaybeComplex>) -> Array<Complex>

Ensure that all data items in the array are Complex numbers.

Internal methods

FFT.conjugate(amplitudes: Array<Complex>) -> Array<Complex>

Flips the sign of each amplitude

FFT.keyed(data: Array<Dictionary>, key: String) -> Data<Any>

Returns data[idx][key] for each index.

Buy Me A Coffee

Fast Fourier Transform in GDScript

Reviews

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
Godot FFT (Fast Fourier Transform) icon image
tavurth
Godot FFT (Fast Fourier Transform)

Fast Fourier Transform in GDScript

Supported Engine Version
4.0
Version String
0.1
License Version
MIT
Support Level
community
Modified Date
1 year ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers