# Understanding Hertz

This question is in two parts, both related in some way or another.

Suppose I have a signal where the sample rate is 44100 and compute a normal 1D DFT on this signal. The size of this signal is 220500. I need to compute the Hertz for the outputted DFT.

I calculate the bins using the formula below:

sqrt(output[i].re * output[i]. re + output[i].im * output[i].im)


I then find the maximum number in this vector and compute the following:

freq = max * 44100 / fft.size()


This then gives me a result of: 4526.84

I don't know, something seems to be wrong here, the duration of the file is 0:05 is this result expected or unexpected? I'm sure I need to take into account the number of seconds, but I was lead to believe that the resulting answer should be that of the sample rate (44100)

Question 2:

Let's suppose I've computed a STFT of this signal of size 256 with an overlap of 128, let's suppose I want to calculate the frequency of each of these segments, or, parts, since this will now effectively be a 2D vector. Do I therefore need to calculate this using the formula above, where the FFT size in this case will infact be 256.

Any help would be greatly appreciated :)

• Why did you think that the result should be the sample rate? Jan 9 '14 at 21:30
• @JimClay I don't really know. I just picked this up as an observation. I made a simple mono sine wave at 500Hz and got: 10146.4 as a result.. So need to re-think where I'm going wrong Jan 9 '14 at 21:34

$$Freq = \frac{binNumber}{numberOfBins}F_s$$
• How do you mean? This currently isn't working. I generated a 10hz sound file from: audiocheck.net/audiofrequencysignalgenerator_sinetone.php ... The max index is: 440895 where the size is 441001.. My calculation therefore: 440895 * 44100 / 441001 = 44089.4 So where am I going wrong here? Jan 9 '14 at 22:29