Skip to content

ComplexFFTProcess

Traits

trait ComplexFFTProcessable

Implement this trait in a custom struct to pass to FFTProcess as a Parameter.

See TestFFTProcess.mojo for an example on how to create a spectral process using a struct that implements FFTProcessable.

ComplexFFTProcessable Required Methods

trait ComplexFFTProcessable . fn init

Create a new instance of the value by copying an existing one.

Signature

__init__(out self: _Self, *, copy: _Self)

Arguments

  • copy: _Self - The value to copy. Returns

Type: _Self


Create a new instance of the value by moving the value of another.

Signature

__init__(out self: _Self, *, deinit take: _Self)

Arguments

  • take: _Self - The value to move. Returns

Type: _Self


trait ComplexFFTProcessable . fn next_frame

Signature

next_frame(mut self: _Self, mut complex: List[ComplexSIMD[DType.float64, 1]])

Arguments

  • complex: List[ComplexSIMD[DType.float64, 1]]

Default Implementation

This method has a default implementation.


trait ComplexFFTProcessable . fn next_stereo_frame

Signature

next_stereo_frame(mut self: _Self, mut complex: List[ComplexSIMD[DType.float64, 2]])

Arguments

  • complex: List[ComplexSIMD[DType.float64, 2]]

Default Implementation

This method has a default implementation.


trait ComplexFFTProcessable . fn get_messages

Signature

get_messages(mut self: _Self)

Default Implementation

This method has a default implementation.


Structs

struct ComplexFFTProcess

Create an FFTProcess for audio manipulation in the frequency domain. This version will output and input complex frequency bins directly rather than magnitude and phase. This is currently untested.

Traits: AnyType, Copyable, ImplicitlyDestructible, Movable

ComplexFFTProcess Parameters

Name Type Default Description
T ComplexFFTProcessable A user defined struct that implements the FFTProcessable trait.
ifft Bool True A boolean specifying whether to perform an IFFT after processing in the frequency domain.
input_window_shape Int WindowType.hann Int specifying what window shape to use to modify the amplitude of the input samples before the FFT. See WindowType for the options.
output_window_shape Int WindowType.hann Int specifying what window shape to use to modify the amplitude of the output samples after the IFFT. See WindowType for the options.

ComplexFFTProcess Functions

struct ComplexFFTProcess . fn init

Initializes a FFTProcess struct.

fn init Signature

__init__(out self, world: UnsafePointer[MMMWorld, MutExternalOrigin], var process: T, window_size: Int, hop_size: Int)

fn init Arguments

Name Type Default Description
world UnsafePointer[MMMWorld, MutExternalOrigin] A pointer to the MMMWorld.
process T A user defined struct that implements the FFTProcessable trait.
window_size Int The size of the window to use for processing. This will determine how many samples are passed to the user defined struct's .next_window() method.
hop_size Int The number of samples between the beginning of FFT windows.

fn init Returns : Self An initialized FFTProcess struct.

Static Method

This is a static method.

struct ComplexFFTProcess . fn get_process

fn get_process Signature

get_process(mut self) -> ref[self.buffered_process.process.process] T

fn get_process Returns : ref[self.buffered_process.process.process] T

struct ComplexFFTProcess . fn next

Processes the next input sample and returns the next output sample.

fn next Signature

next(mut self, input: Float64) -> Float64

fn next Arguments

Name Type Default Description
input Float64 The next input sample to process.

fn next Returns : Float64 The next output sample.

struct ComplexFFTProcess . fn next_stereo

Processes the next stereo input sample and returns the next output sample.

fn next_stereo Signature

next_stereo(mut self, input: SIMD[DType.float64, 2]) -> SIMD[DType.float64, 2]

fn next_stereo Arguments

Name Type Default Description
input SIMD[DType.float64, 2] The next input samples to process.

fn next_stereo Returns : SIMD[DType.float64, 2] The next output samples.

struct ComplexFFTProcess . fn next_from_buffer

Returns the next output sample from the internal buffered process. The buffered process reads a block of samples from the provided buffer at the given phase and channel on each hop.

fn next_from_buffer Signature

next_from_buffer(mut self, ref buffer: SIMDBuffer[1], phase: Float64, chan: Int = 0) -> Float64

fn next_from_buffer Arguments

Name Type Default Description
buffer SIMDBuffer[1] The input buffer to read samples from.
phase Float64 The current phase to read from the buffer. Between 0 (beginning) and 1 (end).
chan Int 0 The channel to read from the buffer.

fn next_from_buffer Returns : Float64 The next output sample.

struct ComplexFFTProcess . fn next_from_stereo_buffer

Returns the next stereo output sample from the internal buffered process. The buffered process reads a block of samples from the provided buffer at the given phase and channel on each hop.

fn next_from_stereo_buffer Signature

next_from_stereo_buffer(mut self, ref buffer: SIMDBuffer, phase: Float64) -> SIMD[DType.float64, 2]

fn next_from_stereo_buffer Arguments

Name Type Default Description
buffer SIMDBuffer The input buffer to read samples from.
phase Float64 The current phase to read from the buffer. Between 0 (beginning) and 1 (end).

fn next_from_stereo_buffer Returns : SIMD[DType.float64, 2] The next stereo output sample.


Documentation generated with mojo doc from Mojo version 1.0.0b1