qdft

Constant-Q Sliding DFT in C++, Rust and Python

https://github.com/jurihock/qdft

Science Score: 64.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: ieee.org
  • Committers with academic emails
    1 of 2 committers (50.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.3%) to scientific vocabulary

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
Last synced: 4 months ago · JSON representation ·

Repository

Constant-Q Sliding DFT in C++, Rust and Python

Basic Info
  • Host: GitHub
  • Owner: jurihock
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 2.48 MB
Statistics
  • Stars: 39
  • Watchers: 3
  • Forks: 3
  • Open Issues: 7
  • Releases: 1
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
Created about 3 years ago · Last pushed about 2 years ago
Metadata Files
Readme License Citation

README.md

Constant-Q Sliding DFT in C++, Rust, and Python

language license pypi creates

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

  • Arbitrary octave resolution (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 quality control parameter to smoothly reduce low frequency bandwidth and improve the time resolution
  • 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, 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
  • [x] Rust package qdft
  • [ ] Sliding chromagram as a bonus (a draft is already included in the Python package)

Basic usage

C++

```c++

include // see also cpp folder

double sr = 44100; // sample rate in hertz std::pair 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 qdft(sr, bw, r); // create qdft plan for custom time and frequency domain data types

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

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

std::complex* 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.

Rust

```rust use qdft::QDFT; // see also rust folder

// just a shortcut for our complex number type

[allow(noncamelcase_types)]

type c64 = num::complex::Complex;

// zero number trait, e.g. c64::zero() use num::Zero;

let samplerate = 44100.0; // sample rate in hertz let bandwidth = (50.0, samplerate / 2.0); // lowest and highest frequency in hertz to be resolved let resolution = 24.0; // octave resolution, e.g. number of DFT bins per octave let latency = 0.0; // analysis latency adjustment between -1 and +1 let window = Some((0.5, -0.5)); // hann window coeffs

// create qdft plan for custom time and frequency domain data types let mut qdft = QDFT::::new( samplerate, bandwidth, resolution, latency, window);

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

let mut x = vec![f32::zero(); n]; // analysis samples of shape (n) let mut y = vec![f32::zero(); n]; // synthesis samples of shape (n)

let mut dft = vec![c64::zero(); n * m]; // dft matrix of shape (n, m)

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

Alternatively use ndarray instead of a flat array to allocate the DFT matrix, as shown in the analysis.rs example.

Python

```python from qdft import QDFT # see also 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 by executing pip install qdft.

Examples

| QDFT | Chroma12 | | :--: | :------: | | SDFT | STFT | | face.py | cmajor.py | | SDFT | STFT |

See also

If you're interested in Sliding DFT with linear frequency resolution, don't forget to browse my jurihock/sdft project!

References

  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

  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

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

License

github.com/jurihock/qdft is licensed under the terms of the MIT license. For details please refer to the accompanying LICENSE file distributed with it.

Owner

  • Name: Jürgen Hock
  • Login: jurihock
  • Kind: user
  • Location: Karlsruhe, Germany
  • Company: Fraunhofer

❤️ Open Source, DSP, Audio FX

Citation (CITATION.cff)

cff-version: 1.2.0
title: "Constant-Q Sliding DFT in C++ and Python (QDFT)"
authors:
  - family-names: Hock
    given-names: Juergen
url: https://github.com/jurihock/qdft
license: MIT
type: software
message: >-
  If you use this software, please cite it
  using the metadata from this file.
references:
  - title: "Sliding with a Constant Q"
    authors:
      - family-names: Bradford
        given-names: Russell
    url: https://www.dafx.de/paper-archive/2008/papers/dafx08_63.pdf
    type: article
  - title: "Sliding is Smoother Than Jumping"
    authors:
      - family-names: Bradford
        given-names: Russell
    url: http://hdl.handle.net/2027/spo.bbp2372.2005.086
    type: article
  - title: "Fast, Accurate Frequency Estimators"
    authors:
      - family-names: Jacobsen
        given-names: Eric
      - family-names: Kootsookos
        given-names: Peter
    url: https://ieeexplore.ieee.org/document/4205098
    doi: 10.1109/MSP.2007.361611
    type: article

GitHub Events

Total
  • Watch event: 7
  • Fork event: 1
Last Year
  • Watch event: 7
  • Fork event: 1

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 75
  • Total Committers: 2
  • Avg Commits per committer: 37.5
  • Development Distribution Score (DDS): 0.013
Top Committers
Name Email Commits
Jürgen Hock j****k@j****e 74
hk j****k@i****e 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 5 months ago

All Time
  • Total issues: 10
  • Total pull requests: 2
  • Average time to close issues: 3 days
  • Average time to close pull requests: about 8 hours
  • Total issue authors: 2
  • Total pull request authors: 1
  • Average comments per issue: 1.1
  • Average comments per pull request: 1.0
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • jurihock (7)
  • TF3RDL (2)
Pull Request Authors
  • stellarpower (1)
Top Labels
Issue Labels
enhancement (4)
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • cargo 1,403 total
    • pypi 31 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 0
    (may contain duplicates)
  • Total versions: 6
  • Total maintainers: 2
pypi.org: qdft

Constant-Q Sliding DFT

  • Versions: 5
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 31 Last month
Rankings
Dependent packages count: 6.6%
Stargazers count: 19.5%
Average: 20.3%
Downloads: 21.6%
Forks count: 23.2%
Dependent repos count: 30.6%
Maintainers (1)
Last synced: 5 months ago
crates.io: qdft

Constant-Q Sliding DFT

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 1,403 Total
Rankings
Dependent repos count: 28.2%
Stargazers count: 29.9%
Forks count: 30.7%
Dependent packages count: 32.7%
Average: 44.1%
Downloads: 98.9%
Maintainers (1)
Last synced: 5 months ago

Dependencies

rust/Cargo.toml cargo
  • ndarray 0.15.* development
  • ndarray-npy 0.8.* development
  • num 0.4.*
python/pyproject.toml pypi