Skip to main content

MdctViaDct4

Struct MdctViaDct4 

Source
pub struct MdctViaDct4<T> { /* private fields */ }
Expand description

MDCT implementation that converts the problem to a DCT Type 4 of the same size.

It is much easier to express a MDCT as a DCT Type 4 than it is to express it as a FFT, so converting the MDCT to a DCT4 before converting it to a FFT results in greatly simplified code

// Computes a MDCT of input size 1234 via a DCT4, using the MP3 window function
use rustdct::mdct::{Mdct, MdctViaDct4, window_fn};
use rustdct::{DctPlanner, RequiredScratch};

let len = 1234;

let mut planner = DctPlanner::new();
let inner_dct4 = planner.plan_dct4(len);

let dct = MdctViaDct4::new(inner_dct4, window_fn::mp3);

let input = vec![0f32; len * 2];
let (input_a, input_b) = input.split_at(len);
let mut output = vec![0f32; len];
let mut scratch = vec![0f32; dct.get_scratch_len()];

dct.process_mdct_with_scratch(input_a, input_b, &mut output, &mut scratch);

Implementations§

Source§

impl<T: DctNum> MdctViaDct4<T>

Source

pub fn new<F>(inner_dct: Arc<dyn TransformType4<T>>, window_fn: F) -> Self
where F: FnOnce(usize) -> Vec<T>,

Creates a new MDCT context that will process signals of length inner_dct.len() * 2, with an output of length inner_dct.len()

inner_dct.len() must be even.

window_fn is a function that takes a size and returns a Vec containing size window values. See the window_fn module for provided window functions.

Trait Implementations§

Source§

impl<T> Length for MdctViaDct4<T>

Source§

fn len(&self) -> usize

The FFT size that this algorithm can process
Source§

impl<T: DctNum> Mdct<T> for MdctViaDct4<T>

Source§

fn process_mdct_with_scratch( &self, input_a: &[T], input_b: &[T], output: &mut [T], scratch: &mut [T], )

Computes the MDCT on the input buffer and places the result in the output buffer. Uses input_a for the first half of the input, and input_b for the second half of the input Read more
Source§

fn process_imdct_with_scratch( &self, input: &[T], output_a: &mut [T], output_b: &mut [T], scratch: &mut [T], )

Computes the IMDCT on the input buffer and places the result in the output buffer. Puts the first half of the output in output_a, and puts the first half of the output in output_b. Read more
Source§

impl<T> RequiredScratch for MdctViaDct4<T>

Auto Trait Implementations§

§

impl<T> Freeze for MdctViaDct4<T>

§

impl<T> !RefUnwindSafe for MdctViaDct4<T>

§

impl<T> Send for MdctViaDct4<T>
where T: Send,

§

impl<T> Sync for MdctViaDct4<T>
where T: Sync,

§

impl<T> Unpin for MdctViaDct4<T>

§

impl<T> UnsafeUnpin for MdctViaDct4<T>

§

impl<T> !UnwindSafe for MdctViaDct4<T>

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.