# Demystifying DFT-Based Harmonic Phase Estimation, Transformation, and Synthesis
## 2 Robust DFT-Based Phase Estimation of Individual Sinusoids
### DFT and the Sine and Shifted Hanning Windows  
Other windows that provide better main-to-side lobe attenuation compared to the rectangular window are frequently used in spectrum estimation and FIR filter design [15]. Although standard Hamming or Hanning windows could be used in our analysis, we employ two related windows that are particularly significant in perfect reconstruction filter banks [19; 20], such as those that are frequently used in audio coding and general analysis synthesis [21]. One window is known as the sine window and is defined as follows:  
\[w_{S}[n]=\sqrt{w_{H}[n]}=\sin\frac{\pi}{N}(n+0.5),\ n=0,\ldots,N-1\,, \tag{12}\]  
where \(w_{H}[n]\) represents the shifted Hanning window, defined as follows:  
\[w_{H}[n]=\frac{1}{2}\bigg{[}1-\cos\frac{2\pi}{N}(n+0.5)\bigg{]},\ n=0,\ldots, N-1\,. \tag{13}\]  
When the sine window is used in the DFT analysis according to (4), where \(x[n]\) is a noisy sinusoid given by (5), then, using an approach that is similar to that used in the previous subsection, the spectral line corresponding to the relevant local maximum in the magnitude spectrum (\(|X[k_{\ell}]|\)) can be approximated by the following:  
\[X[k_{\ell}]\approx\frac{\Lambda}{4}e^{j\left(\phi_{\ell}-\frac{\pi}{2}+\pi \Delta_{\ell}\left(1-\frac{1}{N}\right)\right)}F(\Delta_{\ell})\, \tag{14}\]  
where we have the following:  
\[F(\Delta_{\ell})=\frac{\sin\pi\left(\Delta_{\ell}+\frac{1}{2}\right)}{\sin \frac{\pi}{N}\left(\Delta_{\ell}+\frac{1}{2}\right)}+\frac{\sin\pi\left( \Delta_{\ell}-\frac{1}{2}\right)}{\sin\frac{\pi}{N}\left(\Delta_{\ell}-\frac {1}{2}\right)}. \tag{15}\]  
Figure 5: Cumulative phase estimation error as a function of the fractional frequency \(\Delta_{\ell}\), when the DFT and the rectangular window are used. In the illustrated cases, \(N=128\), \(\ell=13\), SNR = 30 dB (**left**) and SNR = 10 dB (**right**). In the case of the shifted Hanning window, the local maximum in the magnitude spectrum can be approximated by the following:  
\[X[k_{\ell}]\approx\frac{A}{4}e^{i\left(\phi_{\ell}-\frac{\pi}{2}+\pi\Delta_{\ell }(1-\frac{1}{N})\right)}G(\Delta_{\ell})\, \tag{16}\]  
where we have the following:  
\[G(\Delta_{\ell})=2\frac{\sin\pi\Delta_{\ell}}{\sin\frac{\pi}{N}\Delta_{\ell}}+ \frac{\sin\pi(\Delta_{\ell}+1)}{\sin\frac{\pi}{N}(\Delta_{\ell}+1)}+\frac{\sin \pi(\Delta_{\ell}-1)}{\sin\frac{\pi}{N}(\Delta_{\ell}-1)}. \tag{17}\]  
It can be easily concluded that the \(F(\Delta_{\ell})\) and \(G(\Delta_{\ell})\) functions have the same polarity when \(\Delta_{\ell}\in[-0.5,0.5]\) and, thus, they do not affect the phase in this particular range of \(\Delta_{\ell}\). On the other hand, comparing (14), (16), and (8), when \(k=k_{\ell}\), it can be concluded that the phase is governed by the same function, which is a consequence of the fact that all three windows share the same linear-phase property and the same group delay. This also means that in all three cases, the phase can be estimated using Equation (10), although the quality of the phase estimation depends on each window due to its specific near-end and far-end leakage characteristics. As apparent in Figure 3, the width of the main lobe of the frequency response is \(6\pi\tau/N\) in the case of the sine window, and \(8\pi/N\) in the case of the shifted Hanning window [5, 11]. This implies that, depending on the value of \(\Delta_{\ell}\), at most three spectral lines with non-zero magnitude fall within the main lobe width of the sine window frequency response. In the case of the shifted Hanning window, the number of spectral lines is four. As in the previous subsection, if \(\Delta_{\ell}\in[-0.5,0.5]\), then the spectral line \(k=k_{\ell}\) corresponds to a local maximum in the magnitude spectrum when the sine window or the shifted Hanning window is used. Figure 6 illustrates the case corresponding to the sine window. Although this figure resembles Figure 4, two important aspects are worth noting.