A PyTorch implementation of the Modified Discrete Cosine Transform (MDCT) and its inverse for audio processing.
Project description
torch_mdct
PyTorch implementation of Modified Discrete Cosine Transform and Inverse Modified Discrete Cosine Transform.
Installation
pip install torch_mdct
Usage
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] Zaf-Python: Zafar's Audio Functions in Python for audio signal analysis.
[2] MDCT: A fast MDCT implementation using SciPy and FFTs.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
torch_mdct-0.1.0.tar.gz
(3.0 MB
view details)
Built Distribution
File details
Details for the file torch_mdct-0.1.0.tar.gz
.
File metadata
- Download URL: torch_mdct-0.1.0.tar.gz
- Upload date:
- Size: 3.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f3b454bfb7a8ee4954e8d5c045d5906340799c349846b8b03fcb6d2abcdacb3 |
|
MD5 | c90a7fb748a2e8ce5e8f5d124b5f25d5 |
|
BLAKE2b-256 | 8fb0eaa9a7b48f5ffc1dac51d06e14e27fb3382ea891e24f39667ca3286182d3 |
File details
Details for the file torch_mdct-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: torch_mdct-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7933f1265bc95bd595d4fc2e606a5c89ab49a2874b74359294b9764f49accca1 |
|
MD5 | 2d04455ad5ec3836fc75e39a78d53fa2 |
|
BLAKE2b-256 | cb4c0645cfdcae6fa39cb9ebe97c7bcc309585ac330da9f7e282e08850dfd65c |