Liking cljdoc? Tell your friends :D

fastmath.signal.iir

IIR filter design, based on the iirj library.

Filters are iirj Cascade objects (cascades of second order sections) with mutable state; process samples with fastmath.signal/filter-signal, fastmath.signal/filter-signal-1 or the Cascade.filter method, reset the state with fastmath.signal/reset-IIR!.

  • butterworth, chebyshev (types I and II), bessel - classic designs, as scipy.signal.butter, cheby1, cheby2, bessel (with norm='phase') in second order sections
  • biquad - one Audio EQ Cookbook section (see fastmath.signal.biquad)
  • sos - a cascade from given section coefficients

Common options:

  • :kind - :lowpass (default), :highpass, :bandpass, :bandstop
  • :order - filter order (default 5)
  • :fs - sample rate (default 1.0)
  • :cutoff - corner frequency for low and high pass, center frequency for band filters (default 0.1)
  • :bandwidth - width of band filters in frequency units: the pass or stop band is cutoff ± bandwidth/2 (default 0.1)
  • :direct-form - realization of the sections, 1 or 2 (default 2)

Frequencies are in the units of :fs: 0 < cutoff < fs/2 for low and high pass, 0 < cutoff - bandwidth/2 and cutoff + bandwidth/2 < fs/2 for band filters.

Throws ex-info for an unknown :kind, :type or :direct-form, a non-positive order or fs, frequencies outside these ranges, or malformed sections in sos.

IIR filter design, based on the iirj library.

Filters are iirj `Cascade` objects (cascades of second order sections) with mutable state; process samples with `fastmath.signal/filter-signal`, `fastmath.signal/filter-signal-1` or the `Cascade.filter` method, reset the state with `fastmath.signal/reset-IIR!`.

* [[butterworth]], [[chebyshev]] (types I and II), [[bessel]] - classic designs, as `scipy.signal.butter`, `cheby1`, `cheby2`, `bessel` (with `norm='phase'`) in second order sections
* [[biquad]] - one Audio EQ Cookbook section (see `fastmath.signal.biquad`)
* [[sos]] - a cascade from given section coefficients

Common options:

* `:kind` - `:lowpass` (default), `:highpass`, `:bandpass`, `:bandstop`
* `:order` - filter order (default 5)
* `:fs` - sample rate (default 1.0)
* `:cutoff` - corner frequency for low and high pass, center frequency for band filters (default 0.1)
* `:bandwidth` - width of band filters in frequency units: the pass or stop band is `cutoff ± bandwidth/2` (default 0.1)
* `:direct-form` - realization of the sections, 1 or 2 (default 2)

Frequencies are in the units of `:fs`: `0 < cutoff < fs/2` for low and high pass, `0 < cutoff - bandwidth/2` and `cutoff + bandwidth/2 < fs/2` for band filters.

Throws `ex-info` for an unknown `:kind`, `:type` or `:direct-form`, a non-positive order or `fs`, frequencies outside these ranges, or malformed sections in [[sos]].
raw docstring

besselclj

(bessel
  {:keys [kind order bandwidth cutoff fs direct-form]
   :or {kind :lowpass order 5 bandwidth 0.1 cutoff 0.1 fs 1.0 direct-form 2}})
(bessel kind order opts)

Bessel low pass, high pass, band pass or band stop filter, as scipy.signal.bessel with norm='phase'.

Options: :kind, :order, :fs, :cutoff, :bandwidth, :direct-form, see the namespace docstring. Returns a Cascade.

Bessel low pass, high pass, band pass or band stop filter, as `scipy.signal.bessel` with `norm='phase'`.

Options: `:kind`, `:order`, `:fs`, `:cutoff`, `:bandwidth`, `:direct-form`, see the namespace docstring. Returns a `Cascade`.
raw docstring

biquadclj

(biquad
  {:keys [kind cutoff fs direct-form gain bandwidth Q]
   :or {kind :lowpass cutoff 0.1 fs 1.0 direct-form 2 gain 1.0 bandwidth 0.5}})
(biquad kind opts)

One Audio EQ Cookbook biquad section as a Cascade, see fastmath.signal.biquad.

Options:

  • :kind - :lowpass (default), :highpass, :bandpass, :notch, :allpass, :equalizer (peaking), :lowshelf, :highshelf
  • :cutoff - corner or center frequency (default 0.1), :fs - sample rate (default 1.0)
  • :bandwidth - in octaves (default 0.5), or :Q - quality factor (converted with the digital cookbook formula); shelves take their Q from the bandwidth too (biquad/bandwidth->Q, Q ≈ 2.87 for the default 0.5 octave), not from a shelf slope, use fastmath.signal.biquad/shelf-slope->Q to pass a slope as :Q
  • :gain - in dB for :equalizer and shelves (default 1.0)
  • :direct-form - 1 or 2 (default)
