Crate apodize [] [src]

iterators that yield generalized cosine, hanning, hamming, blackman and nuttall windows

example for a hanning window (hamming, blackman and nuttall are analogous):

use std::ops::Mul;

#[macro_use]
extern crate nalgebra;
use nalgebra::{ApproxEq, DVec};

#[macro_use]
extern crate apodize;
use apodize::{hanning_iter};

fn main() {
    // create a hanning window iterator of size 7
    // and collect the values it yields in an nalgebra::DVec.
    // hanning_iter is generic over the type
    // of floating point number yielded (f32 or f64).
    // we use f64 here.
    let window = hanning_iter::<f64>(7).collect::<DVec<f64>>();

    assert_approx_eq_ulps!(
        window,
        dvec![
            0.0,
            0.24999999999999994,
            0.7499999999999999,
            1.0,
            0.7500000000000002,
            0.25,
            0.0],
        10);

    // some data we want to window
    let data: DVec<f64> = dvec![1., 2., 3., 4., 5., 6., 7.];

    // apply window to data
    let windowed_data = window.mul(data);

    assert_approx_eq_ulps!(
        windowed_data,
        dvec![
            0.0,
            0.4999999999999999,
            2.2499999999999996,
            4.0,
            3.750000000000001,
            1.5,
            0.0],
        10);
}

Macros

dvec!

build an nalgebra::DVec as easy as a std::Vec. for shorter, more readable code in tests and examples.

from!

helper shorthand macro for shorter, more readable code: from!(T, x) -> T::from(x).unwrap()

Structs

CosineWindowIter

holds the window coefficients and iteration state of a cosine window iterator

Traits

CanRepresentPi

the constant pi for generic floating point types. workaround until associated constants are stable.

Functions

blackman_iter

returns an iterator that yields the values for a blackman window of size

cosine_at

returns the value of the cosine window of size with the coefficients a, b, c and d at index index

cosine_iter

returns an iterator that yields the values for a cosine window of size with the coefficients a, b, c and d

hamming_iter

returns an iterator that yields the values for a hamming window of size

hanning_iter

returns an iterator that yields the values for a hanning window of size

nuttall_iter

returns an iterator that yields the values for a nuttall window of size