Skip to content

FFT

Structs

struct RealFFT

Real-valued FFT implementation using Cooley-Tukey algorithm.

If you're looking to create an FFT-based FX, look to the FFTProcessable trait used in conjunction with FFTProcess instead. This struct is a lower-level implementation that provides FFT and inverse FFT on fixed windows of real values. FFTProcessable structs will enable you to send audio samples (such as in a custom struct's .next() fn) into and out of an FFT, doing some manipulation of the magnitudes and phases in between. (FFTProcess has this RealFFT struct inside of it.)

Traits: AnyType, Copyable, Movable, UnknownDestructibility

RealFFT Parameters

Name Type Default Description
size Int 1024 Size of the FFT (must be a power of two).
num_chans Int 1 Number of channels for SIMD processing.

RealFFT Functions

struct RealFFT . fn init

Initialize the RealFFT struct. All internal buffers and lookup tables are set up here based on the Parameters. fn init Signature

__init__(out self)

fn init Returns : Self

Static Method

This is a static method.

struct RealFFT . fn fft

Compute the FFT of the input real-valued samples. The resulting magnitudes and phases are stored in the internal mags and phases lists.

fn fft Signature

fft(mut self, input: List[SIMD[DType.float64, num_chans]])

fn fft Arguments

Name Type Default Description
input List The input real-valued samples to transform. This can be a List of SIMD vectors for multi-channel processing or a List of Float64 for single-channel processing.

struct RealFFT . fn fft

Compute the FFT of the input real-valued samples. The resulting magnitudes and phases are stored in the provided lists.

fn fft Signature

fft(mut self, input: List[SIMD[DType.float64, num_chans]], mut mags: List[SIMD[DType.float64, num_chans]], mut phases: List[SIMD[DType.float64, num_chans]])

fn fft Arguments

Name Type Default Description
input List The input real-valued samples to transform. This can be a List of SIMD vectors for multi-channel processing or a List of Float64 for single-channel processing.
mags List A mutable list to store the magnitudes of the FFT result.
phases List A mutable list to store the phases of the FFT result.

struct RealFFT . fn ifft

Compute the inverse FFT using the internal magnitudes and phases. The output real-valued samples are written to the provided output list.

fn ifft Signature

ifft(mut self, mut output: List[SIMD[DType.float64, num_chans]])

fn ifft Arguments

Name Type Default Description
output List A mutable list to store the output real-valued samples.

struct RealFFT . fn ifft

Compute the inverse FFT using the provided magnitudes and phases. The output real-valued samples are written to the provided output list.

fn ifft Signature

ifft(mut self, mags: List[SIMD[DType.float64, num_chans]], phases: List[SIMD[DType.float64, num_chans]], mut output: List[SIMD[DType.float64, num_chans]])

fn ifft Arguments

Name Type Default Description
mags List A list of magnitudes for the inverse FFT.
phases List A list of phases for the inverse FFT.
output List A mutable list to store the output real-valued samples.

Documentation generated with mojo doc from Mojo version 0.25.6.1