Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zeroby0/mdctn
Multidimensional Modified Discrete Cosine Transforms in Python
https://github.com/zeroby0/mdctn
dct lapped-orthogonal-transform mdct signal-processing
Last synced: about 2 months ago
JSON representation
Multidimensional Modified Discrete Cosine Transforms in Python
- Host: GitHub
- URL: https://github.com/zeroby0/mdctn
- Owner: zeroby0
- Created: 2022-12-09T08:16:32.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-12-14T06:59:47.000Z (about 2 years ago)
- Last Synced: 2024-10-10T21:21:05.456Z (3 months ago)
- Topics: dct, lapped-orthogonal-transform, mdct, signal-processing
- Language: Python
- Homepage:
- Size: 30.3 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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, imdctx = 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 corex = 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)