Closed awelkie closed 9 years ago
I've actually struggled with this issue myself - a pure Rust FFT impl will likely make it easier for compile-time number widths than trying to trigger a recompilation of kissfft. :)
Aside from a call to f32::consts::PI and some explicit casts, the implementation you adopted from kissfft looks pretty type-generic. Have you spent any time trying to refactor RustFFT such that process
looks like
process<T: std::num::Float>(&mut self, signal: &[Complex<T>], spectrum: &mut [Complex<T>])
or equiv?
I tried making it generic a while ago, and I think I got hung up on the casts of f32::consts::PI to the generic type. But other than that, T
should just need to be Float
, I think. But it looks like std::num::Float
is deprecated. Does that mean we're supposed to use the Float
trait from the num
crate?
And yeah, having generics is probably the only actual improvement over a C implementation of the FFT. That, and maybe a slightly easier build process for Rust projects.
use core::num::Float;
....I think....
I just merged in generics. I decided to use Signed + FromPrimitive + Copy' which should more easily allow fixed point numbers than using the
Float` trait.
Awesome!
The FFT functions should be generic over the sample type