libflo_audio/dsp/backends/
rustfft.rs1use crate::dsp::{Complex32, Fft, FftDirection, FftPlanner};
4use alloc::boxed::Box;
5use alloc::sync::Arc;
6
7pub struct RustFftPlanner;
9
10impl FftPlanner for RustFftPlanner {
11 fn new() -> Self {
12 Self
13 }
14
15 fn plan_fft(&mut self, len: usize, direction: FftDirection) -> Box<dyn Fft> {
16 let mut planner = rustfft::FftPlanner::new();
17 let fft = match direction {
18 FftDirection::Forward => planner.plan_fft_forward(len),
19 FftDirection::Inverse => planner.plan_fft_inverse(len),
20 };
21 Box::new(RustFft(fft))
22 }
23
24 fn max_supported_len(&self) -> usize {
27 1 << 16
28 }
29}
30
31pub struct RustFft(Arc<dyn rustfft::Fft<f32>>);
33
34impl Fft for RustFft {
35 fn process(&self, buffer: &mut [Complex32]) {
36 self.0.process(buffer);
37 }
38}