Skip to content
Structs

struct Lag

A lag processor that smooths input values over time based on a specified lag time in seconds.

Traits: AnyType, Copyable, Movable, Representable, UnknownDestructibility

Lag Parameters

Name Type Description
N Int Number of SIMD channels to process in parallel.

Lag Functions

struct Lag . fn init

Initialize the lag processor with given lag time in seconds.

fn init Signature

__init__(out self, world: UnsafePointer[MMMWorld], lag: SIMD[DType.float64, N] = 0.02)

fn init Arguments

Name Type Default Description
world UnsafePointer Pointer to the MMMWorld.
lag SIMD 0.02 SIMD vector specifying lag time in seconds for each channel.

fn init Returns : Self None.

Static Method

This is a static method.

struct Lag . fn next

Process one sample through the lag processor.

fn next Signature

next(mut self, in_samp: SIMD[DType.float64, N]) -> SIMD[DType.float64, N]

fn next Arguments

Name Type Default Description
in_samp SIMD (SIMD[DType.float64, N]): Input SIMD vector of Float64 values.

fn next Returns : SIMD SIMD[DType.float64, N]: Output SIMD vector of Float64 values after applying the lag.

struct Lag . fn set_lag_time

Set a new lag time in seconds for each channel. None. fn set_lag_time Signature

set_lag_time(mut self, lag: SIMD[DType.float64, N])

fn set_lag_time Arguments

Name Type Default Description
lag SIMD SIMD vector specifying new lag time in seconds for each channel.

struct LagN

Traits: AnyType, Copyable, Movable, UnknownDestructibility

LagN Parameters

Name Type Description
lag Float64
N Int

LagN Functions

struct LagN . fn init

fn init Signature

__init__(out self, world: UnsafePointer[MMMWorld], lag_times: List[Float64])

fn init Arguments

Name Type Default Description
world UnsafePointer
lag_times List

fn init Returns : Self

Static Method

This is a static method.

struct LagN . fn next

fn next Signature

next(mut self, ref in_list: List[Float64], mut out_list: List[Float64])

fn next Arguments

Name Type Default Description
in_list List
out_list List

struct SVFModes

Traits: AnyType, UnknownDestructibility


struct SVF

State Variable Filter

Implementation from Andrew Simper. Translated from Oleg Nesterov's Faust implementation.

This struct enables many different types of filters (see below). To use any of them, they are all declared and initialized in the same way. Use the "convenience" functions for calling the different filter types. For example to create a lowpass filter:

# declare
var svf: SVF
...
# initialize
self.svf = SVF(world)
...
# use
output = self.svf.lpf(input,1000.0, 1.0)  # lowpass filter

Traits: AnyType, Copyable, Movable, Representable, UnknownDestructibility

SVF Parameters

Name Type Description
N Int Number of SIMD channels to process in parallel.

SVF Functions

struct SVF . fn init

Initialize the SVF.

fn init Signature

__init__(out self, world: UnsafePointer[MMMWorld])

fn init Arguments

Name Type Default Description
world UnsafePointer Pointer to the MMMWorld.

fn init Returns : Self None

Static Method

This is a static method.

struct SVF . fn reset

Reset internal state None fn reset Signature

reset(mut self)

struct SVF . fn lpf

Lowpass filter

fn lpf Signature

lpf(mut self, input: SIMD[DType.float64, N], frequency: SIMD[DType.float64, N], q: SIMD[DType.float64, N]) -> SIMD[DType.float64, N]

fn lpf Arguments

Name Type Default Description
input SIMD The input signal to process.
frequency SIMD The cutoff frequency of the lowpass filter.
q SIMD The resonance (Q factor) of the filter.

fn lpf Returns : SIMD The next sample of the filtered output.

struct SVF . fn bpf

Bandpass filter

fn bpf Signature

bpf(mut self, input: SIMD[DType.float64, N], frequency: SIMD[DType.float64, N], q: SIMD[DType.float64, N]) -> SIMD[DType.float64, N]

fn bpf Arguments

Name Type Default Description
input SIMD The input signal to process.
frequency SIMD The center frequency of the bandpass filter.
q SIMD The resonance (Q factor) of the filter.

fn bpf Returns : SIMD The next sample of the filtered output.

struct SVF . fn hpf

Highpass filter

fn hpf Signature

