music.low_pass

music.low_pass(cutoff=0.1)[source]

A one-pole low pass, from the article’s equation eq:passa-baixas.

x = exp(-2 pi f_c), then a_0 = 1 - x and b_1 = x.

Parameters:
cutoffscalar

Where the filter attenuates by 3 dB, as a fraction of the sample rate, in (0, 0.5).

Returns:
a, bndarray

The feedforward and feedback coefficients, for iir().

Raises:
ValueError

If cutoff is outside (0, 0.5), which is where a fraction of the sample rate has a filter to describe.

Parameters:

cutoff (float)

Return type:

tuple[NDArray[float64], NDArray[float64]]

See also

high_pass

the complementary filter, from the same pole.

fraction_of

converts a frequency in Hertz into a cutoff.

Notes

One pole, so the roll-off above the cutoff is 6 dB per octave. The article gives it “for didactic purposes and as a reference”, and names biquad recipes and Chebyshev coefficients as what to reach for when this is not sharp enough.

Examples

>>> a, b = low_pass(cutoff=0.05)
>>> [round(float(v), 6) for v in a]
[0.269597]
>>> [round(float(v), 6) for v in b]
[1.0, 0.730403]