Skip to content

Windows

Structs

struct Windows

Stores various window functions used in audio processing. This struct precomputes several common window types.

Traits: AnyType, Copyable, Movable, UnknownDestructibility


Windows Functions

struct Windows . fn init

fn init Signature

__init__(out self)

fn init Returns : Self

Static Method

This is a static method.

struct Windows . fn at_phase

Get window value at given phase (0.0 to 1.0) for specified window type.

fn at_phase Signature

at_phase[window_type: Int64, interp: Int = 0](self, world: UnsafePointer[MMMWorld], phase: Float64, prev_phase: Float64 = 0) -> Float64

fn at_phase Parameters

Name Type Default Description
window_type Int64
interp Int 0

fn at_phase Arguments

Name Type Default Description
world UnsafePointer
phase Float64
prev_phase Float64 0

fn at_phase Returns : Float64

struct Windows . fn make_window

Generate a window of specified type and size.

fn make_window Signature

make_window[window_type: Int](size: Int64, beta: Float64 = 5) -> List[Float64]

fn make_window Parameters

Name Type Default Description
window_type Int Type of window to generate. Use alias variables from WindowType struct (e.g. WindowType.hann).

fn make_window Arguments

Name Type Default Description
size Int64 Length of the window.
beta Float64 5 Shape parameter only used for Kaiser window. See kaiser_window() for details.

fn make_window Returns : List

Static Method

This is a static method.

Functions

(Functions that are not associated with a Struct)

fn rect_window

Generate a rectangular window of length size.

Signature

rect_window(size: Int64) -> List[Float64]

Arguments

Name Type Default Description
size Int64 Length of the window.

Returns

Type: List List containing the rectangular window values (all ones).

fn tri_window

Generate a triangular window of length size. Args: size: Length of the window. Returns: List containing the triangular window values.

Signature

tri_window(size: Int64) -> List[Float64]

Arguments

Name Type Default Description
size Int64

Returns

Type: List

fn bessel_i0

Calculate the modified Bessel function of the first kind, order 0 (I₀). Uses polynomial approximation for accurate results.

Signature

bessel_i0(x: Float64) -> Float64

Arguments

Name Type Default Description
x Float64 Input value.

Returns

Type: Float64 I₀(x).

fn kaiser_window

Create a Kaiser window of length n with shape parameter beta.

  • beta = 0: rectangular window.
  • beta = 5: similar to Hamming window.
  • beta = 6: similar to Hanning window.
  • beta = 8.6: similar to Blackman window.

Signature

kaiser_window(size: Int64, beta: Float64) -> List[Float64]

Arguments

Name Type Default Description
size Int64 Length of the window.
beta Float64 Shape parameter that controls the trade-off between main lobe width and side lobe level. See description for details.

Returns

Type: List List[Float64] containing the Kaiser window coefficients.

fn hann_window

Generate a Hann window of length size.

Signature

hann_window(size: Int64) -> List[Float64]

Arguments

Name Type Default Description
size Int64 Length of the window.

Returns

Type: List List containing the Hann window values.

fn hamming_window

Generate a Hamming window of length size.

Signature

hamming_window(size: Int64) -> List[Float64]

Arguments

Name Type Default Description
size Int64 Length of the window.

Returns

Type: List List containing the Hamming window values.

fn blackman_window

Generate a Blackman window of length size.

Signature

blackman_window(size: Int64) -> List[Float64]

Arguments

Name Type Default Description
size Int64 Length of the window.

Returns

Type: List List containing the Blackman window values.

fn sine_window

Generate a Sine window of length size.

Signature

sine_window(size: Int64) -> List[Float64]

Arguments

Name Type Default Description
size Int64 Length of the window.

Returns

Type: List List containing the Sine window values.

fn pan2_window

Generate a SIMD[DType.float64, 2] quarter cosine window for panning. The first element of the SIMD vector is the multiplier for the left channel, and the second element is for the right channel. This allows any sample to be panned at one of size positions between left and right channels smoothly.

Signature

pan2_window(size: Int64) -> List[SIMD[DType.float64, 2]]

Arguments

Name Type Default Description
size Int64 Length of the window.

Returns

Type: List List containing the quarter cosine window values.


Documentation generated with mojo doc from Mojo version 0.25.6.1