RealFFT
Fast real-to-complex forward FFT and complex-to-real inverse FFT for Rust, built on RustFFT.
Repository Health
Technical Analysis
RealFFT is a Rust crate that provides fast, convenient Fast Fourier Transforms of real-valued data. It wraps the popular RustFFT library with an API deliberately kept close to RustFFT’s, but specialized for the common case where the input signal is real rather than complex.
By avoiding the need to convert real data into complex form and, for even lengths, computing a complex FFT of half the length, RealFFT can roughly double throughput on larger transforms. The forward transform maps an N-sample real signal to an N/2+1 complex spectrum, and the inverse transform reverses that, all while passing RustFFT’s SIMD feature flags straight through.
What You Get
- Real-to-complex forward FFTs producing an N/2+1 complex spectrum
- Complex-to-real inverse FFTs reconstructing an N-sample real signal
- A planner API mirroring RustFFT for creating and reusing transform instances
- Roughly 2x speedups over naive complex FFT for larger real inputs
- Pass-through of RustFFT SIMD feature flags (avx, sse, neon, wasm_simd)
Common Use Cases
- Spectral analysis of audio or sensor signals in a Rust DSP pipeline
- Implementing filters or convolution via frequency-domain multiplication
- Any workload needing efficient forward/inverse FFT of real-valued data
Under The Hood
Architecture - The entire crate is implemented in a single src/lib.rs, exposing a RealFftPlanner that produces RealToComplex and ComplexToReal transform objects. Internally it delegates the heavy lifting to a RustFFT complex FFT (of half the length for even inputs) and adds the packing/unpacking and post-processing that convert between real signals and the half-spectrum representation.
Tech Stack - Rust (edition 2018) with a single runtime dependency on rustfft (>=6.4). Its Cargo feature flags map one-to-one onto RustFFT’s, so consumers can enable AVX, SSE, NEON, or WASM SIMD without RealFFT itself changing. Criterion and rand are used only for benchmarks and tests.
Code Quality - Despite living in one file, the crate is well-tested (tests colocated in lib.rs) and benchmarked via Criterion, with continuous integration on GitHub. The focused scope keeps the implementation readable and auditable.
API Design - The API intentionally mirrors RustFFT’s planner-and-transform pattern, so anyone familiar with RustFFT can adopt RealFFT with almost no learning curve. Transforms are created once and reused, scratch buffers are explicit for zero-allocation hot paths, and docs.rs documentation covers the packing conventions.