Skip to main content

A PyTorch implementation of the Modified Discrete Cosine Transform (MDCT) and its inverse for audio processing.

Project description

torch_mdct

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

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


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.4.0.tar.gz (3.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

torch_mdct-0.4.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file torch_mdct-0.4.0.tar.gz.

File metadata

  • Download URL: torch_mdct-0.4.0.tar.gz
  • Upload date:
  • Size: 3.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for torch_mdct-0.4.0.tar.gz
Algorithm Hash digest
SHA256 734b4092ccf72f1fe6005da24f8e1e19ace6ad94e0ec927a17bb70ddcd426990
MD5 235077c3a4f4d5fbae06434866554bd8
BLAKE2b-256 c838c0db2642cd3661841572c471af01beec2c1fed4ae48377dabb8fe6f28b67

See more details on using hashes here.

File details

Details for the file torch_mdct-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: torch_mdct-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for torch_mdct-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b21e559bc56b0de9bfbde7d1e591e713749772cdb4f45137a4f686506282703d
MD5 9efea1f11bc678b7175f776fe7d9c5e0
BLAKE2b-256 d69b668f4d5dcdf9f566f8a5dbeb6bd350ece08cb1a8b085ea7c01109104bf57

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page