lazy_filters Module

Stream filtering module

Summary of module contents:

Name Description
LinearFilterProperties Class with common properties in a linear filter that can be used as a mixin.
LinearFilter Base class for Linear filters, time invariant or not.
ZFilterMeta <class 'audiolazy.lazy_filters.ZFilterMeta'>
ZFilter Linear filters based on Z-transform frequency domain equations.
z Linear filters based on Z-transform frequency domain equations.
FilterListMeta <class 'audiolazy.lazy_filters.FilterListMeta'>
FilterList Class from which CascadeFilter and ParallelFilter inherits the common part of their contents. You probably won’t need to use this directly.
CascadeFilter Filter cascade as a list of filters.
ParallelFilter Filters in parallel as a list of filters.
comb This is a StrategyDict instance object called comb. Strategies stored: 3.
resonator This is a StrategyDict instance object called resonator. Strategies stored: 4.
lowpass This is a StrategyDict instance object called lowpass. Strategies stored: 4.
highpass This is a StrategyDict instance object called highpass. Strategies stored: 4.
class LinearFilterProperties[source]

Bases: object

Class with common properties in a linear filter that can be used as a mixin.

The classes that inherits this one should implement the numpoly and denpoly properties, and these should return a Poly instance.

dendict
denlist
denominator
denpolyz

Like denpoly, the linear filter denominator (or backward coefficients) as a Poly instance based on x = z instead of denpoly’s x = z ** -1, useful for taking roots.

numdict
numerator
numlist
numpolyz

Like numpoly, the linear filter numerator (or forward coefficients) as a Poly instance based on x = z instead of numpoly’s x = z ** -1, useful for taking roots.

class LinearFilter(numerator=None, denominator=None)[source]

Bases: audiolazy.lazy_filters.LinearFilterProperties

Base class for Linear filters, time invariant or not.

__call__(seq, memory=None, zero=0.0)[source]

IIR, FIR and time variant linear filtering.

Parameters:
  • seq – Any iterable to be seem as the input stream for the filter.
  • memory – Might be an iterable or a callable. Generally, as a iterable, the first needed elements from this input will be used directly as the memory (not the last ones!), and as a callable, it will be called with the size as the only positional argument, and should return an iterable. If None (default), memory is initialized with zeros.
  • zero – Value to fill the memory, when needed, and to be seem as previous input when there’s a delay. Defaults to 0.0.
Returns:

A Stream that have the data from the input sequence filtered.

__eq__(other)[source]
__hash__()[source]
__init__(numerator=None, denominator=None)[source]
__iter__()[source]
__ne__(other)[source]
copy()[source]

Returns a filter copy.

It’ll return a LinearFilter instance (more specific class when subclassing) with the same terms in both numerator and denominator, but as a “T” (tee) copy when the coefficients are Stream instances, allowing maths using a filter more than once.

freq_response(freq)[source]

Frequency response for this filter.

Parameters:freq – Frequency, in rad/sample. Can be an iterable with frequencies.
Returns:Complex number with the frequency response of the filter.

See also

dB10
Logarithmic power magnitude from data with squared magnitude.
dB20
Logarithmic power magnitude from raw complex data or data with linear amplitude.
phase
Phase from complex data.
LinearFilter.plot
Method to plot the LTI filter frequency and phase response into a Matplotlib figure.
is_causal()[source]

Causality test for this filter.

Returns:Boolean returning True if this filter is causal, False otherwise.
is_lti()[source]

Test if this filter is LTI (Linear Time Invariant).

Returns:Boolean returning True if this filter is LTI, False otherwise.
linearize()[source]

Linear interpolation of fractional delay values.

Returns:A new linear filter, with the linearized delay values.
Examples:
>>> filt = z ** -4.3
>>> filt.linearize()
0.7 * z^-4 + 0.3 * z^-5
plot(fig=None, samples=2048, rate=None, min_freq=0.0, max_freq=3.141592653589793, blk=None, unwrap=True, freq_scale='linear', mag_scale='dB')[source]

Plots the filter frequency response into a formatted MatPlotLib figure with two subplots, labels and title, including the magnitude response and the phase response.

Parameters:
  • fig – A matplotlib.figure.Figure instance. Defaults to None, which means that it will create a new figure.
  • samples – Number of samples (frequency values) to plot. Defaults to 2048.
  • rate – Given rate (samples/second) or “s” object from sHz. Defaults to 300.
  • [min_freq – ...
  • max_freq] – Frequency range to be drawn, in rad/sample. Defaults to [0, pi].
  • blk – Sequence block. Plots the block DFT together with the filter frequency. Defaults to None (no block).
  • unwrap – Boolean that chooses whether should unwrap the data phase or keep it as is. Defaults to True.
  • freq_scale – Chooses whether plot is “linear” or “log” with respect to the frequency axis. Defaults to “linear”. Case insensitive.
  • mag_scale – Chooses whether magnitude plot scale should be “linear”, “squared” or “dB”. Defaults do “dB”. Case insensitive.
Returns:

The matplotlib.figure.Figure instance.

See also

sHz
Second and hertz constants from samples/second rate.
LinearFilter.zplot
Zeros-poles diagram plotting.
dB20
Elementwise casting from an amplitude value to a logarithmic power gain (in decibels).
phase
Phase from complex data.
LinearFilter.freq_response
Get the complex frequency response of a filter for specific frequency values.
LinearFilter.zplot
Filter zero-pole plane plot.
poles

Returns a list with all poles (denominator roots in z). Needs Numpy.

See also

LinearFilterProperties.numpoly
Numerator polynomials where x is z ** -1.
LinearFilterProperties.denpoly
Denominator polynomials where x is z ** -1.
LinearFilterProperties.numpolyz
Numerator polynomials where x is z.
LinearFilterProperties.denpolyz
Denominator polynomials where x is z.
zeros

Returns a list with all zeros (numerator roots in z), besides the zero-valued “zeros” that might arise from the difference between the numerator and denominator order (i.e., the roots returned are the inverse from the numpoly.roots() in z ** -1). Needs Numpy.

See also

LinearFilterProperties.numpoly
Numerator polynomials where x is z ** -1.
LinearFilterProperties.denpoly
Denominator polynomials where x is z ** -1.
LinearFilterProperties.numpolyz
Numerator polynomials where x is z.
LinearFilterProperties.denpolyz
Denominator polynomials where x is z.
zplot(fig=None, circle=True)[source]

Plots the filter zero-pole plane into a formatted MatPlotLib figure with one subplot, labels and title.

Parameters:
  • fig – A matplotlib.figure.Figure instance. Defaults to None, which means that it will create a new figure.
  • circle – Chooses whether to include the unit circle in the plot. Defaults to True.
Returns:

The matplotlib.figure.Figure instance.

Note

Multiple roots detection is slow, and roots may suffer from numerical errors (e.g., filter f = 1 - 2 * z ** -1 + 1 * z ** -2 has twice the root 1, but f ** 3 suffer noise from the root finding algorithm). For the exact number of poles and zeros, see the result title, or the length of LinearFilter.poles() and LinearFilter.zeros().

See also

LinearFilter.plot
Frequency response plotting. Needs MatPlotLib.
LinearFilter.zeros, LinearFilter.poles
Filter zeros and poles, as a list. Needs NumPy.
class ZFilterMeta[source]

Bases: audiolazy.lazy_core.AbstractOperatorOverloaderMeta

__operators__ = '+ - * / **'
__rbinary__(op)[source]
__unary__(op)[source]
class ZFilter(numerator=None, denominator=None)[source]

Bases: audiolazy.lazy_filters.LinearFilter

Linear filters based on Z-transform frequency domain equations.

Examples:

Using the z object (float output because default filter memory has float zeros, and the delay in the numerator creates another float zero as “pre-input”):

