qdft


Nameqdft JSON
Version 0.5 PyPI version JSON
download
home_pagehttps://github.com/jurihock/qdft
SummaryConstant-Q Sliding DFT
upload_time2023-01-28 22:17:20
maintainer
docs_urlNone
authorJuergen Hock
requires_python>=3
licenseMIT
keywords digital audio signal processing dasp sliding discrete fourier transform constant-q cqt qdft sdft stft dft fft frequency spectrum algorithms analysis synthesis c cpp python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Constant-Q Sliding DFT in C++ and Python (QDFT)

![language](https://img.shields.io/badge/languages-C%2B%2B%20Python-blue)
![license](https://img.shields.io/github/license/jurihock/sdft?color=green)
![pypi](https://img.shields.io/pypi/v/qdft?color=gold)

Forward and inverse Constant-Q Sliding DFT according to [[1]](#1) with following features:

- Arbitrary octave resolution ([quarter tone](https://en.wikipedia.org/wiki/Quarter_tone) by default)
- Built-in parameterizable cosine family window (Hann by default)
- Customizable time and frequency domain data type in C++
- Endless single or multiple sample processing at once
- Optional analysis latency control parameter
- Real-time analysis and synthesis capability

The Constant-Q Sliding Discrete Fourier Transform (QDFT) is a recursive approach to compute the Fourier transform sample by sample. This is an efficient implementation without the FFT calculus. Just define an arbitrary frequency range and octave resolution to obtain the corresponding DFT estimate. In contrast to the linear [SDFT](https://github.com/jurihock/sdft), frequency bins of the QDFT are logarithmically spaced. Thus, both high and low frequencies are resolved with the same quality, which is particularly useful for audio analysis. Based on the QDFT, a chromagram feature with detailed instantaneous frequency estimation is planned for the future release.

## WIP

- [x] Readme
- [ ] Docstrings
- [x] PyPI package [qdft](https://pypi.org/project/qdft)
- [ ] Sliding [chromagram](https://en.wikipedia.org/wiki/Chroma_feature) as a bonus (a draft is already included in the Python package)

## Basic usage

### C++

```c++
#include <qdft/qdft.h> // see also src/cpp folder

double sr = 44100;                             // sample rate in hertz
std::pair<double, double> bw = { 50, sr / 2 }; // lowest and highest frequency in hertz to be resolved
double r = 24;                                 // octave resolution, e.g. number of DFT bins per octave

QDFT<float, double> qdft(sr, bw, r); // create qdft plan for custom time and frequency domain data types

size_t n = ...;         // number of samples
size_t m = qdft.size(); // number of dft bins

float* x = ...; // analysis samples of shape (n)
float* y = ...; // synthesis samples of shape (n)

std::complex<double>* dft = ...; // dft matrix of shape (n, m)

qdft.qdft(n, x, dft);  // extract dft matrix from input samples
qdft.iqdft(n, dft, y); // synthesize output samples from dft matrix
```

The time domain data type defaults to `float` and the frequency domain data type to `double`.

### Python

```python
from qdft import QDFT # see also src/python folder

sr = 44100        # sample rate in hertz
bw = (50, sr / 2) # lowest and highest frequency in hertz to be resolved
r = 24            # octave resolution, e.g. number of DFT bins per octave

qdft = QDFT(sr, bw, r) # create qdft plan

n = ...       # number of samples
m = qdft.size # number of dft bins (if need to know in advance)

x = ... # analysis samples of shape (n)

dft = qdft.qdft(x)  # extract dft matrix of shape (n, m) from input samples
y = qdft.iqdft(dft) # synthesize output samples from dft matrix
```

Feel free to obtain current version from [PyPI](https://pypi.org/project/qdft) by executing `pip install qdft`.

## Examples

| QDFT | Chroma12 |
| :--: | :------: |
| ![SDFT](https://github.com/jurihock/qdft/raw/main/examples/face.png) | ![STFT](https://github.com/jurihock/qdft/raw/main/examples/cmajor.png) |
| [face.py](https://github.com/jurihock/qdft/blob/main/examples/face.py) | [cmajor.py](https://github.com/jurihock/qdft/blob/main/examples/cmajor.py) |
| ![SDFT](https://github.com/jurihock/qdft/raw/main/examples/face.wav.png) | ![STFT](https://github.com/jurihock/qdft/raw/main/examples/cmajor.wav.png) |

## See also

If you're interested in Sliding DFT with *linear* frequency resolution, don't forget to browse my [jurihock/sdft](https://github.com/jurihock/sdft) project!

## References

1. <span id="1">Russell Bradford et al. (2008). Sliding with a Constant Q. International Conference on Digital Audio Effects. https://www.dafx.de/paper-archive/2008/papers/dafx08_63.pdf</span>

2. <span id="2">Russell Bradford et al. (2005). Sliding is Smoother Than Jumping. International Computer Music Conference Proceedings. http://hdl.handle.net/2027/spo.bbp2372.2005.086</span>

3. <span id="3">Eric Jacobsen and Peter Kootsookos (2007). Fast, Accurate Frequency Estimators. IEEE Signal Processing Magazine. https://ieeexplore.ieee.org/document/4205098</span>

## License

[github.com/jurihock/qdft](https://github.com/jurihock/qdft) is licensed under the terms of the MIT license.
For details please refer to the accompanying [LICENSE](https://github.com/jurihock/qdft/raw/main/LICENSE) file distributed with it.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jurihock/qdft",
    "name": "qdft",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3",
    "maintainer_email": "",
    "keywords": "digital,audio,signal,processing,dasp,sliding,discrete,fourier,transform,constant-q,cqt,qdft,sdft,stft,dft,fft,frequency,spectrum,algorithms,analysis,synthesis,c,cpp,python",
    "author": "Juergen Hock",
    "author_email": "juergen.hock@jurihock.de",
    "download_url": "https://files.pythonhosted.org/packages/1d/08/5e6ea71b7c2e22da0103b7d51c86adafe8a4c0264e0f58cde41796ae94dc/qdft-0.5.tar.gz",
    "platform": null,
    "description": "# Constant-Q Sliding DFT in C++ and Python (QDFT)\n\n![language](https://img.shields.io/badge/languages-C%2B%2B%20Python-blue)\n![license](https://img.shields.io/github/license/jurihock/sdft?color=green)\n![pypi](https://img.shields.io/pypi/v/qdft?color=gold)\n\nForward and inverse Constant-Q Sliding DFT according to [[1]](#1) with following features:\n\n- Arbitrary octave resolution ([quarter tone](https://en.wikipedia.org/wiki/Quarter_tone) by default)\n- Built-in parameterizable cosine family window (Hann by default)\n- Customizable time and frequency domain data type in C++\n- Endless single or multiple sample processing at once\n- Optional analysis latency control parameter\n- Real-time analysis and synthesis capability\n\nThe Constant-Q Sliding Discrete Fourier Transform (QDFT) is a recursive approach to compute the Fourier transform sample by sample. This is an efficient implementation without the FFT calculus. Just define an arbitrary frequency range and octave resolution to obtain the corresponding DFT estimate. In contrast to the linear [SDFT](https://github.com/jurihock/sdft), frequency bins of the QDFT are logarithmically spaced. Thus, both high and low frequencies are resolved with the same quality, which is particularly useful for audio analysis. Based on the QDFT, a chromagram feature with detailed instantaneous frequency estimation is planned for the future release.\n\n## WIP\n\n- [x] Readme\n- [ ] Docstrings\n- [x] PyPI package [qdft](https://pypi.org/project/qdft)\n- [ ] Sliding [chromagram](https://en.wikipedia.org/wiki/Chroma_feature) as a bonus (a draft is already included in the Python package)\n\n## Basic usage\n\n### C++\n\n```c++\n#include <qdft/qdft.h> // see also src/cpp folder\n\ndouble sr = 44100;                             // sample rate in hertz\nstd::pair<double, double> bw = { 50, sr / 2 }; // lowest and highest frequency in hertz to be resolved\ndouble r = 24;                                 // octave resolution, e.g. number of DFT bins per octave\n\nQDFT<float, double> qdft(sr, bw, r); // create qdft plan for custom time and frequency domain data types\n\nsize_t n = ...;         // number of samples\nsize_t m = qdft.size(); // number of dft bins\n\nfloat* x = ...; // analysis samples of shape (n)\nfloat* y = ...; // synthesis samples of shape (n)\n\nstd::complex<double>* dft = ...; // dft matrix of shape (n, m)\n\nqdft.qdft(n, x, dft);  // extract dft matrix from input samples\nqdft.iqdft(n, dft, y); // synthesize output samples from dft matrix\n```\n\nThe time domain data type defaults to `float` and the frequency domain data type to `double`.\n\n### Python\n\n```python\nfrom qdft import QDFT # see also src/python folder\n\nsr = 44100        # sample rate in hertz\nbw = (50, sr / 2) # lowest and highest frequency in hertz to be resolved\nr = 24            # octave resolution, e.g. number of DFT bins per octave\n\nqdft = QDFT(sr, bw, r) # create qdft plan\n\nn = ...       # number of samples\nm = qdft.size # number of dft bins (if need to know in advance)\n\nx = ... # analysis samples of shape (n)\n\ndft = qdft.qdft(x)  # extract dft matrix of shape (n, m) from input samples\ny = qdft.iqdft(dft) # synthesize output samples from dft matrix\n```\n\nFeel free to obtain current version from [PyPI](https://pypi.org/project/qdft) by executing `pip install qdft`.\n\n## Examples\n\n| QDFT | Chroma12 |\n| :--: | :------: |\n| ![SDFT](https://github.com/jurihock/qdft/raw/main/examples/face.png) | ![STFT](https://github.com/jurihock/qdft/raw/main/examples/cmajor.png) |\n| [face.py](https://github.com/jurihock/qdft/blob/main/examples/face.py) | [cmajor.py](https://github.com/jurihock/qdft/blob/main/examples/cmajor.py) |\n| ![SDFT](https://github.com/jurihock/qdft/raw/main/examples/face.wav.png) | ![STFT](https://github.com/jurihock/qdft/raw/main/examples/cmajor.wav.png) |\n\n## See also\n\nIf you're interested in Sliding DFT with *linear* frequency resolution, don't forget to browse my [jurihock/sdft](https://github.com/jurihock/sdft) project!\n\n## References\n\n1. <span id=\"1\">Russell Bradford et al. (2008). Sliding with a Constant Q. International Conference on Digital Audio Effects. https://www.dafx.de/paper-archive/2008/papers/dafx08_63.pdf</span>\n\n2. <span id=\"2\">Russell Bradford et al. (2005). Sliding is Smoother Than Jumping. International Computer Music Conference Proceedings. http://hdl.handle.net/2027/spo.bbp2372.2005.086</span>\n\n3. <span id=\"3\">Eric Jacobsen and Peter Kootsookos (2007). Fast, Accurate Frequency Estimators. IEEE Signal Processing Magazine. https://ieeexplore.ieee.org/document/4205098</span>\n\n## License\n\n[github.com/jurihock/qdft](https://github.com/jurihock/qdft) is licensed under the terms of the MIT license.\nFor details please refer to the accompanying [LICENSE](https://github.com/jurihock/qdft/raw/main/LICENSE) file distributed with it.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Constant-Q Sliding DFT",
    "version": "0.5",
    "split_keywords": [
        "digital",
        "audio",
        "signal",
        "processing",
        "dasp",
        "sliding",
        "discrete",
        "fourier",
        "transform",
        "constant-q",
        "cqt",
        "qdft",
        "sdft",
        "stft",
        "dft",
        "fft",
        "frequency",
        "spectrum",
        "algorithms",
        "analysis",
        "synthesis",
        "c",
        "cpp",
        "python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2dd9e4c8e8a1e7a9d27cb4aa000824336698279eb634c374d6f97650fda81d56",
                "md5": "bf3b28baaad1ee016f35d0397eab62a0",
                "sha256": "78284c4df70c3c14036965e909d9b85966336491f5ce22d06cd6334e4d70b118"
            },
            "downloads": -1,
            "filename": "qdft-0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bf3b28baaad1ee016f35d0397eab62a0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3",
            "size": 9189,
            "upload_time": "2023-01-28T22:17:18",
            "upload_time_iso_8601": "2023-01-28T22:17:18.774157Z",
            "url": "https://files.pythonhosted.org/packages/2d/d9/e4c8e8a1e7a9d27cb4aa000824336698279eb634c374d6f97650fda81d56/qdft-0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1d085e6ea71b7c2e22da0103b7d51c86adafe8a4c0264e0f58cde41796ae94dc",
                "md5": "e21c22e97ccb96506abe581a1b2c6a7e",
                "sha256": "0178074a0a8c13eb3dd3e38096631c62348ed8a694f31ebf2a40c7d261c79dd9"
            },
            "downloads": -1,
            "filename": "qdft-0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "e21c22e97ccb96506abe581a1b2c6a7e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3",
            "size": 9849,
            "upload_time": "2023-01-28T22:17:20",
            "upload_time_iso_8601": "2023-01-28T22:17:20.665273Z",
            "url": "https://files.pythonhosted.org/packages/1d/08/5e6ea71b7c2e22da0103b7d51c86adafe8a4c0264e0f58cde41796ae94dc/qdft-0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-28 22:17:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "jurihock",
    "github_project": "qdft",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "qdft"
}
        
Elapsed time: 0.03575s