I am trying to answer the question:

"Given a single-sourced pitch signal with a fundamental frequency of 440Hz and a sampling rate of 44100Hz how long should the Hamming window of the STFT analysis be to resolve the harmonics of the signal"

My understanding of resolving a harmonic is to ensure the frequency is represented in the frequency domain e.g. the top graph plots the sum of 4 sinusoids in the time domain. The bottom graph shows 4 distinct frequency peaks in the frequency domain (4 harmonics are resolved).

enter image description here

For the question, I use the below code to calculate the STFT of a sinusoid with 440hz frequency. Trying length 10 vs 100, based on the logic above I would say N=10 does not resolve the harmonic while N=100 does.

Is this correct? Is there a mathematical intuition for calculating the length that will resolve a harmonic?

Comparing Hamming Window Lengths


import numpy as np
from matplotlib import pyplot as plt

SR = 44100 #Sampling rate (sometimes denoted as fs)
T = 1/SR #Time step in secs
t = np.arange(0,1,T) #A 1 second array arrange intp 44100 samples

##Sinusoid parameters
f = 400 #Frequency
A = 1 #Amplitude
x = A*np.sin(2*np.pi*f*t) #sinusoid equation

N = 100 #Hamming window of length N (this is what we want to optimize)
win = np.hamming(N)
ind = np.arange(0,N,1)
Window_sig = x[ind]*win #multiplying our first N samples by our window

Xwin = np.fft.fft(windowSig)
NposFreqs = round(N/2)+1 
freqHz = ind[0:NposFreqs]*SR/N

plt.xlabel('Frequency [Hz]')
plt.title('Signal magnitude specturm, N = '+str(N))


1 Answer 1


Around 1000 samples to resolve the psychoacoustic pitch of concert A.

The fundamental period of 440 Hz is just over 100 samples at a sample rate of 44100. But humans typically need somewhere around the range 6 to 10 pitch periods to hear a pitched sound instead of noise or clicks. Since FFT windows attenuate the edges of the waveform, using the larger number of periods (10) is likely more reliable in matching human perception.

So I'd use a 1024 length FFT for initial testing.

To inspect higher harmonics if you already know the exact pitch frequency, you could use a shorter window, at least 2 pitch periods for a Hamming window, and zero pad after windowing to use a much longer DFT that is an exact integer multiple (say 16X) of the pitch period in length.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.