Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Constant Q #314

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Feature: Constant Q #314

wants to merge 1 commit into from

Conversation

hughrawlinson
Copy link
Member

This is a sketch, it doesn't work and there are no tests, and it'll fail existing tests. I don't know what the term i is in the formula, and it's missing a windowing function. It'll also require some parameterization on the Meyda object that isn't there already. I think we should do that after rationalizing Meyda's interface a little better, it's very 2015 at the moment.

@nevosegal
Copy link
Collaborator

I quickly looked at the equation. i is the imaginary unit (or √-1) and the equation is basically the DFT equation, but with different bins (makes sense - that's what constant-Q transform is). I am wondering if there is a way to transform our FFT output directly to constant-Q, instead of calculating it from the time-domain - could be more efficient. Will report back.

@hughrawlinson
Copy link
Member Author

hughrawlinson commented Jan 16, 2020

Oh, that i.

🤦

There is! There's a paper from Judith Brown about this. She wrote two papers close together, and the latter was in published 1991 on an efficient implementation of constant q based on fft. The second paper is here. The code in this PR is based on the algorithm in the first paper. We should definitely prefer the second paper. I just couldn't figure out the math. So I implemented the first algorithm and shared it as a PR so we could at least see code. The problem this feature extractor presents is that it has specific parameters, unlike most of the other ones, so we need to extend the Meyda object. That doesn't change based on the implementation.

I also tried to implement one based on one of librosa's implementations. They have several, and an inverse cqt. That makes me think it's worth putting the cqt in its own package, like jsfft. If you have time, I would love if you could compare the algorithms used in librosa.

@pkl
Copy link

pkl commented Oct 31, 2020

I would love this in Meyda. Can't find any constant Q extractors for JavaScript that I can use in Node...

@hughrawlinson hughrawlinson changed the base branch from master to main October 31, 2021 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants