# Harmonic Product Spectrum algorithm. I dont understand one step

I was looking some Harmonic Product Spectrum algorithm examples and I came up with this:

//Implement Harmonic Product Spectrum
for(k = 0; k < buffer_size / 8; k++)
{
sum[k] = magFFT[k] * magFFT[2*k] * magFFT[3*k];
// find fundamental frequency (maximum value in plot)
if( sum[k] > max_value2 && k > 0 )
{
max_value2 = sum[k];
fund_freq = k;
}
}
fund_freq1 = fund_freq * 8000 / buffer_size;

What I dont understand is the reason behind the last line, I tested it and it works but I couldn't find an explanation for that multiplication. Can anyone help me please?

Source of code: SOURCE

• is your sampling rate 16 kHz or 8 kHz, by any chance? – Marcus Müller Aug 15 '17 at 19:22
• It's 8kHz, you have any ideas? – Sebastian Araneda Aug 15 '17 at 19:26
• Based on your reply to Marcus' comment, it converts the found DFT index $k$ into the analog frequency in Hertz for a hardwired(?) sampling frequency of 8000 Hz, where buffersize shall denote the DFT length $N$. – Fat32 Aug 15 '17 at 19:35
• sorta interesting pitch detection algorithm. it won't work right if there is a missing fundamental (but other odd harmonics are present). – robert bristow-johnson Aug 15 '17 at 23:53