hpf(mut self, input: SIMD[DType.float64, N], frequency: SIMD[DType.float64, N], q: SIMD[DType.float64, N]) -> SIMD[DType.float64, N]

fn hpf Arguments

Name Type Default Description
input SIMD The input signal to process.
frequency SIMD The cutoff frequency of the highpass filter.
q SIMD The resonance (Q factor) of the filter.

fn hpf Returns : SIMD The next sample of the filtered output.

struct SVF . fn notch

Notch filter

fn notch Signature

notch(mut self, input: SIMD[DType.float64, N], frequency: SIMD[DType.float64, N], q: SIMD[DType.float64, N]) -> SIMD[DType.float64, N]

fn notch Arguments

Name Type Default Description
input SIMD The input signal to process.
frequency SIMD The center frequency of the notch filter.
q SIMD The resonance (Q factor) of the filter.

fn notch Returns : SIMD The next sample of the filtered output.

struct SVF . fn peak

Peak filter

fn peak Signature

peak(mut self, input: SIMD[DType.float64, N], frequency: SIMD[DType.float64, N], q: SIMD[DType.float64, N]) -> SIMD[DType.float64, N]

fn peak Arguments

Name Type Default Description
input SIMD The input signal to process.
frequency SIMD The center frequency of the peak filter.
q SIMD The resonance (Q factor) of the filter.

fn peak Returns : SIMD The next sample of the filtered output.

struct SVF . fn allpass

Allpass filter

fn allpass Signature

allpass(mut self, input: SIMD[DType.float64, N], frequency: SIMD[DType.float64, N], q: SIMD[DType.float64, N]) -> SIMD[DType.float64, N]

fn allpass Arguments

Name Type Default Description
input SIMD The input signal to process.
frequency SIMD The center frequency of the allpass filter.
q SIMD The resonance (Q factor) of the filter.

fn allpass Returns : SIMD The next sample of the filtered output.

struct SVF . fn bell

Bell filter (parametric EQ)

fn bell Signature

bell(mut self, input: SIMD[DType.float64, N], frequency: SIMD[DType.float64, N], q: SIMD[DType.float64, N], gain_db: SIMD[DType.float64, N]) -> SIMD[DType.float64, N]

fn bell Arguments

Name Type Default Description
input SIMD The input signal to process.
frequency SIMD The center frequency of the bell filter.
q SIMD The resonance (Q factor) of the filter.
gain_db SIMD The gain in decibels for the bell filter.

fn bell Returns : SIMD The next sample of the filtered output.

struct SVF . fn lowshelf

Low shelf filter

fn lowshelf Signature

lowshelf(mut self, input: SIMD[DType.float64, N], frequency: SIMD[DType.float64, N], q: SIMD[DType.float64, N], gain_db: SIMD[DType.float64, N]) -> SIMD[DType.float64, N]

fn lowshelf Arguments

Name Type Default Description
input SIMD The input signal to process.
frequency SIMD The cutoff frequency of the low shelf filter.
q SIMD The resonance (Q factor) of the filter.
gain_db SIMD The gain in decibels for the low shelf filter.

fn lowshelf Returns : SIMD The next sample of the filtered output.

struct SVF . fn highshelf

High shelf filter

fn highshelf Signature

highshelf(mut self, input: SIMD[DType.float64, N], frequency: SIMD[DType.float64, N], q: SIMD[DType.float64, N], gain_db: SIMD[DType.float64, N]) -> SIMD[DType.float64, N]

fn highshelf Arguments

Name Type Default Description
input SIMD The input signal to process.
frequency SIMD The cutoff frequency of the high shelf filter.
q SIMD The resonance (Q factor) of the filter.
gain_db SIMD The gain in decibels for the high shelf filter.

fn highshelf Returns : SIMD The next sample of the filtered output.

struct lpf_LR4

A 4th-order Linkwitz-Riley lowpass filter.

Linkwitz-Riley filters are commonly used for audio crossovers because they have a flat magnitude response when combining a high pass and low pass at the same cutoff frequency.

Traits: AnyType, Copyable, Movable, Representable, UnknownDestructibility

lpf_LR4 Parameters

Name Type Description
N Int Number of SIMD channels to process in parallel.

lpf_LR4 Functions

struct lpf_LR4 . fn init

