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.3.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.3.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: torch_mdct-0.3.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.3.0.tar.gz
Algorithm Hash digest
SHA256 e828e92422ea3eee37b2ddb633a8f21e1b5931fc0f7828e4f26dbb9c2a099622
MD5 351e3cdc07abbdd9d18c009dde7f076f
BLAKE2b-256 3b57a02de0cd926b029a7d24efc3231302c7161e9c4c4dae5faa2249c3c162ad

See more details on using hashes here.

File details

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

File metadata

  • Download URL: torch_mdct-0.3.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.9.20

File hashes

Hashes for torch_mdct-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 468a0a5632505c0f0c6bdff0d4c70fab87fc5c08d0ed7f660143bf232b744561
MD5 2258f232c8d0aac2a13be79606d05df8
BLAKE2b-256 846f87b9dcd8daefdb0500349378bfadb1aecfafc2834b0ef6fd97eeaef22027

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