>>> filt = (1 + z ** -1) / (1 - z ** -1)
>>> data = [1, 5, -4, -7, 9]
>>> stream_result = filt(data) # Lazy iterable
>>> list(stream_result) # Freeze
[1.0, 7.0, 8.0, -3.0, -1.0]

Same example with the same filter, but with a memory input, and using lists for filter numerator and denominator instead of the z object:

>>> b = [1, 1]
>>> a = [1, -1] # Each index ``i`` has the coefficient for z ** -i
>>> filt = ZFilter(b, a)
>>> data = [1, 5, -4, -7, 9]
>>> stream_result = filt(data, memory=[3], zero=0) # Lazy iterable
>>> result = list(stream_result) # Freeze
>>> result
[4, 10, 11, 0, 2]
>>> filt2 = filt * z ** -1 # You can add a delay afterwards easily
>>> final_result = filt2(result, zero=0)
>>> list(final_result)
[0, 4, 18, 39, 50]
__add__(other)[source]
__call__(seq, memory=None, zero=0.0)[source]

IIR, FIR and time variant linear filtering.

Parameters:
  • seq – Any iterable to be seem as the input stream for the filter, or another ZFilter for substituition.
  • memory – Might be an iterable or a callable. Generally, as a iterable, the first needed elements from this input will be used directly as the memory (not the last ones!), and as a callable, it will be called with the size as the only positional argument, and should return an iterable. If None (default), memory is initialized with zeros. Neglect when seq input is a ZFilter.
  • zero – Value to fill the memory, when needed, and to be seem as previous input when there’s a delay. Defaults to 0.0. Neglect when seq input is a ZFilter.
Returns:

A Stream that have the data from the input sequence filtered.

Examples:

With ZFilter instances:

>>> filt = 1 + z ** -1
>>> filt(z ** -1)
z + 1
>>> filt(- z ** 2)
1 - z^-2

With any iterable (but ZFilter instances):

>>> filt = 1 + z ** -1
>>> data = filt([1.0, 2.0, 3.0])
>>> data
<audiolazy.lazy_stream.Stream object at ...>
>>> list(data)
[1.0, 3.0, 5.0]
__mul__(other)[source]
__neg__()
__pos__()
__pow__(other)[source]
__radd__(other)
__repr__()
__rmul__(other)
__rpow__(other)
__rsub__(other)
__rtruediv__(other)
__str__()[source]
__sub__(other)[source]
__truediv__(other)[source]
diff(n=1, mul_after=1)[source]

Takes n-th derivative, multiplying each m-th derivative filter by mul_after before taking next (m+1)-th derivative or returning.

class FilterListMeta[source]

Bases: audiolazy.lazy_core.AbstractOperatorOverloaderMeta

__binary__(op)[source]
__operators__ = 'add * > >= < <='
__rbinary__(op)
class FilterList(*filters)[source]

Bases: list, audiolazy.lazy_filters.LinearFilterProperties

Class from which CascadeFilter and ParallelFilter inherits the common part of their contents. You probably won’t need to use this directly.

__add__(other)

This operator acts just like it would do with lists.

__eq__(other)[source]
__ge__(other)

This operator acts just like it would do with lists.

__gt__(other)

This operator acts just like it would do with lists.

__hash__ = None
__init__(*filters)[source]
__le__(other)

This operator acts just like it would do with lists.

__lt__(other)

This operator acts just like it would do with lists.

__mul__(other)

This operator acts just like it would do with lists.

__ne__(other)[source]
__rmul__(other)

This operator acts just like it would do with lists.

callables

List of callables with all filters, casting to LinearFilter each one that isn’t callable.

is_causal()[source]

Tests whether all filters in the list are causal (i.e., no future-data delay in positive z exponents). Non-linear filters are seem as causal by default. CascadeFilter and ParallelFilter are causal if all the filters they group are causal.

is_linear()[source]

Tests whether all filters in the list are linear. CascadeFilter and ParallelFilter instances are also linear if all filters they group are linear.

is_lti()[source]

