Skip to content

Filters

Structs

struct Lag

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

Traits: AnyType, Copyable, ImplicitlyDeletable, Movable

Lag Parameters

Name Type Default Description
num_chans Int 1 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

def __init__(out self, world: UnsafePointer[MMMWorld, MutUntrackedOrigin], lag_time: SIMD[DType.float64, num_chans] = 0.02)

fn init Arguments

Name Type Default Description
world UnsafePointer[MMMWorld, MutUntrackedOrigin] Pointer to the MMMWorld.
lag_time SIMD[DType.float64, num_chans] 0.02 SIMD vector specifying lag time in seconds for each channel.

fn init Returns : Self

Static Method

This is a static method.

struct Lag . fn init

Initialize the lag processor with given lag time in seconds.

fn init Signature

def __init__(out self, sr: Float64, lag_time: SIMD[DType.float64, num_chans] = 0.02)

fn init Arguments

Name Type Default Description
sr Float64 Sample rate in Hz.
lag_time SIMD[DType.float64, num_chans] 0.02 SIMD vector specifying lag time in seconds for each channel.

fn init Returns : Self

Static Method

This is a static method.

struct Lag . fn next

Process one sample through the lag processor.

fn next Signature

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

fn next Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] Input SIMD vector values.

fn next Returns : SIMD[DType.float64, num_chans] Output values after applying the lag.

struct Lag . fn next

Process one sample through the lag processor. This version does not take an input argument and instead uses the last value set in self.input.

fn next Signature

def next(mut self) -> SIMD[DType.float64, num_chans]

fn next Returns : SIMD[DType.float64, num_chans] Output values after applying the lag.

struct Lag . fn set_lag_time

Set a new lag time in seconds for each channel.

fn set_lag_time Signature

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

fn set_lag_time Arguments

Name Type Default Description
lag SIMD[DType.float64, num_chans] SIMD vector specifying new lag time in seconds for each channel.

struct Lags

A convenience struct for processing a list of lags (which are processed in parallel using SIMD). The number of lags is determined at compile time by the num_lags parameter. The outputs of the lags can be accessed using the [] operator, just like accessing values in a List: lags[0].

Traits: AnyType, Copyable, ImplicitlyDeletable, Movable

Lags Parameters

Name Type Default Description
num_lags Int The total number of lags.

Lags Functions

struct Lags . fn init

fn init Signature

def __init__(out self, world: UnsafePointer[MMMWorld, MutUntrackedOrigin], lag_time: Float64)

fn init Arguments

Name Type Default Description
world UnsafePointer[MMMWorld, MutUntrackedOrigin]
lag_time Float64

fn init Returns : Self

Static Method

This is a static method.

struct Lags . fn init

fn init Signature

def __init__(out self, sr: Float64, lag_time: Float64)

fn init Arguments

Name Type Default Description
sr Float64
lag_time Float64

fn init Returns : Self

Static Method

This is a static method.

struct Lags . fn getitem

fn getitem Signature

def __getitem__(self, idx: Int) -> Float64

fn getitem Arguments

Name Type Default Description
idx Int

fn getitem Returns : Float64

struct Lags . fn setitem

fn setitem Signature

def __setitem__(mut self, idx: Int, value: Float64)

fn setitem Arguments

Name Type Default Description
idx Int
value Float64

struct Lags . fn next

Process a Span (List or InlineArray) of Floats through the lags.

fn next Signature

def next(mut self, vals: Span[Float64])

fn next Arguments

Name Type Default Description
vals Span[Float64] Input values whose length should match num_lags.

struct Lags . fn set_lag_time

Set a new lag time in seconds for all lags.

fn set_lag_time Signature

def set_lag_time(mut self, lag: Float64)

fn set_lag_time Arguments

Name Type Default Description
lag Float64 New lag time in seconds.

struct LagUD

A lag processor with separate lag times for rising (up) and falling (down) values.

Traits: AnyType, Copyable, ImplicitlyDeletable, Movable

LagUD Parameters

Name Type Default Description
num_chans Int 1 Number of SIMD channels to process in parallel.

LagUD Functions

struct LagUD . fn init

