# MDCTN :yarn:
Multidimensional [Modified Discrete Cosine Transforms](https://en.wikipedia.org/wiki/Modified_discrete_cosine_transform)
```bash
pip install mdctn
```
- [x] 1-D MDCT & IMDCT
- [ ] n-D MDCT & IMDCT
- [ ] Windowing support
- [x] Helper functions for signals
### 1-D MDCT on signals
Signals are [wrapped around](https://github.com/zeroby0/mdctn/discussions/1)
so all the data is stored in the same number of bits.
``` python
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
``` python
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](./benchmarks.ipynb)
Raw data
{
"_id": null,
"home_page": "https://github.com/zeroby0/mdctn.git",
"name": "mdctn",
"maintainer": "Aravind Reddy Voggu",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "aravind.reddy@iiitb.org",
"keywords": "MDCT,DCT,FFT,lapped,signal-processing,lapped-orthogonal-transform",
"author": "Aravind Reddy Voggu",
"author_email": "aravind.reddy@iiitb.org",
"download_url": "https://files.pythonhosted.org/packages/7b/bd/5057e24afe00c373c8a4836dbdfe64f6ada8d6843f24cb8f399c20624616/mdctn-0.3.1.tar.gz",
"platform": null,
"description": "# MDCTN :yarn:\n\nMultidimensional [Modified Discrete Cosine Transforms](https://en.wikipedia.org/wiki/Modified_discrete_cosine_transform)\n\n```bash\npip install mdctn\n```\n\n- [x] 1-D MDCT & IMDCT\n- [ ] n-D MDCT & IMDCT\n- [ ] Windowing support\n- [x] Helper functions for signals\n\n\n\n### 1-D MDCT on signals\n\nSignals are [wrapped around](https://github.com/zeroby0/mdctn/discussions/1)\nso all the data is stored in the same number of bits.\n\n``` python\nimport numpy as np\nfrom mdctn import mdct, imdct\n\nx = np.arange(24)\n\ny = mdct(x, N=16)\nz = imdct(y, N=16)\n\nnp.allclose(x, z) # True\n```\n\n### 1-D Pure MDCT\n\nThe core MDCT function\n\n``` python\nimport numpy as np\nfrom mdctn import core\n\nx = np.arange(6) # [0, 1, 2, 3, 4, 5]\n\ny_1 = core.mdct(x[0:4]) # [-2.50104055, -0.49476881]\ny_2 = core.mdct(x[2:6]) # [-4.34879961, -1.26013568]\n\nz_1 = core.imdct(y_1) # [-0.5, 0.5, 2.5, 2.5]\nz_2 = core.imdct(y_2) # [-0.5, 0.5, 4.5, 4.5]\n\nz = (z_1[2:4] + z_2[0:2]) # [2.0, 3.0]\n```\n\n### Benchmarks\n\nSee [benchmarks.ipynb](./benchmarks.ipynb)\n\n\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Multidimensional Modified Discrete Cosine Transforms",
"version": "0.3.1",
"split_keywords": [
"mdct",
"dct",
"fft",
"lapped",
"signal-processing",
"lapped-orthogonal-transform"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "893502b9d5e8a651ec1aaa22af25b52d",
"sha256": "995f2d38837a561620d2d8b2fcee0df68e8bcc3f350246b273b160efdd219e47"
},
"downloads": -1,
"filename": "mdctn-0.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "893502b9d5e8a651ec1aaa22af25b52d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 6400,
"upload_time": "2022-12-14T06:58:47",
"upload_time_iso_8601": "2022-12-14T06:58:47.570081Z",
"url": "https://files.pythonhosted.org/packages/38/18/ee403696812f1f77666e130cbaf5c492cc3b6acfb4ee7095c18d2bd1f825/mdctn-0.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "c7e798794a25c665f3b3b333c178ff99",
"sha256": "4ebf0501fe17d17d9e22803c7d0e7d447cf7ca08676d6554bc040d92ca564384"
},
"downloads": -1,
"filename": "mdctn-0.3.1.tar.gz",
"has_sig": false,
"md5_digest": "c7e798794a25c665f3b3b333c178ff99",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 3455,
"upload_time": "2022-12-14T06:58:49",
"upload_time_iso_8601": "2022-12-14T06:58:49.602620Z",
"url": "https://files.pythonhosted.org/packages/7b/bd/5057e24afe00c373c8a4836dbdfe64f6ada8d6843f24cb8f399c20624616/mdctn-0.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-14 06:58:49",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "zeroby0",
"github_project": "mdctn.git",
"lcname": "mdctn"
}