Tests whether all filters in the list are linear time invariant (LTI). CascadeFilter and ParallelFilter instances are also LTI if all filters they group are LTI.

plot(fig=None, samples=2048, rate=None, min_freq=0.0, max_freq=3.141592653589793, blk=None, unwrap=True, freq_scale='linear', mag_scale='dB')

Plots the filter frequency response into a formatted MatPlotLib figure with two subplots, labels and title, including the magnitude response and the phase response.

Parameters:
  • fig – A matplotlib.figure.Figure instance. Defaults to None, which means that it will create a new figure.
  • samples – Number of samples (frequency values) to plot. Defaults to 2048.
  • rate – Given rate (samples/second) or “s” object from sHz. Defaults to 300.
  • [min_freq – ...
  • max_freq] – Frequency range to be drawn, in rad/sample. Defaults to [0, pi].
  • blk – Sequence block. Plots the block DFT together with the filter frequency. Defaults to None (no block).
  • unwrap – Boolean that chooses whether should unwrap the data phase or keep it as is. Defaults to True.
  • freq_scale – Chooses whether plot is “linear” or “log” with respect to the frequency axis. Defaults to “linear”. Case insensitive.
  • mag_scale – Chooses whether magnitude plot scale should be “linear”, “squared” or “dB”. Defaults do “dB”. Case insensitive.
Returns:

The matplotlib.figure.Figure instance.

See also

sHz
Second and hertz constants from samples/second rate.
LinearFilter.zplot
Zeros-poles diagram plotting.
dB20
Elementwise casting from an amplitude value to a logarithmic power gain (in decibels).
phase
Phase from complex data.
LinearFilter.freq_response
Get the complex frequency response of a filter for specific frequency values.
LinearFilter.zplot
Filter zero-pole plane plot.
zplot(fig=None, circle=True)

Plots the filter zero-pole plane into a formatted MatPlotLib figure with one subplot, labels and title.

Parameters:
  • fig – A matplotlib.figure.Figure instance. Defaults to None, which means that it will create a new figure.
  • circle – Chooses whether to include the unit circle in the plot. Defaults to True.
Returns:

The matplotlib.figure.Figure instance.

Note

Multiple roots detection is slow, and roots may suffer from numerical errors (e.g., filter f = 1 - 2 * z ** -1 + 1 * z ** -2 has twice the root 1, but f ** 3 suffer noise from the root finding algorithm). For the exact number of poles and zeros, see the result title, or the length of LinearFilter.poles() and LinearFilter.zeros().

See also

LinearFilter.plot
Frequency response plotting. Needs MatPlotLib.
LinearFilter.zeros, LinearFilter.poles
Filter zeros and poles, as a list. Needs NumPy.
class CascadeFilter(*filters)[source]

Bases: audiolazy.lazy_filters.FilterList

Filter cascade as a list of filters.

Note

A filter is any callable that receives an iterable as input and returns a Stream.

Examples:
>>> filt = CascadeFilter(z ** -1, 2 * (1 - z ** -3))
>>> data = Stream(1, 3, 5, 3, 1, -1, -3, -5, -3, -1) # Endless
>>> filt(data, zero=0).take(15)
[0, 2, 6, 10, 4, -4, -12, -12, -12, -4, 4, 12, 12, 12, 4]
__add__(other)

This operator acts just like it would do with lists.

__call__(*args, **kwargs)[source]
__ge__(other)

This operator acts just like it would do with lists.

__gt__(other)

This operator acts just like it would do with lists.

__le__(other)

This operator acts just like it would do with lists.

__lt__(other)

This operator acts just like it would do with lists.

__mul__(other)

This operator acts just like it would do with lists.

__rmul__(other)

This operator acts just like it would do with lists.

denpoly
freq_response(freq)[source]
numpoly
poles
zeros
class ParallelFilter(*filters)[source]

Bases: audiolazy.lazy_filters.FilterList

Filters in parallel as a list of filters.

This list of filters that behaves as a filter, returning the sum of all signals that results from applying the the same given input into all filters. Besides the name, the data processing done isn’t parallel.

