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 PyTorch implementation of the Modified Discrete Cosine Transform (MDCT) and its inverse for audio processing.

Installation

pip install torch_mdct

Usage

import torchaudio
from torch_mdct import IMDCT, MDCT, kaiser_bessel_derived, vorbis

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

# Initialize the mdct and imdct transforms
mdct = MDCT(win_length=1024, window_fn=vorbis, window_kwargs=None, center=True)
imdct = IMDCT(win_length=1024, window_fn=vorbis, window_kwargs=None, center=True)

# 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.1.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.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: torch_mdct-0.4.1.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.1.tar.gz
Algorithm Hash digest
SHA256 61282b3679b07a8a4671601d9251d9a74e2cf1a24eab4fd51eae707d9d6c6137
MD5 ae88a53e8cb3f8e5e33bdfcd620edd2c
BLAKE2b-256 e96da65d5e09b791833493cf3b3b017d29b00f567f880a704fd518585c9f8c4c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: torch_mdct-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 6.2 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 67a3863260ba7115e55e15e6cef02d19c343d3f0ecd32f8a16e8626663078c5d
MD5 5a040c02b1e185e91c5bcdd9f7e3fd99
BLAKE2b-256 28cd28f348cfb3590946b5929acbfc80669da49050a8871b91c2206386c98928

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