Mdct

Struct Mdct 

Source
pub struct Mdct { /* private fields */ }
Expand description

MDCT processor with pre-computed windows and FFT plans

Provides O(N log N) MDCT/IMDCT transforms using FFT acceleration.

Implementations§

Source§

impl Mdct

Source

pub fn new(channels: usize, window_type: WindowType) -> Self

Create a new MDCT processor

Source

pub fn sine_window(n: usize) -> Vec<f32>

Sine window: w[n] = sin(π(n+0.5)/N)

Source

pub fn vorbis_window(n: usize) -> Vec<f32>

Vorbis window: sin(π/2 * sin²(π(n+0.5)/N))

Source

pub fn forward(&self, samples: &[f32], block_size: BlockSize) -> Vec<f32>

Forward MDCT: N time samples → N/2 frequency coefficients

X[k] = Σ x[n] * w[n] * cos(π/N * (n + 0.5 + N/2) * (k + 0.5))

Source

pub fn inverse(&self, coeffs: &[f32], block_size: BlockSize) -> Vec<f32>

Inverse MDCT: N/2 frequency coefficients → N time samples

y[n] = 2/N * Σ(k=0 to N-1) X[k] * cos(π/N * (n + 0.5 + N/2) * (k + 0.5))

Source

pub fn process_frame( &mut self, samples: &[f32], channel: usize, block_size: BlockSize, ) -> (Vec<f32>, Vec<f32>)

Process a frame with overlap-add for perfect reconstruction Returns N/2 output samples (the middle half after overlap-add)

Source

pub fn reset(&mut self)

Reset overlap buffers (e.g., for seeking)

Source

pub fn analyze( &mut self, samples: &[f32], block_size: BlockSize, ) -> Vec<Vec<f32>>

Encode samples to MDCT coefficients for all channels Input: interleaved samples [L, R, L, R, …] Output: MDCT coefficients per channel

Source

pub fn synthesize( &mut self, coeffs: &[Vec<f32>], block_size: BlockSize, ) -> Vec<f32>

Synthesize samples from MDCT coefficients with overlap-add Input: MDCT coefficients per channel Output: interleaved samples

Auto Trait Implementations§

§

impl Freeze for Mdct

§

impl !RefUnwindSafe for Mdct

§

impl Send for Mdct

§

impl Sync for Mdct

§

impl Unpin for Mdct

§

impl !UnwindSafe for Mdct

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.