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.2.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.2.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for torch_mdct-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2a7eed822944207eba112747792ba332fc6dfd1d8a22138486a65a680a8c1e01
MD5 5c98e8c81820bed10aafebb153485353
BLAKE2b-256 6bebb6f8b397ea8764935044942ddc1ea970446c4136c3f04fd7fe0e03f7a81c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: torch_mdct-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for torch_mdct-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 63948a496596aefe435306c88f56a8314eb548763904fcc881d9d4715e9aa274
MD5 ca14f42aaf10d8bb750e92e354e75a06
BLAKE2b-256 5a1860a4c03a22f48f4034a3c6e59e0fce4732827a002dca5179a3b0244d88b8

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