# Demystifying DFT-Based Harmonic Phase Estimation, Transformation, and Synthesis
## 2 Robust DFT-Based Phase Estimation of Individual Sinusoids  
The purpose of this section is to estimate the starting phases (\(\phi_{\ell}\)) of all sinusoids in a harmonic signal, as in (1), after the signal has been subject to simple uniform sampling, as in (3), multiplied by a window (\(w[n]\)); the result is transformed into a discrete-frequency Fourier domain, such as in (4). As shown in Section 1.1 and illustrated in Figures 1 and 2, we rely on a pre-existing harmonic analysis framework that can deliver not only an accurate fundamental frequency estimate (\(\omega_{0}\)) but also harmonic magnitude estimates (\(A_{\ell}\)). In our simulations, in this paper, we use ground-truth test signals such that those parameters are known beforehand. This is equivalent to assuming that these parameters are estimated without error.  
Given a certain magnitude spectrum describing a harmonic signal, it is tempting to think that the estimated harmonic starting phases can be taken as the phases of the DFT spectral lines (or DFT bins) corresponding to local maxima in the magnitude spectrum. In other words, if \(X[k]\), \(k=0,1,\ldots,N-1\) represents the Fourier spectrum of the windowed harmonic signal, and if \(k_{\ell}=\underset{k}{\operatorname{argmax}}|X[k]|\) with \(\ell=0,1,\ldots,L-1\) denotes a DFT bin index representing a local maximum in the magnitude spectrum, and corresponding to harmonic \(\ell\), it is tempting to believe that \(\phi_{\ell}\) can be estimated as \(\hat{\phi}_{\ell}=\angle X[k_{\ell}]\). In fact, this equation is not correct given those estimations must take into consideration the specificity of the time-frequency transformation, the specificity of the window, and the relation between each spectral peak in the magnitude spectrum and fundamental frequency.  
As an important contribution of this paper, this section highlights that phase estimation does not depend on accurate frequency estimation of individual sinusoids. In fact, as stated by [PERSON] and [PERSON], the most practical DFT-based accurate frequency estimators involve a two-step approach: a coarse search followed by a fine search [12]. The first step is almost trivial as it involves only peak picking and the second is what determines the accuracy of the frequency estimator [5]. Usually, sinusoidal magnitude estimation depends on the result of the fine search step in frequency estimation; consequently, the accuracy of the former depends on the accuracy of the latter. In this section, we show that accurate phase estimation does not depend on this fine search step in frequency estimation and, therefore, its accuracy depends mainly on the severity of the signal-to-noise ratio (SNR).  
In order to illustrate different possibilities, we consider six cases that result from the combination of two different DFT-based filter banks and three different windows.  
In order to simplify results and facilitate their comparison, in all six cases, we consider the analysis of one harmonic sinusoid in (1), i.e., after sampling--according to (3)--our signal is as follows:  
\[x[n]=A_{\ell}\sin(\omega_{\ell}n+\phi_{\ell})+s[n]. \tag{5}\]In this equation, we have the following:  
\[\omega_{\ell}=\Omega_{\ell}T_{S}=\frac{2\pi}{N}(k_{\ell}+\Delta_{\ell})\, \tag{6}\]  
where \(k_{\ell}\) represents the bin index (or sub-band channel) corresponding to a local maximum in the magnitude spectrum, and \(\Delta_{\ell}\) represents fractional frequency. Depending on the type of T-F transformation and the window that is used, the continuous interval of \(\Delta_{\ell}\) may be either \([-0.5,0.5[\) or \([0.0,1.0[\). The rationale for this is explained next.