1- ![ crates.io] ( https://img.shields.io/crates/v/stft-rs.svg )
21# stft-rs
32
4- High-quality, streaming-friendly STFT/iSTFT implementation in Rust working with raw slices ( ` &[f32] ` ).
3+ [ ![ crates.io ] ( https://img.shields.io/crates/v/stft-rs.svg )] ( https://crates.io/crates/stft-rs ) [ ![ Documentation ] ( https://docs.rs/stft-rs/badge.svg )] ( https://docs.rs/stft-rs ) [ ![ MIT ] ( https://img.shields.io/badge/License-MIT-blue.svg )] ( https://github.com/wizenink/stft-rs/LICENSE )
54
5+ High-quality, streaming-friendly STFT/iSTFT implementation in Rust working with raw slices (` &[f32] ` ).
66
77> [ !CAUTION]
8- > This crate is a WIP, expect API changes and breakage until first stable version
8+ > This crate is a WIP, expect API changes and breakage until first stable version
99
1010## Features
1111
@@ -111,6 +111,7 @@ use stft_rs::prelude::*;
111111```
112112
113113This exports:
114+
114115- Core types: ` BatchStft ` , ` BatchIstft ` , ` StreamingStft ` , ` StreamingIstft ` , ` StftConfig ` , ` StftConfigBuilder ` , ` Spectrum ` , ` SpectrumFrame `
115116- Type aliases: ` StftConfigF32/F64 ` , ` StftConfigBuilderF32/F64 ` , ` BatchStftF32/F64 ` , ` BatchIstftF32/F64 ` , ` StreamingStftF32/F64 ` , ` StreamingIstftF32/F64 ` , ` SpectrumF32/F64 ` , ` SpectrumFrameF32/F64 `
116117- Mel types: ` MelConfig ` , ` MelSpectrum ` , ` BatchMelSpectrogram ` , ` StreamingMelSpectrogram ` , ` MelScale ` , ` MelNorm ` (+ F32/F64 aliases)
@@ -207,6 +208,7 @@ loop {
207208```
208209
209210** Batch mode:**
211+
210212``` rust
211213let mut spectrum = Spectrum :: new (num_frames , freq_bins );
212214let mut output = Vec :: new ();
@@ -235,7 +237,6 @@ loop {
235237}
236238```
237239
238-
239240## Configuration
240241
241242### Creating Custom Configurations
@@ -272,6 +273,7 @@ let config = StftConfigBuilderF32::new()
272273```
273274
274275** Legacy API (deprecated):**
276+
275277``` rust
276278// Old constructor still works but is deprecated
277279let config = StftConfig :: new (
@@ -291,13 +293,15 @@ let config = StftConfig::new(
291293### Reconstruction Modes
292294
293295#### OLA (Overlap-Add)
296+
294297- Window applied on forward transform only
295298- No window on inverse transform
296299- Normalizes by accumulated window energy: ` sum(w) `
297300- ** Use for** : Spectral processing, modification, filtering
298301- ** Requires** : COLA (Constant Overlap-Add) condition
299302
300303#### WOLA (Weighted Overlap-Add)
304+
301305- Window applied on both forward and inverse transforms
302306- Normalizes by accumulated window squared: ` sum(w²) `
303307- ** Use for** : Standard analysis/resynthesis
@@ -467,6 +471,7 @@ X[k,n] = Σ x[n + m] * w[m] * e^(-j2πkm/N)
467471```
468472
469473Where:
474+
470475- ` x[n] ` : Input signal
471476- ` w[m] ` : Window function
472477- ` N ` : FFT size
@@ -476,11 +481,13 @@ Where:
476481### iSTFT Reconstruction
477482
478483** OLA Mode:**
484+
479485```
480486x[n] = Σ IFFT(X[k,m]) / Σ w[n - m*hop]
481487```
482488
483489** WOLA Mode:**
490+
484491```
485492x[n] = Σ IFFT(X[k,m]) * w[n - m*hop] / Σ w²[n - m*hop]
486493```
@@ -497,15 +504,16 @@ cargo test --lib -- --nocapture
497504```
498505
499506Tests verify:
500- - NOLA/COLA condition validation
501- - Batch OLA roundtrip (>138 dB SNR)
502- - Batch WOLA roundtrip (>138 dB SNR)
503- - Streaming OLA roundtrip (>138 dB SNR)
504- - Streaming WOLA roundtrip (>138 dB SNR)
505- - Batch vs streaming consistency
506- - All window functions (Hann, Hamming, Blackman)
507- - Constant signal reconstruction
508- - Padding modes (reflect, zero, edge)
507+
508+ - NOLA/COLA condition validation
509+ - Batch OLA roundtrip (>138 dB SNR)
510+ - Batch WOLA roundtrip (>138 dB SNR)
511+ - Streaming OLA roundtrip (>138 dB SNR)
512+ - Streaming WOLA roundtrip (>138 dB SNR)
513+ - Batch vs streaming consistency
514+ - All window functions (Hann, Hamming, Blackman)
515+ - Constant signal reconstruction
516+ - Padding modes (reflect, zero, edge)
509517
510518## Dependencies
511519
@@ -519,6 +527,7 @@ Tests verify:
519527## Contributing
520528
521529Contributions welcome! Areas for improvement:
530+
522531- [ ] Additional window functions (Kaiser, Gaussian)
523532- [ ] SIMD optimizations
524533- [ ] GPU acceleration support
0 commit comments