Initialize the 4th-order Linkwitz-Riley lowpass filter

fn init Signature

__init__(out self, world: UnsafePointer[MMMWorld])

fn init Arguments

Name Type Default Description
world UnsafePointer Pointer to the MMMWorld.

fn init Returns : Self

Static Method

This is a static method.

struct lpf_LR4 . fn set_sample_rate

fn set_sample_rate Signature

set_sample_rate(mut self, sample_rate: Float64)

fn set_sample_rate Arguments

Name Type Default Description
sample_rate Float64

struct lpf_LR4 . fn next

A single sample through the 4th order Linkwitz-Riley lowpass filter.

fn next Signature

next(mut self, input: SIMD[DType.float64, N], frequency: SIMD[DType.float64, N]) -> SIMD[DType.float64, N]

fn next Arguments

Name Type Default Description
input SIMD The input sample to process.
frequency SIMD The cutoff frequency of the lowpass filter.

fn next Returns : SIMD The next sample of the filtered output.

struct OnePole

Simple one-pole IIR filter that can be configured as lowpass or highpass.

Traits: AnyType, Copyable, Movable, Representable, UnknownDestructibility

OnePole Parameters

Name Type Description
N Int Number of channels to process in parallel.

OnePole Functions

struct OnePole . fn init

Initialize the one-pole filter

fn init Signature

__init__(out self)

fn init Returns : Self

Static Method

This is a static method.

struct OnePole . fn next

Process one sample through the filter

fn next Signature

next(mut self, input: SIMD[DType.float64, N], coef: SIMD[DType.float64, N]) -> SIMD[DType.float64, N]

fn next Arguments

Name Type Default Description
input SIMD The input signal to process. Can be a SIMD vector for parallel processing.
coef SIMD The filter coefficient.

fn next Returns : SIMD The filtered output signal. Will be a SIMD vector if input is SIMD, otherwise a Float64.

struct DCTrap

DC Trap from Digital Sound Generation by Beat Frei.

Traits: AnyType, Copyable, Movable, Representable, UnknownDestructibility

DCTrap Parameters

Name Type Description
N Int Number of channels to process in parallel.

DCTrap Functions

struct DCTrap . fn init

Initialize the DC blocker filter.

fn init Signature

__init__(out self, world: UnsafePointer[MMMWorld])

fn init Arguments

Name Type Default Description
world UnsafePointer Pointer to the MMMWorld.

fn init Returns : Self

Static Method

This is a static method.

struct DCTrap . fn next

Process one sample through the DC blocker filter.

fn next Signature

next(mut self, input: SIMD[DType.float64, N]) -> SIMD[DType.float64, N]

fn next Arguments

Name Type Default Description
input SIMD The input signal to process.

fn next Returns : SIMD The next sample of the filtered output.

struct VAOnePole

One-pole filter based on the Virtual Analog design by Vadim Zavalishin in "The Art of VA Filter Design"

This implementation supports both lowpass and highpass modes.

Traits: AnyType, Copyable, Movable, Representable, UnknownDestructibility

VAOnePole Parameters

Name Type Description
N Int Number of channels to process in parallel.

VAOnePole Functions

struct VAOnePole . fn init

Initialize the VAOnePole filter.

fn init Signature

__init__(out self, world: UnsafePointer[MMMWorld])

fn init Arguments

Name Type Default Description
world UnsafePointer Pointer to the MMMWorld.

fn init Returns : Self

Static Method

This is a static method.

struct VAOnePole . fn lpf

Process one sample through the VA one-pole lowpass filter.

fn lpf Signature

lpf(mut self, input: SIMD[DType.float64, N], freq: SIMD[DType.float64, N]) -> SIMD[DType.float64, N]

fn lpf Arguments

Name Type Default Description
input SIMD The input signal to process.
freq SIMD The cutoff frequency of the lowpass filter.

fn lpf Returns : SIMD The next sample of the filtered output.

struct VAOnePole . fn hpf

Process one sample through the VA one-pole highpass filter.

fn hpf Signature

hpf(mut self, input: SIMD[DType.float64, N], freq: SIMD[DType.float64, N]) -> SIMD[DType.float64, N]

fn hpf Arguments

Name Type Default Description
input SIMD The input signal to process.
freq SIMD The cutoff frequency of the highpass filter.

