mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-01-18 00:07:00 +00:00
Fix sphinx/build_docs warnings for audio_filters (#12449)
* updating DIRECTORY.md * Fix sphinx/build_docs warnings for audio_filters * Improve * Fix * Fix * Fix --------- Co-authored-by: MaximSmolskiy <MaximSmolskiy@users.noreply.github.com>
This commit is contained in:
parent
f8e595e048
commit
4abfce2791
|
@ -14,9 +14,13 @@ class IIRFilter:
|
|||
this generalized N-order function was made.
|
||||
|
||||
Using the following transfer function
|
||||
H(z)=\frac{b_{0}+b_{1}z^{-1}+b_{2}z^{-2}+...+b_{k}z^{-k}}{a_{0}+a_{1}z^{-1}+a_{2}z^{-2}+...+a_{k}z^{-k}}
|
||||
.. math:: H(z)=\frac{b_{0}+b_{1}z^{-1}+b_{2}z^{-2}+...+b_{k}z^{-k}}
|
||||
{a_{0}+a_{1}z^{-1}+a_{2}z^{-2}+...+a_{k}z^{-k}}
|
||||
|
||||
we can rewrite this to
|
||||
y[n]={\frac{1}{a_{0}}}\left(\left(b_{0}x[n]+b_{1}x[n-1]+b_{2}x[n-2]+...+b_{k}x[n-k]\right)-\left(a_{1}y[n-1]+a_{2}y[n-2]+...+a_{k}y[n-k]\right)\right)
|
||||
.. math:: y[n]={\frac{1}{a_{0}}}
|
||||
\left(\left(b_{0}x[n]+b_{1}x[n-1]+b_{2}x[n-2]+...+b_{k}x[n-k]\right)-
|
||||
\left(a_{1}y[n-1]+a_{2}y[n-2]+...+a_{k}y[n-k]\right)\right)
|
||||
"""
|
||||
|
||||
def __init__(self, order: int) -> None:
|
||||
|
@ -34,10 +38,12 @@ class IIRFilter:
|
|||
|
||||
def set_coefficients(self, a_coeffs: list[float], b_coeffs: list[float]) -> None:
|
||||
"""
|
||||
Set the coefficients for the IIR filter. These should both be of size order + 1.
|
||||
a_0 may be left out, and it will use 1.0 as default value.
|
||||
Set the coefficients for the IIR filter.
|
||||
These should both be of size `order` + 1.
|
||||
:math:`a_0` may be left out, and it will use 1.0 as default value.
|
||||
|
||||
This method works well with scipy's filter design functions
|
||||
|
||||
>>> # Make a 2nd-order 1000Hz butterworth lowpass filter
|
||||
>>> import scipy.signal
|
||||
>>> b_coeffs, a_coeffs = scipy.signal.butter(2, 1000,
|
||||
|
@ -68,7 +74,7 @@ class IIRFilter:
|
|||
|
||||
def process(self, sample: float) -> float:
|
||||
"""
|
||||
Calculate y[n]
|
||||
Calculate :math:`y[n]`
|
||||
|
||||
>>> filt = IIRFilter(2)
|
||||
>>> filt.process(0)
|
||||
|
|
Loading…
Reference in New Issue
Block a user