So I have a frequency response (got it by windowed fft-ing) of a note E4 played on a guitar and now I'm trying to implement a dynamic threshold for finding the peaks (fundamental frequency of the note and its harmonics).
I found an article that describes doing it by convolving normalized Hamming window with the frequency response. Now, I've done it, but I just don't know how to plot it correctly as the convoluted signal is delayed for a few samples like this (the red one):
Here's the code in Scilab:
// plot the frequency response
x_axis = linspace(0, Fs, row);
plot(x_axis(1 : $/2), win_response);
// calculate convolution on each window, siggram_n is just normalized
// matrix of windowed freq. response
[rows_sig, cols] = size(siggram_n);
conv = [];
for i = 1 : cols
conv = [conv (convol(siggram_n(:, i), win_response))'];
end
// calculate the average of all convolutions
[rows, cols] = size(ko);
conv_n = [];
for i = 1 : rows
conv_n = [conv_n sum(conv(i, :))/cols];
end
// raise to the power of 0.7 to flatten the threshold - from the article
conv_n = conv_n .^ 0.7;
// plot the convoluted signal
x_axis = linspace(0, Fs, 2*length(conv_n));
plot(x_axis(1 : $/2), conv_n, 'red');
It's not only important that I know how to plot this, because I'll need to find the peaks, so I have to somehow "synchronize" both signals. What am I doing wrong?