Metadata-Version: 2.1
Name: torchsubband
Version: 0.0.3
Summary: This package is written for constructing subband features.
Home-page: https://github.com/haoheliu/torchsubband
Author: Haohe Liu
Author-email: haoheliu@gmail.com
License: MIT
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=3.6.0
Description-Content-Type: text/markdown
License-File: LICENSE


# torchsubband

This's a package for subband decomposition. 

It can transform waveform into three kinds of subband feature representations. 

[![483sBQ.png](https://z3.ax1x.com/2021/09/19/483sBQ.png)](https://imgtu.com/i/483sBQ)

## Reconstruction loss

The following table shows the reconstruction quality. We tried a set of audio to conduct subband decomposition and reconstruction.


| Subbands |  L1loss   | PESQ  | SiSDR|
| :----: | :----: | :----: | :----:
| 2 | 1e-6  | 4.64 | 61.8 |
| 4 | 1e-6  | 4.64 | 58.9 |
| 8 | 5e-5  | 4.64 | 58.2 |

You can also test this program by training the following test script. It will give you some evaluation output.

```python
from torchsubband import test
test()
```

## Usage

```python
from torchsubband import SubbandDSP
import torch

model = SubbandDSP(subband=2)
batchsize=3
channel=1
length = 44100*2
input = torch.randn((batchsize,channel,length))

# Get subband waveform
subwav = model.wav_to_sub(input)
reconstruct_1 = model.sub_to_wav(subwav,length=length)

# Get subband magnitude spectrogram
sub_spec,cos,sin = model.wav_to_spectrogram_phase(input)
reconstruct_2 = model.spectrogram_phase_to_wav(sub_spec,cos,sin,length=length)

# Get subband complex spectrogram
sub_complex_spec = model.wav_to_complex_sub_spec(input)
reconstruct_3 = model.complex_sub_spec_to_wav(sub_complex_spec,length=length)
```