fn hpf Returns : SIMD The next sample of the filtered output.

struct VAMoogLadder

Virtual Analog Moog Ladder Filter.

Implementation based on the Virtual Analog design by Vadim Zavalishin in "The Art of VA Filter Design"

This implementation supports 4-pole lowpass filtering with optional oversampling.

Traits: AnyType, Copyable, Movable, Representable, UnknownDestructibility

VAMoogLadder Parameters

Name Type Description
N Int Number of channels to process in parallel.
os_index Int Oversampling factor as a power of two (0 = no oversampling, 1 = 2x, 2 = 4x, etc.)

VAMoogLadder Functions

struct VAMoogLadder . fn init

Initialize the VAMoogLadder filter.

fn init Signature

__init__(out self, world: UnsafePointer[MMMWorld])

fn init Arguments

Name Type Default Description
world UnsafePointer Pointer to the MMMWorld.

fn init Returns : Self

Static Method

This is a static method.

struct VAMoogLadder . fn next

Process one sample through the Moog Ladder lowpass filter with optional oversampling.

fn next Signature

next(mut self, sig: SIMD[DType.float64, N], freq: SIMD[DType.float64, N], q_val: SIMD[DType.float64, N]) -> SIMD[DType.float64, N]

fn next Arguments

Name Type Default Description
sig SIMD The input signal to process.
freq SIMD The cutoff frequency of the lowpass filter.
q_val SIMD The resonance (Q factor) of the filter.

fn next Returns : SIMD The next sample of the filtered output.

struct Reson

Resonant filter with lowpass, highpass, and bandpass modes.

A translation of Julius Smith's Faust implementation of digital filters. Copyright (C) 2003-2019 by Julius O. Smith III jos@ccrma.stanford.edu

Traits: AnyType, Copyable, Movable, Representable, UnknownDestructibility

Reson Parameters

Name Type Description
N Int Number of SIMD channels to process in parallel.

Reson Functions

struct Reson . fn init

Initialize the Reson filter.

fn init Signature

__init__(out self, world: UnsafePointer[MMMWorld])

fn init Arguments

Name Type Default Description
world UnsafePointer Pointer to the MMMWorld.

fn init Returns : Self

Static Method

This is a static method.

struct Reson . fn lpf

Process input through a resonant lowpass filter.

fn lpf Signature

lpf(mut self: Reson[N], input: SIMD[DType.float64, N], freq: SIMD[DType.float64, N], q: SIMD[DType.float64, N], gain: SIMD[DType.float64, N]) -> SIMD[DType.float64, N]

fn lpf Arguments

Name Type Default Description
input SIMD The input signal to process.
freq SIMD The cutoff frequency of the lowpass filter.
q SIMD The resonance (Q factor) of the filter.
gain SIMD The output gain (clipped to 0.0-1.0 range).

fn lpf Returns : SIMD The next sample of the filtered output.

struct Reson . fn hpf

Process input through a resonant highpass filter.

fn hpf Signature

hpf(mut self: Reson[N], input: SIMD[DType.float64, N], freq: SIMD[DType.float64, N], q: SIMD[DType.float64, N], gain: SIMD[DType.float64, N]) -> SIMD[DType.float64, N]

fn hpf Arguments

Name Type Default Description
input SIMD The input signal to process.
freq SIMD The cutoff frequency of the highpass filter.
q SIMD The resonance (Q factor) of the filter.
gain SIMD The output gain (clipped to 0.0-1.0 range).

fn hpf Returns : SIMD The next sample of the filtered output.

struct Reson . fn bpf

Process input through a resonant bandpass filter.

fn bpf Signature

bpf(mut self: Reson[N], input: SIMD[DType.float64, N], freq: SIMD[DType.float64, N], q: SIMD[DType.float64, N], gain: SIMD[DType.float64, N]) -> SIMD[DType.float64, N]

fn bpf Arguments

Name Type Default Description
input SIMD The input signal to process.
freq SIMD The center frequency of the bandpass filter.
q SIMD The resonance (Q factor) of the filter.
gain SIMD The output gain (clipped to 0.0-1.0 range).

fn bpf Returns : SIMD The next sample of the filtered output.

struct FIR

Finite Impulse Response (FIR) filter implementation.

