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

The cutoff as a fraction of the sample rate, in (0, 0.5): where the filter is 3 dB down, while the cutoff is small. As it grows the 3 dB point drifts above it, to 0.1035 for a cutoff of 0.1 and 0.2339 for 0.2, and from 0.2805 there is none: the filter is less than 3 dB down even at the Nyquist frequency. See DISCREPANCIES.md.

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]