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

Smarter downsampling for vqt and friends #1679

Open
bmcfee opened this issue Feb 27, 2023 · 0 comments
Open

Smarter downsampling for vqt and friends #1679

bmcfee opened this issue Feb 27, 2023 · 0 comments
Labels
enhancement Does this improve existing functionality? functionality Does this add new functionality?

Comments

@bmcfee
Copy link
Member

bmcfee commented Feb 27, 2023

Is your feature request related to a problem? Please describe.

The VQT function (which powers cqt and the like) recursively downsamples the input signal by factors of 2 to compute one octave worth of frequencies at a time at the lowest feasible sampling rates (subject to integral hop length constraints, etc):

# Iterate down the octaves
my_y, my_sr, my_hop = y, sr, hop_length
for i in range(n_octaves):
# Slice out the current octave of filters
if i == 0:
sl = slice(-n_filters, None)
else:
sl = slice(-n_filters * (i + 1), -n_filters * i)
# This may be incorrect with early downsampling
freqs_oct = freqs[sl]
fft_basis, n_fft, _ = __vqt_filter_fft(
my_sr,
freqs_oct,
filter_scale,
norm,
sparsity,
window=window,
gamma=gamma,
dtype=dtype,
alpha=alpha,
)

There's an assumption in CQT/VQT that all octaves have a fixed number of bins (except maybe the first/last), but this really isn't necessary.

Describe the solution you'd like
We could instead compute a set of feasible sampling rates, and then divide up the basis frequencies into whatever sampling rate range is most reasonable. This change should be invisible to the user for the currently supported use cases.

However, restructuring the code in this way would relax the constraint that each octave has an equal number of frequencies, which in turn should allow for basically arbitrary frequency sets. This, I think, would fully resolve #18 .

@bmcfee bmcfee added enhancement Does this improve existing functionality? functionality Does this add new functionality? labels Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Does this improve existing functionality? functionality Does this add new functionality?
Development

No branches or pull requests

1 participant