[][src]Struct chfft::Mdct1D

pub struct Mdct1D<T, F: Fn(usize, usize) -> T> { /* fields omitted */ }

Perform a Modified discrete cosine transform

Example

use chfft::Mdct1D;

fn main() {
    let input = [2.0 as f64, 0.0, 1.0, 1.0, 0.0, 3.0, 2.0, 4.0];

    let mut mdct = Mdct1D::with_sine(input.len());
    let output = mdct.forward(&input);
    println!("the transform of {:?} is {:?}", input, output);
}

Methods

impl<T: Float + FloatConst + NumAssign> Mdct1D<T, fn(_: usize, _: usize) -> T>[src]

pub fn with_sine(len: usize) -> Self[src]

Returns a instances to execute DCT with sine window

use chfft::Mdct1D;
let mut mdct = Mdct1D::<f64, _>::with_sine(1024);

pub fn with_vorbis(len: usize) -> Self[src]

Returns a instances to execute DCT with vorbis window

use chfft::Mdct1D;
let mut mdct = Mdct1D::<f64, _>::with_vorbis(1024);

impl<T: Float + FloatConst + NumAssign, F: Fn(usize, usize) -> T> Mdct1D<T, F>[src]

pub fn new(window_func: F, len: usize) -> Self[src]

Returns a instances to execute DCT

use chfft::Mdct1D;
let mut mdct = Mdct1D::new(|l, p| (std::f64::consts::PI * (p as f64 + 0.5) / l as f64).sin(), 1024);

pub fn setup(&mut self, len: usize)[src]

Reinitialize length

use chfft::Mdct1D;
let mut mdct = Mdct1D::<f64, _>::with_sine(1024);

// reinitialize
mdct.setup(2048);

pub fn forward(&mut self, source: &[T]) -> Vec<T>[src]

The 1 scaling factor forward transform

use chfft::Mdct1D;

let input = [2.0 as f64, 0.0, 1.0, 1.0, 0.0, 3.0, 2.0, 4.0];

let mut mdct = Mdct1D::with_sine(input.len());
let output = mdct.forward(&input);

pub fn backward(&mut self, source: &[T]) -> Vec<T>[src]

The 1 scaling factor backward transform

use chfft::Mdct1D;

let input = [2.0 as f64, 0.0, 1.0, 1.0, 0.0, 3.0, 2.0, 4.0];

let mut mdct = Mdct1D::with_sine(input.len() << 1);
let output = mdct.backward(&input);

pub fn forwardu(&mut self, source: &[T]) -> Vec<T>[src]

The \(\sqrt{\frac 2 n}\) scaling factor forward transform

use chfft::Mdct1D;

let input = [2.0 as f64, 0.0, 1.0, 1.0, 0.0, 3.0, 2.0, 4.0];

let mut mdct = Mdct1D::with_sine(input.len());
let output = mdct.forward(&input);

pub fn backwardu(&mut self, source: &[T]) -> Vec<T>[src]

The \(\sqrt{\frac 2 n}\) scaling factor backward transform

use chfft::Mdct1D;

let input = [2.0 as f64, 0.0, 1.0, 1.0, 0.0, 3.0, 2.0, 4.0];

let mut mdct = Mdct1D::with_sine(input.len() << 1);
let output = mdct.backward(&input);

Trait Implementations

impl<T: Debug, F: Debug + Fn(usize, usize) -> T> Debug for Mdct1D<T, F>[src]

Auto Trait Implementations

impl<T, F> RefUnwindSafe for Mdct1D<T, F> where
    F: RefUnwindSafe,
    T: RefUnwindSafe

impl<T, F> Send for Mdct1D<T, F> where
    F: Send,
    T: Send

impl<T, F> Sync for Mdct1D<T, F> where
    F: Sync,
    T: Sync

impl<T, F> Unpin for Mdct1D<T, F> where
    F: Unpin,
    T: Unpin

impl<T, F> UnwindSafe for Mdct1D<T, F> where
    F: UnwindSafe,
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.