# Measurement of Head-Related Transfer Functions: A Review
## 2 Principle of HRTF Measurements
### Golay Codes
#### 2.2.2 HRTF Measurement with Sweep Signals
In the case of linear sweeps, \(\tau_{G}(f)\) is set by [40]:  
\[\tau_{G}(f)=\tau_{G}(0)+c\ f,\quad\text{with}\quad c=\frac{\tau_{G}(f_{s}/2)- \tau_{G}(0)}{f_{s}/2}, \tag{15}\]  
where \(f_{s}\) is the sampling rate. \(\tau_{G}(0)\) and \(\tau_{G}(f_{s}/2)\) represent the desired group delays at the DC (\(f\) = 0 Hz) and Nyquist frequency (\(f\) = \(f_{s}/2\)), respectively. Then, the phase is calculated as:  
\[ \begin{split}\varphi(f)&=-2\pi\int_{0}^{f}\tau_{G} (\lambda)\ d\lambda\\ &=-2\pi\left(\frac{\tau_{G}(f_{s}/2)-\tau_{G}(0)}{fs}\ f^{2}+ \tau_{G}(0)\ f\right)+\varphi(f_{0}),\end{split}  \tag{16}\]  
where \(\varphi(f_{0})\) is usually set to zero, \(\tau_{G}(0)\) and \(\tau_{G}(f_{s}/2)\) are comprised between 0 and T. Note that the resulting phase at the Nyquist frequency should be zero or \(\pi/2\) to satisfy the condition for spectra of real-time signals [38]. [PERSON] and [PERSON] [37] introduced an offset for the calculated phase to guarantee this condition:  
\[\varphi_{\text{corrected}}(f)=\varphi(f)-\frac{f}{f_{s}/2}\ \varphi\ (f_{s}/2). \tag{17}\]  
The linear sweep in the time domain can be obtained by applying the IFFT to the corrected phase in combination with a constant magnitude spectrum. Moreover, [PERSON] and [PERSON] [37] suggested to choose a FFT block length that is at least twice longer then the desired sweep length to avoid the \"wrap around\" effect [40]. For the exponential sweep signal, \(\tau_{G}(f)\) is defined as [40]:  
\[\tau_{G}(f)=a+b\ \ln(f). \tag{18}\]  
The parameters \(a\) and \(b\) can be calculated based on the start and end frequencies (\(f_{1}\) and \(f_{2}\)) and their desired group delays (\(\tau_{G}(f_{1})\) and \(\tau_{G}(f_{2})\)):  
\[\tau_{G}(f_{1}) =a+b\ \ln(f_{1}), \tag{19}\] \[\tau_{G}(f_{2}) =a+b\ \ln(f_{2}).\]  
In general, \(f_{1}\) is set as the first frequency bin of the FFT and \(f_{2}\) is set to the Nyquist frequency (\(f_{s}/2\)). Then, the corresponding phase can be calculated as:  
\[\varphi(f) =-2\pi\int_{f_{0}}^{f}\tau_{G}(\lambda)\ d\lambda \tag{20}\] \[=-2\pi\left[f\left(a+b\ (\ln(f)-1)\right)-f_{0}\ (a+b\ (\ln(f_{0})-1)) \right]+\varphi(f_{0}),\]  
where \(f_{0}\) is a small non-zero value (\(f_{0}>0\)), and the replacement of the lower limit of the integral by \(f_{0}\) instead of zero is due to the asymptotic property of the \(\ln\) function (\(\ln(0)\rightarrow-\infty\)). The calculated phase should further be corrected by applying Equation (17). Different from the linear sweep, the magnitude of the exponential sweep \(X(f)\) decreases \(3\,\mathrm{dB}/\,\mathrm{octave}\), which can be expressed as a linear function by using logarithmic magnitude and frequency scales:  
\[20\ \log_{10}|X(f)|=c+d\ \log_{10}(f), \tag{21}\]  
where the coefficients \(c\) and \(d\) can be determined based on the start and end frequencies (\(f_{1}\) and \(f_{2}\)) and the slope of the linear function (\(-3\,\mathrm{dB}/\,\mathrm{octave}\)). After that, the exponential sweep signal in the time domain can be reconstructed by applying the IFFT to the synthesized spectrum. Properties of Sweep Techniques  
HRTFs can generally be derived based on the excitation signal and the recorded ear signals by applying the linear deconvolution method in the frequency domain. Alternatively, HRIRs can directly be obtained by convolving the recorded signals with the inverse of the excitation signal in the time domain, which is particularly suitable for the deconvolution of sweep signals [41]. The inverse filter of the linear sweep is exactly its time-reversed version due to the constant magnitude, while the inverse filter of the exponential sweep is its time-reversed version with a modified magnitude spectrum [41]. One major advantage of the sweep method is the discrimination of harmonic distortion products in the measured impulse response caused by nonlinearities of the measurement system.