# Low-Order Spherical Harmonic HRTF Restoration Using a Neural Network Approach
## 2 Spherical Harmonic HRTF Interpolation  
HRTF interpolation can be done in many different ways, including using inverse-distance weighting and spherical splines in the time or frequency domains or manifold learning [19, 20, 21, 22, 23]. However, SH interpolation is one of the more elegant methods which has a more standardised procedure and shows promising results [23]. HRTF sets are recorded in the time domain as Head Related Impulse Responses (HRIRs). These HRIR sets are commonly described in the SH domain due to simplicity and ease of use in Ambisonics for spatial audio reproduction [24]. Since the SH domain describes a continuous spatial representation of the HRIRs, interpolation can be readily achieved. A given HRIR \(\mathrm{H}(\theta,\phi)\) can be converted to the spherical harmonic domain at a given spherical harmonic order \(M\) by using a re-encoding matrix \(\mathrm{C}\) with \(K\) rows and \(L\) columns, where \(K\) is the number of SH channels calculated as \(K=(M+1)^{2}\) and \(L\) is the number of HRTF measurements from different angles, where \(L\geq K\). The coefficients \(Y_{mn}^{\sigma}\) in the re-encoding matrix \(\mathrm{C}\) with SH order \(m\) and degree \(n\) are calculated by  
\[ \begin{split} Y_{mn}^{\sigma}(\theta,\phi)=\sqrt{(2-\delta_{n,0 })\,\frac{(m-n)!}{(m+n)!}}P_{mn}(\sin\phi)\\ \times\left\{\begin{array}{l}\cos(n\theta),\;\mathrm{if}\; \sigma=+1\\ \sin(n\theta),\;\mathrm{if}\;\sigma=-1\end{array}\right.\end{split}  \tag{1}\]  
where \(\sigma=\pm 1\), \(P_{mn}(\sin\phi)\) are the Legendre functions of order \(m\) and degree \(n\); \(\delta_{n,0}\) is the Kronecker delta function:  
\[\delta_{n,0}\equiv\left\{ \begin{array}{l}1,\;\mathrm{for}\;n=0\\ 0,\;\mathrm{for}\;n\
eq 0\end{array} \right. \tag{2}\]  
This paper uses Schmidt semi-normalisation (SN3D) in the computation of \(Y_{mn}^{\sigma}\). For normal SH HRIR use, a mode matching decoding matrix \(\mathrm{D}\) can be calculated from \(\mathrm{C}\) with the following pseudo-inverse equation:\[\mathrm{D}=\mathrm{C}^{-1}=\mathrm{C}^{T}\left(\mathrm{CC}^{T}\right)^{-1} \tag{3}\]  
which can be used to inverse the SH HRIR back into the original HRIR [25; 26]. However, for HRTF interpolation, another re-encoding matrix \(\hat{\mathrm{C}}\) and decoding matrix \(\hat{\mathrm{D}}\) with the desired target angles can be calculated with Equations (1)-(3), where \(\hat{L}\) is replaced as the number of HRTF measurements to be interpolated from the SH HRIRs whilst \(K\) remains the same. The interpolated HRIRs \(\hat{\mathrm{H}}(\theta,\phi)\) then can be calculated with the following equation:  
\[\hat{\mathrm{H}}=\hat{\mathrm{D}}(\mathrm{C}(\mathrm{H})) \tag{4}\]  
To challenge the full potential of the use of machine learning, this study used 1 st order SH interpolation as it requires the least number of HRIR measurements. An octahedron configuration with six measurements was selected, which has a more stable energy distribution than other arrays for 1 st order SH [8]. Interpolation with 1 st order SH up to the original number of measurements must be undertaken, which, depending on the dataset can be >2000 measurements. More specifically, the six selected sparse HRIRs from the HRIR database were first converted to SH HRIR 1 st order SH which has four channels) by using the re-encoding matrix \(\hat{\mathrm{C}}\) with four rows and six columns. Then a decoding matrix \(\hat{\mathrm{D}}\) was computed using a different re-encoding matrix \(\hat{\mathrm{C}}\) with the same number of rows and a different number of columns based on the desired number of HRIRs to interpolate.