Note

A filter is any callable that receives an iterable as input and returns a Stream.

Examples:
>>> filt = 1 + z ** -1 -  z ** -2
>>> pfilt = ParallelFilter(1 + z ** -1, - z ** -2)
>>> list(filt(range(100))) == list(pfilt(range(100)))
True
>>> list(filt(range(10), zero=0))
[0, 1, 3, 4, 5, 6, 7, 8, 9, 10]
__add__(other)

This operator acts just like it would do with lists.

__call__(*args, **kwargs)[source]
__ge__(other)

This operator acts just like it would do with lists.

__gt__(other)

This operator acts just like it would do with lists.

__le__(other)

This operator acts just like it would do with lists.

__lt__(other)

This operator acts just like it would do with lists.

__mul__(other)

This operator acts just like it would do with lists.

__rmul__(other)

This operator acts just like it would do with lists.

denpoly
freq_response(freq)[source]
numpoly
poles
zeros

lazy_filters.comb StrategyDict

This is a StrategyDict instance object called comb. Strategies stored: 3.

Strategy comb.fb (Default). Aliases available are comb.alpha, comb.fb_alpha, comb.feedback_alpha. Docstring starts with:

Feedback comb filter for a given alpha and delay.

Strategy comb.ff. Aliases available are comb.ff_alpha, comb.feedforward_alpha. Docstring starts with:

Feedforward comb filter for a given alpha (and delay).

Strategy comb.tau. Aliases available are comb.fb_tau, comb.feedback_tau. Docstring starts with:

Feedback comb filter for a given time constant (and delay).

Note

This docstring is self-generated, see the StrategyDict class and the strategies docs for more details.

tau(delay, tau=inf)

Feedback comb filter for a given time constant (and delay).

y[n] = x[n] + alpha * y[n - delay]
Parameters:
  • delay – Feedback delay (lag), in number of samples.
  • tau – Time decay (up to 1/e, or -8.686 dB), in number of samples, which allows finding alpha = e ** (-delay / tau). Defaults to inf (infinite), which means alpha = 1.
Returns:

A ZFilter instance with the comb filter.

See also

freq2lag
Frequency (in rad/sample) to delay (in samples) converter.
fb(delay, alpha=1)

Feedback comb filter for a given alpha and delay.

y[n] = x[n] + alpha * y[n - delay]
Parameters:
  • delay – Feedback delay (lag), in number of samples.
  • alpha – Exponential decay gain. You can find it from time decay tau in the impulse response, bringing us alpha = e ** (-delay / tau). See comb.tau strategy if that’s the case. Defaults to 1 (no decay).
Returns:

A ZFilter instance with the comb filter.

See also

freq2lag
Frequency (in rad/sample) to delay (in samples) converter.
ff(delay, alpha=1)

Feedforward comb filter for a given alpha (and delay).

y[n] = x[n] + alpha * x[n - delay]
Parameters:
  • delay – Feedback delay (lag), in number of samples.
  • alpha – Memory value gain.
Returns:

A ZFilter instance with the comb filter.

See also

freq2lag
Frequency (in rad/sample) to delay (in samples) converter.

lazy_filters.resonator StrategyDict

This is a StrategyDict instance object called resonator. Strategies stored: 4.

Strategy resonator.freq_poles_exp. Docstring starts with:

Resonator filter with 2-poles (conjugated pair) and no zeros (constant numerator), with exponential approximation for bandwidth calculation. Given frequency is the denominator frequency, not the resonant frequency.

Strategy resonator.freq_z_exp. Docstring starts with:

Resonator filter with 2-zeros and 2-poles (conjugated pair). The zeros are at the 1 and -1 (both at the real axis, i.e., at the DC and the Nyquist rate), with exponential approximation for bandwidth calculation. Given frequency is the denominator frequency, not the resonant frequency.

Strategy resonator.poles_exp (Default). Docstring starts with:

