Metadata-Version: 2.3
Name: torch_mdct
Version: 0.3.0
Summary: A PyTorch implementation of the Modified Discrete Cosine Transform (MDCT) and its inverse for audio processing.
Project-URL: Homepage, https://github.com/Kinyugo/torch_mdct
Project-URL: Issues, https://github.com/Kinyugo/torch_mdct/issues
Author-email: Kinyugo Maina <kinyugomaina@gmail.com>
Keywords: audio,imdct,mdct,pytorch,signal processing
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.8
Requires-Dist: torch
Provides-Extra: notebook
Requires-Dist: ipython; extra == 'notebook'
Requires-Dist: matplotlib; extra == 'notebook'
Description-Content-Type: text/markdown

# torch_mdct

A fast and clean implementation of the Modified Discrete Cosine Transform (MDCT) algorithm in PyTorch.

## Installation 

```bash
pip install torch_mdct
```

## Usage

```python
import torchaudio
from torch_mdct import MDCT, IMDCT

# Load a sample waveform 
waveform, sample_rate = torchaudio.load("/path/to/audio.file")

# Initialize the mdct and imdct transforms
mdct = MDCT(win_length=2048)
imdct = IMDCT(win_length=2048)

# Transform waveform into mdct spectrogram
spectrogram = mdct(waveform)

# Transform spectrogram back to audio 
reconst_waveform = imdct(spectrogram)

# Compute the differences
print(f"L1: {(waveform - reconst_waveform).abs().mean()}")
```

## References 
[[1]](https://github.com/zafarrafii/Zaf-Python) Zaf-Python: Zafar's Audio Functions in **Python** for audio signal analysis.

[[2]](https://github.com/nils-werner/mdct) MDCT: A fast MDCT implementation using SciPy and FFTs.