Skip to main content

Multidimensional Modified Discrete Cosine Transforms

Project description

MDCTN :yarn:

Multidimensional Modified Discrete Cosine Transforms

pip install mdctn
  • 1-D MDCT & IMDCT
  • n-D MDCT & IMDCT
  • Windowing support
  • Helper functions for signals

Known bugs: Not all window sizes work: 12, 24, 28 don't work. Bug in arithmetic.

1-D MDCT on signals

Signals are wrapped around so all the data is stored in the same number of bits.

import numpy as np
from mdctn import mdct, imdct

x = np.arange(24)

y =  mdct(x, N=16)
z = imdct(y, N=16)

np.allclose(x, z) # True

1-D Pure MDCT

The core MDCT function

import numpy as np
from mdctn import core

x = np.arange(6) # [0, 1, 2, 3, 4, 5]

y_1 = core.mdct(x[0:4]) # [-2.50104055, -0.49476881]
y_2 = core.mdct(x[2:6]) # [-4.34879961, -1.26013568]

z_1 = core.imdct(y_1) # [-0.5,  0.5,  2.5,  2.5]
z_2 = core.imdct(y_2) #             [-0.5,  0.5,  4.5,  4.5]

z = (z_1[2:4] + z_2[0:2]) # [2.0, 3.0]

Benchmarks

See benchmarks.ipynb

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

mdctn-0.2.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

mdctn-0.2.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mdctn-0.2.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.6 Linux/6.0.6-76060006-generic

File hashes

Hashes for mdctn-0.2.0.tar.gz
Algorithm Hash digest
SHA256 baa877134aa155632fb39f70dfe7250d3275cafd89f26b0a700db2c358038d37
MD5 1f172d1b51f098bb3e2f26fcc27aa4fc
BLAKE2b-256 2d491bc413d840ffd03fa62f06ce5e5d2af1dea2db45f9e57ac493158ccd138e

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: mdctn-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.6 Linux/6.0.6-76060006-generic

File hashes

Hashes for mdctn-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b8f07ba3b2639ce4361ded95c37827054d2afe221b108e11a7540154627a3dde
MD5 4e56568fc297d689530e6ab28f36178b
BLAKE2b-256 33c67c69454645136dd5047e6774939c947ec839508df30fe0611549c4934ea4

See more details on using hashes here.

Provenance

Supported by

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