A translation of Julius Smith's Faust implementation of digital filters. Copyright (C) 2003-2019 by Julius O. Smith III jos@ccrma.stanford.edu

Traits: AnyType, Copyable, Movable, Representable, UnknownDestructibility

FIR Parameters

Name Type Description
N Int The number of SIMD channels to process.

FIR Functions

struct FIR . fn init

Initialize the FIR.

fn init Signature

__init__(out self, world: UnsafePointer[MMMWorld], num_coeffs: Int)

fn init Arguments

Name Type Default Description
world UnsafePointer Pointer to the MMMWorld.
num_coeffs Int

fn init Returns : Self

Static Method

This is a static method.

struct FIR . fn next

Compute the next output sample of the FIR filter.

fn next Signature

next(mut self: FIR[N], input: SIMD[DType.float64, N], coeffs: List[SIMD[DType.float64, N]]) -> SIMD[DType.float64, N]

fn next Arguments

Name Type Default Description
input SIMD The input signal to process.
coeffs List The filter coefficients.

fn next Returns : SIMD The next sample of the filtered output.

struct IIR

Infinite Impulse Response (IIR) filter implementation.

A translation of Julius Smith's Faust implementation of digital filters. Copyright (C) 2003-2019 by Julius O. Smith III jos@ccrma.stanford.edu

Traits: AnyType, Copyable, Movable, Representable, UnknownDestructibility

IIR Parameters

Name Type Description
N Int The number of SIMD channels to process.

IIR Functions

struct IIR . fn init

Initialize the IIR.

fn init Signature

__init__(out self, world: UnsafePointer[MMMWorld])

fn init Arguments

Name Type Default Description
world UnsafePointer Pointer to the MMMWorld.

fn init Returns : Self

Static Method

This is a static method.

struct IIR . fn next

Compute the next output sample of the IIR filter.

fn next Signature

next(mut self: IIR[N], input: SIMD[DType.float64, N], coeffsbv: List[SIMD[DType.float64, N]], coeffsav: List[SIMD[DType.float64, N]]) -> SIMD[DType.float64, N]

fn next Arguments

Name Type Default Description
input SIMD The input signal to process.
coeffsbv List The 'b' coefficients of the IIR filter.
coeffsav List The 'a' coefficients of the IIR filter.

fn next Returns : SIMD

struct tf2

Second-order transfer function filter implementation.

A translation of Julius Smith's Faust implementation of digital filters. Copyright (C) 2003-2019 by Julius O. Smith III jos@ccrma.stanford.edu

Traits: AnyType, Copyable, Movable, Representable, UnknownDestructibility

tf2 Parameters

Name Type Description
N Int The number of SIMD channels to process.

tf2 Functions

struct tf2 . fn init

Initialize the tf2 filter.

fn init Signature

__init__(out self, world: UnsafePointer[MMMWorld])

fn init Arguments

Name Type Default Description
world UnsafePointer Pointer to the MMMWorld.

fn init Returns : Self

Static Method

This is a static method.

struct tf2 . fn next

Process one sample through the second-order transfer function filter.

fn next Signature

next(mut self: tf2[N], input: SIMD[DType.float64, N], coeffs: List[SIMD[DType.float64, N]]) -> SIMD[DType.float64, N]

fn next Arguments

Name Type Default Description
input SIMD The input signal to process.
coeffs List List of filter coefficients.

fn next Returns : SIMD The next sample of the filtered output.

Functions

(Functions that are not associated with a Struct)

fn tf2s

A translation of Julius Smith's Faust implementation of digital filters. Copyright (C) 2003-2019 by Julius O. Smith III jos@ccrma.stanford.edu

None. Results are stored in coeffs_out.

Signature

tf2s[N: Int = 1](coeffs: List[SIMD[DType.float64, N]], mut coeffs_out: List[SIMD[DType.float64, N]], sample_rate: Float64)

Parameters

Name Type Description
N Int The number of SIMD channels to process.

Arguments

Name Type Default Description
coeffs List List containing analog coefficients [b2, b1, b0, a1, a0, w1] where
b coefficients are numerator, a coefficients are denominator,
and w1 is the angular frequency.
coeffs_out List Output list for digital coefficients [b0d, b1d, b2d, a1d, a2d].
sample_rate Float64 The sample rate in Hz.

Documentation generated with mojo doc from Mojo version 0.25.6.1