Resonator filter with 2-poles (conjugated pair) and no zeros (constant numerator), with exponential approximation for bandwidth calculation.

Strategy resonator.z_exp. Docstring starts with:

Resonator filter with 2-zeros and 2-poles (conjugated pair). The zeros are at the 1 and -1 (both at the real axis, i.e., at the DC and the Nyquist rate), with exponential approximation for bandwidth calculation.

Note

This docstring is self-generated, see the StrategyDict class and the strategies docs for more details.

z_exp(freq, bandwidth)

Resonator filter with 2-zeros and 2-poles (conjugated pair). The zeros are at the 1 and -1 (both at the real axis, i.e., at the DC and the Nyquist rate), with exponential approximation for bandwidth calculation.

Parameters:
  • freq – Resonant frequency in rad/sample (max gain).
  • bandwidth – Bandwidth frequency range in rad/sample following the equation: R = exp(-bandwidth / 2) where R is the pole amplitude (radius).
Returns:

A ZFilter object. Gain is normalized to have peak with 0 dB (1.0 amplitude).

freq_z_exp(freq, bandwidth)

Resonator filter with 2-zeros and 2-poles (conjugated pair). The zeros are at the 1 and -1 (both at the real axis, i.e., at the DC and the Nyquist rate), with exponential approximation for bandwidth calculation. Given frequency is the denominator frequency, not the resonant frequency.

Parameters:
  • freq – Denominator frequency in rad/sample (not the one with max gain).
  • bandwidth – Bandwidth frequency range in rad/sample following the equation: R = exp(-bandwidth / 2) where R is the pole amplitude (radius).
Returns:

A ZFilter object. Gain is normalized to have peak with 0 dB (1.0 amplitude).

poles_exp(freq, bandwidth)

Resonator filter with 2-poles (conjugated pair) and no zeros (constant numerator), with exponential approximation for bandwidth calculation.

Parameters:
  • freq – Resonant frequency in rad/sample (max gain).
  • bandwidth – Bandwidth frequency range in rad/sample following the equation: R = exp(-bandwidth / 2) where R is the pole amplitude (radius).
Returns:

A ZFilter object. Gain is normalized to have peak with 0 dB (1.0 amplitude).

freq_poles_exp(freq, bandwidth)

Resonator filter with 2-poles (conjugated pair) and no zeros (constant numerator), with exponential approximation for bandwidth calculation. Given frequency is the denominator frequency, not the resonant frequency.

Parameters:
  • freq – Denominator frequency in rad/sample (not the one with max gain).
  • bandwidth – Bandwidth frequency range in rad/sample following the equation: R = exp(-bandwidth / 2) where R is the pole amplitude (radius).
Returns:

A ZFilter object. Gain is normalized to have peak with 0 dB (1.0 amplitude).

lazy_filters.lowpass StrategyDict

This is a StrategyDict instance object called lowpass. Strategies stored: 4.

Strategy lowpass.pole (Default). Docstring starts with:

Digital lowpass filter with one pole and no zeros (constant numerator).

Strategy lowpass.pole_exp. Docstring starts with:

Matched Z-Transform lowpass filter with one pole and no zeros (constant numerator).

Strategy lowpass.z. Docstring starts with:

Digital lowpass filter with one pole and one zero.

Strategy lowpass.z_exp. Docstring starts with:

Matched Z-Transform lowpass filter with one pole and one zero.

Note

This docstring is self-generated, see the StrategyDict class and the strategies docs for more details.

z_exp(cutoff)

Matched Z-Transform lowpass filter with one pole and one zero.

This strategy uses an exponential approximation for cut-off frequency calculation, found by matching the single pole and single zero Laplace highpass filter and mirroring the resulting filter to get a lowpass.

Parameters:cutoff – Cut-off frequency given in rad/sample. Should be a value (or a Stream of values) ranging from \(0\) (DC/constant level) up to \(\pi\) (Nyquist frequency). This value is used to find the pole amplitude (radius) \(R = e^{cutoff - \pi}\).
Returns:A ZFilter object. Gain is normalized to have peak with 0 dB (1.0 amplitude) at the DC frequency (zero rad/sample). Cut-off frequency is unreliable outside the \([5\pi/6; \pi]\) range.

