Skip to main content

band_magnitude

Function band_magnitude 

Source
pub fn band_magnitude(
    samples: &[f64],
    rate: SampleRate,
    lo: Hz,
    hi: Hz,
) -> Result<Vec<f64>, FilterError>
Expand description

The envelope of the band from lo to hi.

The signal is mixed down by 2 exp(-j 2 pi f_c t) at the centre f_c, low-passed forward and backward at half the bandwidth, and the magnitude taken. A partial of amplitude A inside the band reads A.

Each low-pass extends the ends by an even reflection of three periods of its cutoff, so the ends carry no transient, and memory stays linear in the length, unlike the FFT of AnalyticSignal.

ยงErrors

Returns a FilterError when lo is not above 0 Hz, hi not below the Nyquist frequency, or hi not above lo.