# Length of Hamming Window to Resolve a Harmonic

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). 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? Thanks.

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.figure()
plt.plot(freqHz,np.abs(Xwin[0:NposFreqs]))
plt.xlabel('Frequency [Hz]')
plt.ylabel('Magnitude')
plt.title('Signal magnitude specturm, N = '+str(N))
plt.show()