Initialize the lag processor with separate up/down lag times in seconds.

fn init Signature

def __init__(out self, world: UnsafePointer[MMMWorld, MutUntrackedOrigin], lag_up: SIMD[DType.float64, num_chans] = 0.02, lag_down: SIMD[DType.float64, num_chans] = 0.02)

fn init Arguments

Name Type Default Description
world UnsafePointer[MMMWorld, MutUntrackedOrigin] Pointer to the MMMWorld.
lag_up SIMD[DType.float64, num_chans] 0.02 SIMD vector specifying lag time in seconds for rising values.
lag_down SIMD[DType.float64, num_chans] 0.02 SIMD vector specifying lag time in seconds for falling values.

fn init Returns : Self

Static Method

This is a static method.

struct LagUD . fn next

Process one sample through the lag processor.

fn next Signature

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

fn next Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] Input SIMD vector values.

fn next Returns : SIMD[DType.float64, num_chans] Output values after applying the appropriate lag.

struct LagUD . fn next

Process one sample through the lag processor. This version does not take an input argument and instead uses the last value set in self.input.

fn next Signature

def next(mut self) -> SIMD[DType.float64, num_chans]

fn next Returns : SIMD[DType.float64, num_chans] Output values after applying the appropriate lag.

struct LagUD . fn set_lag_times

Set new lag times in seconds for rising and falling values.

fn set_lag_times Signature

def set_lag_times(mut self, lag_up: SIMD[DType.float64, num_chans], lag_down: SIMD[DType.float64, num_chans])

fn set_lag_times Arguments

Name Type Default Description
lag_up SIMD[DType.float64, num_chans] SIMD vector specifying lag time in seconds for rising values.
lag_down SIMD[DType.float64, num_chans] SIMD vector specifying lag time in seconds for falling values.

struct FilterType

Enumeration of different State Variable Filter modes.

This makes specifying a filter type more readable. For example, to specify a lowpass filter, use FilterType.lowpass.

Mode Value
lowpass 0
bandpass 1
highpass 2
notch 3
peak 4
bell 5
allpass 6
lowshelf 7
highshelf 8

Traits: AnyType, Copyable, Equatable, ImplicitlyCopyable, ImplicitlyDeletable, Movable


struct SVF

A State Variable Filter struct.

To use the different modes, see the mode-specific methods.

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

Traits: AnyType, Copyable, ImplicitlyDeletable, Movable, PolyReset

SVF Parameters

Name Type Default Description
num_chans Int 1 Number of SIMD channels to process in parallel.

SVF Functions

struct SVF . fn init

Initialize the SVF.

fn init Signature

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

fn init Arguments

Name Type Default Description
world UnsafePointer[MMMWorld, MutUntrackedOrigin] Pointer to the MMMWorld.

fn init Returns : Self

Static Method

This is a static method.

struct SVF . fn reset

Clears any leftover internal state so the filter starts clean after interruptions or discontinuities in the audio stream.

fn reset Signature

def reset(mut self)

struct SVF . fn lpf

Process input through a SVF lowpass filter. Passes frequencies below the cutoff while attenuating frequencies above it.

fn lpf Signature

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

fn lpf Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
frequency SIMD[DType.float64, num_chans] The cutoff frequency of the lowpass filter.
q SIMD[DType.float64, num_chans] The resonance of the filter.

fn lpf Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct SVF . fn bpf

Process input through a SVF bandpass filter. Passes a band of frequencies centered at the cutoff while attenuating frequencies above and below.

fn bpf Signature

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

fn bpf Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
frequency SIMD[DType.float64, num_chans] The center frequency of the bandpass filter.
q SIMD[DType.float64, num_chans] The bandwidth of the filter. Higher numbers == narrower filter.

fn bpf Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct SVF . fn hpf

Process input through a SVF highpass filter. Passes frequencies above the cutoff while attenuating frequencies below it.

fn hpf Signature

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

fn hpf Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
frequency SIMD[DType.float64, num_chans] The cutoff frequency of the highpass filter.
q SIMD[DType.float64, num_chans] The resonance of the filter.

fn hpf Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct SVF . fn peak

