{"id":16693408,"url":"https://github.com/jurihock/qdft","last_synced_at":"2025-03-17T00:33:26.668Z","repository":{"id":65190647,"uuid":"585716947","full_name":"jurihock/qdft","owner":"jurihock","description":"Constant-Q Sliding DFT in C++, Rust and Python","archived":false,"fork":false,"pushed_at":"2023-11-28T10:47:09.000Z","size":2603,"stargazers_count":31,"open_issues_count":7,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-13T16:31:06.480Z","etag":null,"topics":["algorithms","audio","audio-processing","constant-q","constant-q-transform","cpp","cqt","dft","digital-signal-processing","dsp","fft","library","python","qdft","rust","sdft","signal-processing","sliding-dft","variable-q","vqt"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jurihock.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-05T22:17:29.000Z","updated_at":"2024-08-15T16:58:45.000Z","dependencies_parsed_at":"2023-11-28T11:49:58.178Z","dependency_job_id":null,"html_url":"https://github.com/jurihock/qdft","commit_stats":{"total_commits":75,"total_committers":2,"mean_commits":37.5,"dds":"0.013333333333333308","last_synced_commit":"6d0bdce17d967fbd7cebc57a15979f1d6d7b8732"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jurihock%2Fqdft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jurihock%2Fqdft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jurihock%2Fqdft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jurihock%2Fqdft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jurihock","download_url":"https://codeload.github.com/jurihock/qdft/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221669503,"owners_count":16860895,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithms","audio","audio-processing","constant-q","constant-q-transform","cpp","cqt","dft","digital-signal-processing","dsp","fft","library","python","qdft","rust","sdft","signal-processing","sliding-dft","variable-q","vqt"],"created_at":"2024-10-12T16:30:21.732Z","updated_at":"2024-10-27T11:36:46.637Z","avatar_url":"https://github.com/jurihock.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Constant-Q Sliding DFT in C++, Rust, and Python\n\n![language](https://img.shields.io/badge/languages-C%2B%2B%20Rust%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![creates](https://img.shields.io/crates/v/qdft?color=gold)\n\nForward and inverse Constant-Q Sliding DFT (QDFT) 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 quality control parameter to smoothly reduce low frequency bandwidth and improve the time resolution\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- [x] Rust package [qdft](https://crates.io/crates/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 \u003cqdft/qdft.h\u003e // see also cpp folder\n\ndouble sr = 44100;                             // sample rate in hertz\nstd::pair\u003cdouble, double\u003e 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\u003cfloat, double\u003e 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\u003cdouble\u003e* 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### Rust\n\n```rust\nuse qdft::QDFT; // see also rust folder\n\n// just a shortcut for our complex number type\n#[allow(non_camel_case_types)]\ntype c64 = num::complex::Complex\u003cf64\u003e;\n\n// zero number trait, e.g. c64::zero()\nuse num::Zero;\n\nlet samplerate = 44100.0;                 // sample rate in hertz\nlet bandwidth = (50.0, samplerate / 2.0); // lowest and highest frequency in hertz to be resolved\nlet resolution = 24.0;                    // octave resolution, e.g. number of DFT bins per octave\nlet latency = 0.0;                        // analysis latency adjustment between -1 and +1\nlet window = Some((0.5, -0.5));           // hann window coeffs\n\n// create qdft plan for custom time and frequency domain data types\nlet mut qdft = QDFT::\u003cf32, f64\u003e::new(\n    samplerate,\n    bandwidth,\n    resolution,\n    latency,\n    window);\n\nlet n = ...;         // number of samples\nlet m = qdft.size(); // number of dft bins\n\nlet mut x = vec![f32::zero(); n]; // analysis samples of shape (n)\nlet mut y = vec![f32::zero(); n]; // synthesis samples of shape (n)\n\nlet mut dft = vec![c64::zero(); n * m]; // dft matrix of shape (n, m)\n\nqdft.qdft(\u0026x, \u0026mut dft);  // extract dft matrix from input samples\nqdft.iqdft(\u0026dft, \u0026mut y); // synthesize output samples from dft matrix\n```\n\nAlternatively use [ndarray](https://github.com/rust-ndarray/ndarray) instead of a flat array to allocate the DFT matrix, as shown in the `analysis.rs` example.\n\n### Python\n\n```python\nfrom qdft import QDFT # see also 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/python/examples/face.png) | ![STFT](https://github.com/jurihock/qdft/raw/main/python/examples/cmajor.png) |\n| [face.py](https://github.com/jurihock/qdft/blob/main/python/examples/face.py) | [cmajor.py](https://github.com/jurihock/qdft/blob/main/python/examples/cmajor.py) |\n| ![SDFT](https://github.com/jurihock/qdft/raw/main/python/examples/face.wav.png) | ![STFT](https://github.com/jurihock/qdft/raw/main/python/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. \u003cspan id=\"1\"\u003eRussell 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\u003c/span\u003e\n\n2. \u003cspan id=\"2\"\u003eRussell Bradford et al. (2005). Sliding is Smoother Than Jumping. International Computer Music Conference Proceedings. http://hdl.handle.net/2027/spo.bbp2372.2005.086\u003c/span\u003e\n\n3. \u003cspan id=\"3\"\u003eEric Jacobsen and Peter Kootsookos (2007). Fast, Accurate Frequency Estimators. IEEE Signal Processing Magazine. https://ieeexplore.ieee.org/document/4205098\u003c/span\u003e\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjurihock%2Fqdft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjurihock%2Fqdft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjurihock%2Fqdft/lists"}