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>
impl<T: DctNum> MdctViaDct4<T>
Sourcepub fn new<F>(inner_dct: Arc<dyn TransformType4<T>>, window_fn: F) -> Self
pub fn new<F>(inner_dct: Arc<dyn TransformType4<T>>, window_fn: F) -> Self
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>
impl<T> Length for MdctViaDct4<T>
Source§impl<T: DctNum> Mdct<T> for MdctViaDct4<T>
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],
)
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 moreSource§fn process_imdct_with_scratch(
&self,
input: &[T],
output_a: &mut [T],
output_b: &mut [T],
scratch: &mut [T],
)
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 moreSource§impl<T> RequiredScratch for MdctViaDct4<T>
impl<T> RequiredScratch for MdctViaDct4<T>
fn get_scratch_len(&self) -> usize
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more