pytfd_compat/README.md

73 lines
1.9 KiB
Markdown

# pytfd-compat
`pytfd-compat` is a Python 3 compatibility layer for the small `pytfd` API
surface in this repository. It keeps the original centered-window STFT behavior
available while fixing the weak points in the older ports:
- explicit padding behavior
- consistent window construction
- tests for the core transforms
- example programs that exercise the API
## Replacement assessment
Modern libraries already cover parts of the old `pytfd` feature set:
- SciPy provides production-quality STFT and ISTFT support.
- librosa provides a higher-level STFT API for audio workflows.
- `tftb` provides a larger collection of time-frequency distributions.
Those are useful building blocks, but none is a clean drop-in replacement for
the legacy `pytfd` module layout and its dense centered-window STFT semantics.
This package therefore implements the original transforms directly and uses
modern SciPy window generation where it helps.
## Licensing and provenance
The original upstream codebase was located at `code.google.com/archive/p/pytfd/`
and is MIT licensed. This compatibility package preserves that lineage while
modernizing the implementation for Python 3.
## What is included
- `pytfd_compat.stft.stft`
- `pytfd_compat.stft.spec`
- `pytfd_compat.wd.wd`
- `pytfd_compat.pwd.pwd`
- `pytfd_compat.sm.sm`
- `pytfd_compat.windows.get_window`
- validation scripts comparing against SciPy and, when installed, `tftb`
## Install
```bash
python -m pip install -e ./pytfd_compat
```
## Test
```bash
cd pytfd_compat
pytest
```
## Validation
```bash
cd pytfd_compat
PYTHONPATH=src python validation/run_validation.py
```
This runs reproducible comparisons against SciPy's `ShortTimeFFT` and reports
alignment, numerical differences, and timing. If `tftb` is installed, the same
script can extend the comparison set.
## Examples
```bash
python examples/basic_stft.py
python examples/distributions_demo.py
```
If `matplotlib` is installed, the examples can also render images.