signal::filter::response
Frequency response of a filter on the unit circle, by Horner's rule at each frequency: O(points * taps), exact to rounding.
Structs
ResponseSource
pub struct ResponseA frequency response: h[k] is the gain at frequency w[k] (in
the units of the fs asked for).
|h|, the magnitude.20 log10 |h|, the magnitude in dB.nabiuse signal::filter::{Band, butter, sosfreqz}; let r = try sosfreqz(try butter(4, Band::Lowpass(0.5)), n: 3); println(r.db()[0]); // 0.0 (to rounding): unit gain at DCThe phase of
hin radians, in(-pi, pi](not unwrapped).
Functions
freqzSource
pub fn freqz(b: some RealSamples, a: some RealSamples, n: usize = 512, whole: bool = false, fs: f64 = 2.0 * f64::PI) throws (SignalError) -> Response The response H(e^jw) = b(e^jw) / a(e^jw) at n frequencies from 0
up to (not including) Nyquist, or the whole circle with whole.
fs sets the units of w (default 2 pi: radians per sample).
nabi
use core::array::Vector;
let b: Vector<f64> = [0.5, 0.5];
let a: Vector<f64> = [1];
let r = try signal::filter::freqz(b, a, n: 2);
println(r.magnitude()); // [1.0, 0.7071..]
sosfreqzSource
pub fn sosfreqz(sos: Matrix<f64>, n: usize = 512, whole: bool = false, fs: f64 = 2.0 * f64::PI) throws (SignalError) -> Response freqz for second-order sections: the product of the rows'
responses.
nabi
use signal::filter::{Band, butter, sosfreqz};
let r = try sosfreqz(try butter(2, Band::Lowpass(100.0), fs: 1000.0), n: 5, fs: 1000.0);
println(r.w); // [0.0, 100.0, 200.0, 300.0, 400.0]
println(r.magnitude()[1]); // 0.7071.. (-3 dB at the cutoff)