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

Bug in FFT windowing #286

Open
tom-huntington opened this issue Jun 21, 2022 · 1 comment
Open

Bug in FFT windowing #286

tom-huntington opened this issue Jun 21, 2022 · 1 comment

Comments

@tom-huntington
Copy link

tom-huntington commented Jun 21, 2022

You windowing for the fft when calculating the mfccs is incorrect, which will reduce performance a little (dtw seems very robust). The default runtime configuration results in frame_length = 1600 which is greater than fft_order = 512. However, this results in the last frame_length - fft_order = 1088 elements being chopped off the hamming window. You actual window is only the first third of the hamming window, which is a very bad choice of window.

frame_length_padded = max(frame_length, self.fft_order)

self.hamming_window = numpy.hamming(frame_length_padded)

besides the point, this should be

self.hamming_window = numpy.hamming(frame_length) 

Your padding is appended only after you do the windowing

fft = numpy.fft.rfft(frame, self.fft_order)

Same with the c code.

hamming_coefficients = _precompute_hamming(frame_length);

if (_apply_hamming(frame, frame_length, hamming_coefficients) != CMFCC_SUCCESS) {

#ifdef USE_FFTW
// fftw code
if (_compute_power_fftw(frame, power, fft_order, plan) != CMFCC_SUCCESS) {
return CMFCC_FAILURE;
}
#else
// own code
if (_compute_power(frame, power, fft_order, sin_table_full, sin_table_half) != CMFCC_SUCCESS) {
return CMFCC_FAILURE;
}
#endif

@tom-huntington
Copy link
Author

tom-huntington commented Jun 21, 2022

It's hard to say what to change, for accuracy I imagine you would want keep the window_length the same so this requires a higher fft order, however for speed you would want to keep the fft_order down which I imagine is how this incorrectness came about.

I think the best solution is to do away with the windowing all together i.e. use the rectangular window as it's the widest

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

1 participant