Process input through a SVF peak filter. Boosts or cuts a band of frequencies centered at the cutoff by an amount determined by q, leaving frequencies outside the band unaffected.

fn peak Signature

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

fn peak Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
frequency SIMD[DType.float64, num_chans] The center frequency of the peak filter.
q SIMD[DType.float64, num_chans] The resonance of the filter.

fn peak Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct SVF . fn notch

Process input through a SVF notch (band stop) filter. Attenuates a narrow band of frequencies centered at the cutoff while passing all others.

fn notch Signature

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

fn notch Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
frequency SIMD[DType.float64, num_chans] The center frequency of the notch filter.
q SIMD[DType.float64, num_chans] The resonance of the filter.

fn notch Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct SVF . fn allpass

Process input through a SVF allpass filter. Passes all frequencies at equal amplitude while shifting their phase relationship around the cutoff frequency.

fn allpass Signature

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

fn allpass Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
frequency SIMD[DType.float64, num_chans] The center frequency of the allpass filter.
q SIMD[DType.float64, num_chans] The resonance of the filter.

fn allpass Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct SVF . fn bell

Process input through a SVF bell (peaking EQ) filter. Boosts or cuts a band of frequencies centered at the cutoff by a specified gain amount, leaving frequencies outside the band unaffected.

fn bell Signature

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

fn bell Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
frequency SIMD[DType.float64, num_chans] The center frequency of the bell filter.
q SIMD[DType.float64, num_chans] The resonance of the filter.
gain_db SIMD[DType.float64, num_chans] The amount to boost/cut around the cutoff.

fn bell Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct SVF . fn lowshelf

Process input through a SVF lowshelf filter. Boosts or cuts all frequencies below the cutoff by a specified gain amount, leaving frequencies above unaffected.

fn lowshelf Signature

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

fn lowshelf Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
frequency SIMD[DType.float64, num_chans] The cutoff frequency of the low shelf filter.
q SIMD[DType.float64, num_chans] The resonance of the filter.
gain_db SIMD[DType.float64, num_chans] The amount to boost/cut around the cutoff.

fn lowshelf Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct SVF . fn highshelf

Process input through a SVF highshelf filter. Boosts or cuts all frequencies above the cutoff by a specified gain amount, leaving frequencies below unaffected.

fn highshelf Signature

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

fn highshelf Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
frequency SIMD[DType.float64, num_chans] The cutoff frequency of the high shelf filter.
q SIMD[DType.float64, num_chans] The resonance of the filter.
gain_db SIMD[DType.float64, num_chans] The amount to boost/cut around the cutoff.

fn highshelf Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct lpf_LR4

A 4th-order Linkwitz-Riley lowpass filter.

Traits: AnyType, Copyable, ImplicitlyDeletable, Movable

lpf_LR4 Parameters

Name Type Default Description
num_chans Int 1 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

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

fn init Arguments

Name Type Default Description
world UnsafePointer[MMMWorld, MutUntrackedOrigin] Pointer to the MMMWorld.

fn init Returns : Self

Static Method

This is a static method.

struct lpf_LR4 . fn next

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

fn next Signature

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

fn next Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input sample to process.
frequency SIMD[DType.float64, num_chans] The cutoff frequency of the lowpass filter.

fn next Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct OnePole

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

Traits: AnyType, Copyable, ImplicitlyDeletable, Movable, PolyReset

OnePole Parameters

Name Type Default Description
num_chans Int 1 Number of channels to process in parallel.

OnePole Functions

struct OnePole . fn init

Initialize the one-pole filter.

fn init Signature

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

fn init Arguments

Name Type Default Description
world UnsafePointer[MMMWorld, MutUntrackedOrigin] Pointer to the MMMWorld.

fn init Returns : Self

Static Method

This is a static method.

struct OnePole . fn lpf

Process one sample through the one-pole lowpass filter with a given cutoff frequency.

fn lpf Signature

def lpf(mut self, input: SIMD[DType.float64, num_chans], cutoff_hz: SIMD[DType.float64, num_chans]) -> SIMD[DType.float64, num_chans]

fn lpf Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
cutoff_hz SIMD[DType.float64, num_chans] The cutoff frequency of the lowpass filter.

fn lpf Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct OnePole . fn hpf

Process one sample through the one-pole highpass filter with a given cutoff frequency.

fn hpf Signature

def hpf(mut self, input: SIMD[DType.float64, num_chans], cutoff_hz: SIMD[DType.float64, num_chans]) -> SIMD[DType.float64, num_chans]

fn hpf Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
cutoff_hz SIMD[DType.float64, num_chans] The cutoff frequency of the highpass filter.

fn hpf Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct OnePole . fn reset

Reset the one-pole filter to its initial state.

fn reset Signature

def reset(mut self)

struct Amplitude

An amplitude tracker that smooths the absolute value of an input signal over time based on specified attack and release times.

Traits: AnyType, Copyable, ImplicitlyDeletable, Movable

Amplitude Parameters

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

Amplitude Functions

struct Amplitude . fn init

fn init Signature

def __init__(out self, world: UnsafePointer[MMMWorld, MutUntrackedOrigin], attack_time: SIMD[DType.float64, num_chans] = 0.10000000000000001, release_time: SIMD[DType.float64, num_chans] = 0.10000000000000001)

fn init Arguments

Name Type Default Description
world UnsafePointer[MMMWorld, MutUntrackedOrigin]
attack_time SIMD[DType.float64, num_chans] 0.10000000000000001
release_time SIMD[DType.float64, num_chans] 0.10000000000000001

fn init Returns : Self

Static Method

This is a static method.

struct Amplitude . fn set_params

Adjust the attack and release time of the Amplitude tracker.

fn set_params Signature

def set_params(mut self, attack_time: SIMD[DType.float64, num_chans], release_time: SIMD[DType.float64, num_chans])

fn set_params Arguments

Name Type Default Description
attack_time SIMD[DType.float64, num_chans] Attack time of the Amplitude function.
release_time SIMD[DType.float64, num_chans] Release time of the Amplitude function.

struct Amplitude . fn next

Process one sample through the Amplitude tracker.

fn next Signature

def next(mut self, sample: SIMD[DType.float64, num_chans]) -> SIMD[DType.float64, num_chans]

fn next Arguments

Name Type Default Description
sample SIMD[DType.float64, num_chans] The input signal to process.

fn next Returns : SIMD[DType.float64, num_chans] The next sample of the amplitude-tracked output.

struct DCTrap

DC Trap filter.

Implementation from Digital Sound Generation by Beat Frei. The cutoff frequency of the highpass filter is fixed to 5 Hz.

Traits: AnyType, Copyable, ImplicitlyDeletable, Movable, PolyReset

DCTrap Parameters

Name Type Default Description
num_chans Int 1 Number of channels to process in parallel.

DCTrap Functions

struct DCTrap . fn init

Initialize the DC blocker filter.

fn init Signature

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

fn init Arguments

Name Type Default Description
world UnsafePointer[MMMWorld, MutUntrackedOrigin] Pointer to the MMMWorld.

fn init Returns : Self

Static Method

This is a static method.

struct DCTrap . fn reset

Reset the DC blocker filter to its initial state.

fn reset Signature

def reset(mut self)

struct DCTrap . fn next

Process one sample through the DC blocker filter.

fn next Signature

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

fn next Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.

fn next Returns : SIMD[DType.float64, num_chans] 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, ImplicitlyDeletable, Movable, PolyReset

VAOnePole Parameters

Name Type Default Description
num_chans Int 1 Number of channels to process in parallel.

VAOnePole Functions

struct VAOnePole . fn init

Initialize the VAOnePole filter.

fn init Signature

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

fn init Arguments

Name Type Default Description
world UnsafePointer[MMMWorld, MutUntrackedOrigin] 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

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

fn lpf Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
freq SIMD[DType.float64, num_chans] The cutoff frequency of the lowpass filter.

fn lpf Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct VAOnePole . fn hpf

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

fn hpf Signature

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

fn hpf Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
freq SIMD[DType.float64, num_chans] The cutoff frequency of the highpass filter.

fn hpf Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct VAOnePole . fn reset

Clears filter's internal state.

fn reset Signature

def reset(mut self)

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 oversampler.