Note

The digital filter design for this filter strategy (lowpass.z_exp) can be found in the AudioLazy math directory, both in the source distribution package and in main repository. That directory contains the code for finding the filter parameters (symbolic, using Sympy), besides the design details.

See also

sHz
Second and hertz constants from samples/second rate.
pole_exp(cutoff)

Matched Z-Transform lowpass filter with one pole and no zeros (constant numerator).

This strategy uses an exponential approximation for cut-off frequency calculation, found by matching the one-pole Laplace lowpass filter.

Parameters:cutoff – Cut-off frequency given in rad/sample. Should be a value (or a Stream of values) ranging from \(0\) (DC/constant level) up to \(\pi\) (Nyquist frequency). This value is used to find the pole amplitude (radius) \(R = e^{-cutoff}\).
Returns:A ZFilter object. Gain is normalized to have peak with 0 dB (1.0 amplitude) at the DC frequency (zero rad/sample). Cut-off frequency is unreliable outside the \([0; \pi/6]\) range.

Note

The digital filter design for this filter strategy (lowpass.pole_exp) can be found in the AudioLazy math directory, both in the source distribution package and in main repository. That directory contains the code for finding the filter parameters (symbolic, using Sympy), besides the design details.

See also

sHz
Second and hertz constants from samples/second rate.
z(cutoff)

Digital lowpass filter with one pole and one zero.

This strategy uses a high-precision cut-off frequency calculation.
Parameters:cutoff – Cut-off frequency given in rad/sample. Should be a value (or a Stream of values) ranging from \(0\) (DC/constant level) up to \(\pi\) (Nyquist frequency). It defines the filter frequency in which the squared gain is 50% the input gain (i.e, when magnitude gain is \(\sqrt{2}/2\) and power gain is about 3.0103 dB).
Returns:A ZFilter object. Gain is normalized to have peak with 0 dB (1.0 amplitude) at the DC frequency (zero rad/sample).

Note

The digital filter design for this filter strategy (lowpass.z) can be found in the AudioLazy math directory, both in the source distribution package and in main repository. That directory contains the code for finding the filter parameters (symbolic, using Sympy), besides the design details.

See also

sHz
Second and hertz constants from samples/second rate.
pole(cutoff)

Digital lowpass filter with one pole and no zeros (constant numerator).

This strategy uses a high-precision cut-off frequency calculation.
Parameters:cutoff – Cut-off frequency given in rad/sample. Should be a value (or a Stream of values) ranging from \(0\) (DC/constant level) up to \(\pi\) (Nyquist frequency). It defines the filter frequency in which the squared gain is 50% the input gain (i.e, when magnitude gain is \(\sqrt{2}/2\) and power gain is about 3.0103 dB).
Returns:A ZFilter object. Gain is normalized to have peak with 0 dB (1.0 amplitude) at the DC frequency (zero rad/sample).

Note

The digital filter design for this filter strategy (lowpass.pole) can be found in the AudioLazy math directory, both in the source distribution package and in main repository. That directory contains the code for finding the filter parameters (symbolic, using Sympy), besides the design details.

See also

sHz
Second and hertz constants from samples/second rate.

lazy_filters.highpass StrategyDict

This is a StrategyDict instance object called highpass. Strategies stored: 4.

Strategy highpass.pole. Docstring starts with:

Digital highpass filter with one pole and no zeros (constant numerator).

Strategy highpass.pole_exp. Docstring starts with:

Matched Z-Transform highpass filter with one pole and no zeros (constant numerator).

Strategy highpass.z (Default). Docstring starts with:

Digital highpass filter with one pole and one zero.

Strategy highpass.z_exp. Docstring starts with:

Matched Z-Transform highpass filter with one pole and one zero.

Note