One Audio EQ Cookbook biquad section as a `Cascade`, see `fastmath.signal.biquad`.

Options:

* `:kind` - `:lowpass` (default), `:highpass`, `:bandpass`, `:notch`, `:allpass`, `:equalizer` (peaking), `:lowshelf`, `:highshelf`
* `:cutoff` - corner or center frequency (default 0.1), `:fs` - sample rate (default 1.0)
* `:bandwidth` - in octaves (default 0.5), or `:Q` - quality factor (converted with the digital cookbook formula); shelves take their `Q` from the bandwidth too (`biquad/bandwidth->Q`, Q ≈ 2.87 for the default 0.5 octave), not from a shelf slope, use `fastmath.signal.biquad/shelf-slope->Q` to pass a slope as `:Q`
* `:gain` - in dB for `:equalizer` and shelves (default 1.0)
* `:direct-form` - 1 or 2 (default)
raw docstring

butterworthclj

(butterworth
  {:keys [kind order bandwidth cutoff fs direct-form]
   :or {kind :lowpass order 5 bandwidth 0.1 cutoff 0.1 fs 1.0 direct-form 2}})
(butterworth kind order opts)

Butterworth low pass, high pass, band pass or band stop filter, as scipy.signal.butter.

Options: :kind, :order, :fs, :cutoff, :bandwidth, :direct-form, see the namespace docstring. Returns a Cascade.

Butterworth low pass, high pass, band pass or band stop filter, as `scipy.signal.butter`.

Options: `:kind`, `:order`, `:fs`, `:cutoff`, `:bandwidth`, `:direct-form`, see the namespace docstring. Returns a `Cascade`.
raw docstring

chebyshevclj

(chebyshev {:keys [kind order ripple type bandwidth cutoff fs direct-form]
            :or {kind :lowpass
                 order 5
                 type :type-I
                 bandwidth 0.1
                 cutoff 0.1
                 fs 1.0
                 direct-form 2}})
(chebyshev kind order opts)

Chebyshev type I or II low pass, high pass, band pass or band stop filter, as scipy.signal.cheby1 / cheby2.

Options as in the namespace docstring, plus:

  • :type - :type-I (default, ripple in the pass band) or :type-II (ripple in the stop band)
  • :ripple - in dB: pass band ripple for type I (rp, default 0.5), minimum stop band attenuation for type II (rs, default 40)

Returns a Cascade.

Chebyshev type I or II low pass, high pass, band pass or band stop filter, as `scipy.signal.cheby1` / `cheby2`.

Options as in the namespace docstring, plus:

* `:type` - `:type-I` (default, ripple in the pass band) or `:type-II` (ripple in the stop band)
* `:ripple` - in dB: pass band ripple for type I (`rp`, default 0.5), minimum stop band attenuation for type II (`rs`, default 40)

Returns a `Cascade`.
raw docstring

direct-formsclj

Direct form realizations of the sections: 1 - direct form I, 2 - direct form II.

Direct form realizations of the sections: `1` - direct form I, `2` - direct form II.
raw docstring

responseclj

(response iir N)

Complex frequency response of the filter at N/2 frequencies k fs / N, k = 0 ... N/2 - 1 (from 0 to below the Nyquist frequency), as scipy.signal.sosfreqz at these frequencies.

Returns a vector of complex numbers (Vec2).

Complex frequency response of the filter at `N/2` frequencies `k fs / N`, `k = 0 ... N/2 - 1` (from 0 to below the Nyquist frequency), as `scipy.signal.sosfreqz` at these frequencies.

Returns a vector of complex numbers (`Vec2`).
raw docstring

sosclj

(sos seq-of-coeffs)
(sos seq-of-coeffs df)

Creates an IIR filter (Cascade) from a sequence of second order sections ([b0 b1 b2 a0 a1 a2] ...), as rows of scipy.signal sos arrays.

direct-form is 1 or 2 (default). Throws ex-info for no sections, a section without 6 numbers or a0 = 0.

Creates an IIR filter (`Cascade`) from a sequence of second order sections `([b0 b1 b2 a0 a1 a2] ...)`, as rows of `scipy.signal` `sos` arrays.

`direct-form` is 1 or 2 (default). Throws `ex-info` for no sections, a section without 6 numbers or `a0 = 0`.
raw docstring

sos-coeffsclj

(sos-coeffs irr)

Returns the second order sections of a filter: [[b0 b1 b2 1.0 a1 a2] ...], normalized to a0 = 1 as rows of a scipy.signal sos array.

Returns the second order sections of a filter: `[[b0 b1 b2 1.0 a1 a2] ...]`, normalized to `a0 = 1` as rows of a `scipy.signal` `sos` array.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close