Traits: AnyType, Copyable, ImplicitlyDeletable, Movable, PolyReset

VAMoogLadder Parameters

Name Type Default Description
num_chans Int 1 Number of channels to process in parallel.
ov_samp TimesOversampling TimesOversampling.none An oversampler struct to indicate times oversampler.

VAMoogLadder Functions

struct VAMoogLadder . fn init

Initialize the VAMoogLadder filter.

fn init Signature

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

fn init Arguments

Name Type Default Description
world UnsafePointer[MMMWorld, MutUntrackedOrigin] Pointer to the MMMWorld.

fn init Returns : Self

Static Method

This is a static method.

struct VAMoogLadder . fn reset

Clears filter's internal state.

fn reset Signature

def reset(mut self)

struct VAMoogLadder . fn next

Process one sample through the Moog Ladder lowpass filter.

fn next Signature

def next(mut self, sig: SIMD[DType.float64, num_chans], freq: SIMD[DType.float64, num_chans] = 100, res: SIMD[DType.float64, num_chans] = 0.5) -> SIMD[DType.float64, num_chans]

fn next Arguments

Name Type Default Description
sig SIMD[DType.float64, num_chans] The input signal to process.
freq SIMD[DType.float64, num_chans] 100 The cutoff frequency of the lowpass filter.
res SIMD[DType.float64, num_chans] 0.5 The resonance of the filter. Values between 0 and 1 are typical, though slightly higher values may work, especially with oversampler.

fn next Returns : SIMD[DType.float64, num_chans] 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 tf2s (virtual analog) resonant filters. Copyright (C) 2003-2019 by Julius O. Smith III

Traits: AnyType, Copyable, ImplicitlyDeletable, Movable, PolyReset

Reson Parameters

Name Type Default Description
num_chans Int 1 Number of SIMD channels to process in parallel.

Reson Functions

struct Reson . fn init

Initialize the Reson filter.

fn init Signature

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

fn init Arguments

Name Type Default Description
world UnsafePointer[MMMWorld, MutUntrackedOrigin] 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

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

fn lpf Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
freq SIMD[DType.float64, num_chans] The cutoff frequency of the lowpass filter.
q SIMD[DType.float64, num_chans] The resonance of the filter.
gain SIMD[DType.float64, num_chans] The output gain (clipped to 0.0-1.0 range).

fn lpf Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct Reson . fn hpf

Process input through a resonant highpass filter.

fn hpf Signature

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

fn hpf Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
freq SIMD[DType.float64, num_chans] The cutoff frequency of the highpass filter.
q SIMD[DType.float64, num_chans] The resonance of the filter.
gain SIMD[DType.float64, num_chans] The output gain (clipped to 0.0-1.0 range).

fn hpf Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct Reson . fn bpf

Process input through a resonant bandpass filter.

fn bpf Signature

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

fn bpf Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
freq SIMD[DType.float64, num_chans] The center frequency of the bandpass filter.
q SIMD[DType.float64, num_chans] The resonance of the filter.
gain SIMD[DType.float64, num_chans] The output gain (clipped to 0.0-1.0 range).

fn bpf Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct Reson . fn reset

Reset the internal state of the Reson filter.

fn reset Signature

def reset(mut self)

struct Biquad

A Biquad filter struct.

To use the different modes, see the mode-specific methods.

Based on Robert Bristow-Johnson's Audio EQ Cookbook.

Traits: AnyType, Copyable, ImplicitlyDeletable, Movable, PolyReset

Biquad Parameters

Name Type Default Description
num_chans Int 1 Number of SIMD channels to process in parallel.

Biquad Functions

struct Biquad . fn init

Initialize the Biquad.

fn init Signature

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

fn init Arguments

Name Type Default Description
world UnsafePointer[MMMWorld, MutUntrackedOrigin] Pointer to the MMMWorld.

fn init Returns : Self

Static Method

This is a static method.

struct Biquad . fn reset

Clears any leftover internal state so the filter starts clean after interruptions or discontinuities in the audio stream.

fn reset Signature

def reset(mut self)

struct Biquad . fn lpf

Process input through a biquad lowpass filter. Passes frequencies below the cutoff while attenuating frequencies above it.

fn lpf Signature

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

fn lpf Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
frequency SIMD[DType.float64, num_chans] The cutoff frequency in Hz.
q SIMD[DType.float64, num_chans] The resonance of the filter.

fn lpf Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct Biquad . fn hpf

Process input through a biquad highpass filter. Passes frequencies above the cutoff while attenuating frequencies below it.

fn hpf Signature

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

fn hpf Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
frequency SIMD[DType.float64, num_chans] The cutoff frequency in Hz.
q SIMD[DType.float64, num_chans] The resonance of the filter.

fn hpf Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct Biquad . fn bpf

Process input through a biquad bandpass filter. Passes a band of frequencies centered at the cutoff while attenuating frequencies above and below.

fn bpf Signature

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

fn bpf Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
frequency SIMD[DType.float64, num_chans] The cutoff frequency in Hz.
q SIMD[DType.float64, num_chans] The bandwidth of the filter.

fn bpf Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct Biquad . fn notch

Process input through a biquad notch (band stop) filter. Attenuates a narrow band of frequencies centered at the cutoff while passing all others.

fn notch Signature

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

fn notch Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
frequency SIMD[DType.float64, num_chans] The cutoff frequency in Hz.
q SIMD[DType.float64, num_chans] The resonance of the filter.

fn notch Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct Biquad . fn allpass

Process input through a biquad allpass filter. Passes all frequencies at equal amplitude while shifting their phase relationship around the cutoff frequency.

fn allpass Signature

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

fn allpass Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
frequency SIMD[DType.float64, num_chans] The cutoff frequency in Hz.
q SIMD[DType.float64, num_chans] The resonance of the filter.

fn allpass Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct Biquad . fn bell

Process input through a biquad bell (peaking EQ) filter. Boosts or cuts a band of frequencies centered at the cutoff by a specified gain amount, leaving frequencies outside the band unaffected.

fn bell Signature

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

fn bell Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
frequency SIMD[DType.float64, num_chans] The cutoff frequency in Hz.
q SIMD[DType.float64, num_chans] The resonance of the filter.
gain_db SIMD[DType.float64, num_chans] The amount to boost/cut around the cutoff.

fn bell Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct Biquad . fn lowshelf

Process input through a biquad lowshelf filter. Boosts or cuts all frequencies below the cutoff by a specified gain amount, leaving frequencies above unaffected.

fn lowshelf Signature

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

fn lowshelf Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
frequency SIMD[DType.float64, num_chans] The cutoff frequency in Hz.
q SIMD[DType.float64, num_chans] The resonance of the filter.
gain_db SIMD[DType.float64, num_chans] The amount to boost/cut around the cutoff.

fn lowshelf Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct Biquad . fn highshelf

Process input through a biquad highshelf filter. Boosts or cuts all frequencies above the cutoff by a specified gain amount, leaving frequencies below unaffected.

fn highshelf Signature

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

fn highshelf Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The input signal to process.
frequency SIMD[DType.float64, num_chans] The cutoff frequency in Hz.
q SIMD[DType.float64, num_chans] The resonance of the filter.
gain_db SIMD[DType.float64, num_chans] The amount to boost/cut around the cutoff.

fn highshelf Returns : SIMD[DType.float64, num_chans] The next sample of the filtered output.

struct MedianFilter

A simple median filter for scalar samples.

The window size is forced to be odd and at least 1.

Traits: AnyType, Copyable, ImplicitlyDeletable, Movable, PolyReset


MedianFilter Functions

struct MedianFilter . fn init

fn init Signature

def __init__(out self, size: Int = 5)

fn init Arguments

Name Type Default Description
size Int 5

fn init Returns : Self

Static Method

This is a static method.

struct MedianFilter . fn process_sample

fn process_sample Signature

def process_sample(mut self, value: Float64) -> Float64

fn process_sample Arguments

Name Type Default Description
value Float64

fn process_sample Returns : Float64

struct MedianFilter . fn reset

Reset the median filter to its initial state.

fn reset Signature

def reset(mut self)

Documentation generated with mojo doc from Mojo version 1.0.0b2