🚀 AVILA-FFT: Production-Ready FFT Library
High-performance Fast Fourier Transform library and CLI tool in pure Rust
- 🔥 Zero external dependencies - Pure Rust implementation
- ⚡ Multi-threaded - Up to 4x speedup with parallel processing
- 💾 Streaming support - Process multi-GB files with constant memory
- 🎯 Production-ready - Professional CLI tool included
- 📊 STFT & Spectrograms - Complete time-frequency analysis
- 🔬 Scientific accuracy - Extensively tested (42 tests passing)
🎬 Quick Start
As a Library
[]
= "0.1.0"
use *;
// Simple FFT
let signal = vec!;
let planner = new?;
let spectrum = planner.process_real?;
// STFT with spectrogram
let config = overlap_75;
let processor = new?;
let spectrogram = processor.process?;
As a CLI Tool
# Install
# Generate test signal
# Analyze with advanced features
# Create spectrogram
# Run benchmarks
✨ Features
Core FFT
- Cooley-Tukey algorithm - Iterative in-place implementation
- Real and complex FFT - Optimized for both data types
- Generic floating-point - Support for
f32andf64 - Twiddle factor caching - Reduced redundant computations
- Bit-reversal optimization - Cache-friendly permutation
STFT & Time-Frequency Analysis
- Short-Time Fourier Transform - Complete STFT/ISTFT implementation
- Window functions - Hann, Hamming, Blackman, Blackman-Harris
- Configurable overlap - 50%, 75%, 87.5% presets
- Spectral features - Centroid, bandwidth, flatness, rolloff
- Phase analysis - Coherence and stability metrics
- Harmonic detection - Automatic peak finding
- SNR estimation - Temporal signal-to-noise ratio
Scalability ⚡
Parallel Processing
use *;
let config = default;
let processor = new;
// Process batch of 100 signals with 4x speedup
let results = processor.process_batch;
Benchmarks:
- FFT batch (100 signals, size 4096): 4x speedup with 4 threads
- STFT (5s audio): 1.07x speedup with 2 threads
- Near-linear scaling for large workloads
Streaming for Large Files
use *;
let config = default;
let mut processor = new;
// Process multi-GB file with constant memory
processor.process_file?;
Performance:
- 37x realtime throughput (16K buffer)
- Constant memory usage (processes 10GB files with 64MB RAM)
- Configurable buffer sizes for optimal I/O
See PERFORMANCE.md for detailed benchmarks and optimization guide.
📊 Performance
FFT Benchmarks
| Operation | Size | Time | Throughput |
|---|---|---|---|
| Forward FFT | 1024 | 0.05 ms | 20 million/s |
| Forward FFT | 4096 | 0.63 ms | 6.5 million/s |
| Inverse FFT | 1024 | 0.05 ms | 20 million/s |
STFT Benchmarks
| Signal | Frames | Process Time | Inverse Time |
|---|---|---|---|
| 1s audio | 61 | 15 ms | 8 ms |
| 5s audio | 317 | 67 ms | 41 ms |
Parallel Speedup
| Workload | Serial | Parallel (4 threads) | Speedup |
|---|---|---|---|
| 100 FFTs (4096) | 149 ms | 37 ms | 4.0x |
| 50 FFTs (2048) | 43 ms | 25 ms | 1.7x |
Streaming Performance
| Buffer | Throughput | Realtime Factor |
|---|---|---|
| 16K samples | 612K samples/s | 37x |
| 4K samples | 169K samples/s | 10x |
🛠️ CLI Tool
Professional-grade command-line interface for signal analysis:
Commands
generate- Create test signals (chirp, tone, sweep, noise, impulse)analyze- Complete STFT analysis with optional featuresspectrogram- Export time-frequency data to CSVbenchmark- Performance testing
Advanced Analysis Features
# Harmonic analysis
# Phase coherence
# Temporal SNR
# All features combined
Output Formats
- CSV export with metadata headers
- Multiple formats: magnitude, power, phase, dB scale
- Configurable frequency range for targeted analysis
- Pipeline-friendly for batch processing
See CLI.md for complete documentation.
🔬 Scientific Validation
Test Coverage
- 42 tests passing (35 core + 7 STFT + parallel + streaming)
- Zero external dependencies - No test framework bloat
- Numerical accuracy - ε < 1e-10 for f64
- Edge cases covered - Power-of-2 validation, empty signals, etc.
ISTFT Reconstruction Quality
Signal → STFT → ISTFT → Recovered Signal
Signal-to-Noise Ratio: 308.8 dB
- Virtually perfect reconstruction
- Validates overlap-add algorithm
- Proves Parseval's theorem compliance
Benchmark Methodology
# Release mode compilation (critical!)
# Run comprehensive benchmarks
# Individual feature tests
📚 Documentation
- README.md - This file (overview and quick start)
- CLI.md - Complete CLI reference and examples
- PERFORMANCE.md - Detailed benchmarks and optimization guide
- API Docs - Generated from source (docs.rs)
🎯 Use Cases
1. Audio Analysis
- Spectral analysis of music and speech
- Harmonic detection and tracking
- Time-frequency visualization
- Pitch estimation and melody extraction
2. Signal Processing
- Real-time FFT for embedded systems
- Batch processing of sensor data
- Frequency domain filtering
- Spectral feature extraction
3. Scientific Computing
- Educational purposes (pure Rust FFT)
- Prototyping DSP algorithms
- Integration into larger systems
- Research and experimentation
4. Production Workloads
- Large-scale audio processing pipelines
- Server-side signal analysis
- Distributed computing with streaming
- High-performance batch jobs
🚀 Roadmap
Current (v0.1.0)
- ✅ Core FFT (Cooley-Tukey)
- ✅ STFT & Spectrograms
- ✅ Parallel processing
- ✅ Streaming for large files
- ✅ Professional CLI tool
- ✅ Zero dependencies
Planned (v0.2.0)
- 🔲 SIMD optimizations (2-4x additional speedup)
- 🔲 Pitch detection (autocorrelation)
- 🔲 DCT/DST transforms
- 🔲 Bluestein algorithm (non-power-of-2)
- 🔲 Wavelets
Future (v1.0.0)
- 🔲 GPU acceleration via WGPU
- 🔲 WebAssembly support
- 🔲 Real-time processing mode
- 🔲 Audio file I/O (WAV, FLAC)
📖 Examples
Basic FFT
use *;
// Create a simple sine wave
let signal: =
.map
.collect;
// FFT
let planner = new?;
let spectrum = planner.process_real?;
// Find peak frequency
let magnitudes: = spectrum.iter.map.collect;
let peak_bin = magnitudes.iter
.enumerate
.max_by
.map
.unwrap;
let peak_freq = peak_bin as f64 * sample_rate / 1024.0;
println!; // ~10 Hz
STFT Spectrogram
use *;
// Generate chirp signal
let sample_rate = 16384.0;
let duration = 2.0;
let signal: =
.map
.collect;
// STFT
let config = overlap_75;
let processor = new?;
let spec = processor.process?;
// Extract features
let centroid = spec.spectral_centroid;
let bandwidth = spec.spectral_bandwidth;
let flatness = spec.spectral_flatness;
println!;
Parallel Batch Processing
use *;
// Create batch of signals
let signals: =
.map
.collect;
// Process in parallel
let config = default; // Auto-detect CPU cores
let processor = new;
let results = processor.process_batch;
println!;
Streaming Large Files
use *;
// Stream-process a huge file
let config = StreamConfig ;
let mut processor = new;
let mut max_magnitude = 0.0;
processor.process_file?;
println!;
🤝 Contributing
Contributions welcome! Areas of interest:
- SIMD optimizations (AVX2, NEON)
- Additional window functions
- GPU acceleration
- Wavelet transforms
- Documentation improvements
- Bug reports and feature requests
📜 License
MIT License - see LICENSE for details.
🙏 Acknowledgments
- Cooley-Tukey FFT algorithm - Classic butterfly-based approach
- Rust community - For excellent tooling and ecosystem
- Pure Rust philosophy - Zero external dependencies maintained
📞 Contact
- Crates.io: https://crates.io/crates/avila-fft
- Issues: GitHub repository (coming soon)
- Documentation: https://docs.rs/avila-fft
Built with ❤️ in Rust • Zero Dependencies • Production Ready
Last updated: December 2025 • Version 0.1.0