Skip to content

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

License

Notifications You must be signed in to change notification settings

Kinyugo/torch_mdct

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published