This docstring is self-generated, see the StrategyDict class and the strategies docs for more details.

z_exp(cutoff)

Matched Z-Transform highpass filter with one pole and one zero.

This strategy uses an exponential approximation for cut-off frequency calculation, found by matching the single pole and single zero Laplace highpass filter.

Parameters:cutoff – Cut-off frequency given in rad/sample. Should be a value (or a Stream of values) ranging from \(0\) (DC/constant level) up to \(\pi\) (Nyquist frequency). This value is used to find the pole amplitude (radius) \(R = e^{-cutoff}\).
Returns:A ZFilter object. Gain is normalized to have peak with 0 dB (1.0 amplitude) at the Nyquist frequency (pi rad/sample). Cut-off frequency is unreliable outside the \([0; \pi/6]\) range.

Note

The digital filter design for this filter strategy (highpass.z_exp) can be found in the AudioLazy math directory, both in the source distribution package and in main repository. That directory contains the code for finding the filter parameters (symbolic, using Sympy), besides the design details.

See also

sHz
Second and hertz constants from samples/second rate.
pole_exp(cutoff)

Matched Z-Transform highpass filter with one pole and no zeros (constant numerator).

This strategy uses an exponential approximation for cut-off frequency calculation, found by matching the one-pole Laplace lowpass filter and mirroring the resulting filter to get a highpass.

Parameters:cutoff – Cut-off frequency given in rad/sample. Should be a value (or a Stream of values) ranging from \(0\) (DC/constant level) up to \(\pi\) (Nyquist frequency). This value is used to find the pole amplitude (radius) \(R = e^{cutoff - \pi}\).
Returns:A ZFilter object. Gain is normalized to have peak with 0 dB (1.0 amplitude) at the Nyquist frequency (pi rad/sample). Cut-off frequency is unreliable outside the \([5\pi/6; \pi]\) range.

Note

The digital filter design for this filter strategy (highpass.pole_exp) can be found in the AudioLazy math directory, both in the source distribution package and in main repository. That directory contains the code for finding the filter parameters (symbolic, using Sympy), besides the design details.

See also

sHz
Second and hertz constants from samples/second rate.
z(cutoff)

Digital highpass filter with one pole and one zero.

This strategy uses a high-precision cut-off frequency calculation.
Parameters:cutoff – Cut-off frequency given in rad/sample. Should be a value (or a Stream of values) ranging from \(0\) (DC/constant level) up to \(\pi\) (Nyquist frequency). It defines the filter frequency in which the squared gain is 50% the input gain (i.e, when magnitude gain is \(\sqrt{2}/2\) and power gain is about 3.0103 dB).
Returns:A ZFilter object. Gain is normalized to have peak with 0 dB (1.0 amplitude) at the Nyquist frequency (pi rad/sample).

Note

The digital filter design for this filter strategy (highpass.z) can be found in the AudioLazy math directory, both in the source distribution package and in main repository. That directory contains the code for finding the filter parameters (symbolic, using Sympy), besides the design details.

See also

sHz
Second and hertz constants from samples/second rate.
pole(cutoff)

Digital highpass filter with one pole and no zeros (constant numerator).

This strategy uses a high-precision cut-off frequency calculation.
Parameters:cutoff – Cut-off frequency given in rad/sample. Should be a value (or a Stream of values) ranging from \(0\) (DC/constant level) up to \(\pi\) (Nyquist frequency). It defines the filter frequency in which the squared gain is 50% the input gain (i.e, when magnitude gain is \(\sqrt{2}/2\) and power gain is about 3.0103 dB).
Returns:A ZFilter object. Gain is normalized to have peak with 0 dB (1.0 amplitude) at the Nyquist frequency (pi rad/sample).

Note

The digital filter design for this filter strategy (highpass.pole) can be found in the AudioLazy math directory, both in the source distribution package and in main repository. That directory contains the code for finding the filter parameters (symbolic, using Sympy), besides the design details.

See also

sHz
Second and hertz constants from samples/second rate.