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

Fractional Octave Smoothing #34

Open
nico-franco-gomez opened this issue Aug 22, 2024 · 2 comments
Open

Fractional Octave Smoothing #34

nico-franco-gomez opened this issue Aug 22, 2024 · 2 comments

Comments

@nico-franco-gomez
Copy link

Hi! I was looking at the implementation of the fractional octave smoothing function and stumbled across this line.

win = np.hamming(k_hi-k_lo) # hamming is good because never 0

I believe it has a bug because the spectrum is expected to be linearly-spaced. This window definition will have linear-axis symmetry but not the log-axis one, which is expected for the fractional octave smoothing (the highest point of the window lies in the arithmetic mean between the indices, but the geometric mean would be the right one...)

@chris-hld
Copy link
Owner

Hi! That's an interesting point -
I believe the smoothing is done in linear spacing (therefore with a symmetrical window), and only the plotting then in log-spacing.
Do you have an example where that fails/shows an issue?

@nico-franco-gomez
Copy link
Author

nico-franco-gomez commented Dec 20, 2024

Hi Chris. I plotted the current window for center frequency $f_c = 1$ kHz and octave fraction $k = 1$ ($f_{l} = 707$ Hz and $f_h = 1414$ Hz) with both linear and logarithmic frequency axis (only difference is the x-axis, data is the same). Like I said, the current window computation is wrong from the log-axis symmetry perspective if the frequency vector is something different than logarithmic. In this minimal example, I compared a linear frequency vector with a logarithmic one. This whole thing is actually independent of the axis used for plotting.

One can see, the corrected window looks kind of warped in the linear frequency axis, but is symmetrical for the logarithmic plot. Moreover, the center frequency of the current window is, as stated, the arithmetic mean between the two extreme points, which is always a bit larger than the geometric mean. The geometric mean would be the right one though.

7faa62f9-f9c6-4745-8e7b-f429bd653d48

I think you can solve this by defining the window on a logarithmic scale and then interpolating it to whatever the current frequency axis is (this effectively maps the correct window to the input's frequency vector).

Hit me up if I wasn't clear or if you spot some mistake in my logic :) and sorry for the ugly x-axis on the logarithmic plot, I got bored of fighting with matplotlib for such a tiny thing hahaha

PS: Here's a nice paper explaining the topic more in depth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants