Metadata-Version: 2.4
Name: fast-short-time-fft
Version: 0.1.0
Summary: Fast Short-Time FFT — vectorized, bit-identical to scipy.signal.ShortTimeFFT, 7× faster
Author-email: yonikremer <yonikremer@example.com>
License: MIT
Project-URL: Homepage, https://github.com/yonikremer/fast-short-time-fft
Project-URL: Issues, https://github.com/yonikremer/fast-short-time-fft/issues
Keywords: stft,short-time-fft,spectrogram,audio,scipy
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Multimedia :: Sound/Audio
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: numpy>=1.22
Requires-Dist: scipy>=1.9

# fast-short-time-fft

**Fast Short-Time FFT — 7× faster than `scipy.signal.ShortTimeFFT`, bit-identical.**

Vectorized, CPU-only (pocketfft, no GPU). One batched `rfft` per signal vs per-slice Python loop.

```py
from fast_short_time_fft import FastShortTimeFFT
import numpy as np

SFT = FastShortTimeFFT(win=np.hanning(256), hop=64, fs=8000)  # same API as scipy
Sx = SFT.stft(x)  # (129, p_num) — exact as scipy, 7× faster
# or
from fast_short_time_fft import stft
Sx = stft(x, win=np.hanning(256), hop=64, fs=8000)
```

For 1k wavs (8kHz, avg 2s, 250k frames): **0.66s** vs scipy **3.3s** (median, incl. I/O).

Repo: https://github.com/yonikremer/fast-short-time-fft

## Install

```bash
pip install fast-short-time-fft
```

## CLI

```bash
fast-stft sounds/*.wav --hop 64 --mfft 256 --workers 6
```

## Why faster

Scipy loops `for p in 250k: rfft(x_*win)` in Python (10µs overhead per 256-pt FFT). This batches all `p_num` frames per file: `pad → as_strided view → frames*win → rfft(workers=6).T` — 1k Python calls vs 250k, one AVX `*win`, one batched C FFT with 6 threads. Same `pad`/`win`/`rfft` math → `max err 0`.

## License

MIT
