{'fraction_non_alphanumeric': 0.03941465498825037, 'fraction_numerical': 0.028092287972655415, 'mean_word_length': 4.523893805309735, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A set of equations for numerically calculating the interaural level difference in the horizontal plane

The variation of interaural level difference (ILD) with direction and frequency is particularly complex and convoluted. The purpose of this work was to determine a set of parametric equations that can be used to calculate ILDs continuously at any value of frequency and azimuth in the horizontal plane. They were derived by fitting equations to ILDs derived from the azimuthal-dependence data tabulated by Shaw and Vaillancourt [(1985). J. Acoust. Soc Am. 78, 1120–1123] and assuming left-right symmetry. The equations are shown to fit those data to an overall RMS error less than 0.5 dB. VC 2021 Author(s). All article content, except where otherwise noted, is licensed under a Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/). [Editor: Christopher Bergevin] https://doi.org/10.1121/10.0004261 Received: 15 December 2020 Accepted: 23 March 2021 Published Online: 23 April 2021


Introduction
To complement some current projects on spatial hearing, it was necessary to have a set of closed-form equations from which interaural time and level differences (ITDs and ILDs, respectively) could be calculated continuously for any value of azimuth or frequency in the horizontal plane. For ITDs, it is typical to use the expression (rh þ r sin h)/c, where r is the radius of the head, h is the azimuth of the sound source, in radians, and c is the speed of sound (Woodworth, 1938;Blauert, 1997). This expression is derived from a simple geometrical model in which it is assumed that the head is spherical in shape (Duda and Martens, 1998), the two ears are diametrically opposite each other, and the source of sound is sufficiently far away for the wavefronts to be planes. It has proved remarkably popular, even though the equation is not an exact fit to any particular individual's ITDs nor does it take into account the frequency dependence of ITDs. However, the acoustics of ILDs are far more complicated, and to the best of our knowledge there is no published set of expressions for ILDs that allow accurate calculations. The best simple approximation that we know of is that published by van Opstal (2016), which is ILD ¼ 0:18 ffiffi ffi f p sinðhÞ, where f is the frequency in Hz. This equation captures two overall phenomena pertaining to the shape of the function of ILD across azimuth and frequency: the dependence on azimuth essentially follows the first half (0-p) of a sinusoid, and the overall magnitude of the ILDs increases with frequency.
To resolve this, we set out to develop continuous parametric equations that could be fitted to published ILD data. We derived these from tabulated data reported by Shaw and Vaillancourt (1985) [henceforth S-V], which quantify "self-consistent" families of curves that best fitted the azimuthal-dependence (see below) data from twelve previous studies (Shaw, 1974). These curves were described as "syntheses," were visually fitted and are internally consistent with smooth progressions, and represent the earlier data as a whole, though being neither true averages across listeners nor the functions of any particular individual or manikin. Shaw (1974) noted that individuals would generally be within 1 dB below 500 Hz but 5 dB or more at about 5 kHz. Though they are not any individual's ILDs, for our purposes this was much outweighed by the convenience of using smoothed, tabulated, and published data. Overall, we set ourselves the pragmatic target of fitting these within 1 dB or less within the range of 200 to 10 000 Hz. We avoided higher frequencies as they can be particularly idiosyncratic, and we could not find a simple set of expressions that were suitable.

Methods
We derived ILDs from S-V's data on the "azimuthal dependence" of at-ear level at 33 frequencies from 200 to 10 000 Hz (spaced at 50, 100, 200, and 500 Hz) and 24 azimuths from 0 to 3450 (spaced at 150; see Fig. 1(A)]; we excluded data at the irregularly spaced frequencies of 320, 630, 1250, 2900, 6300 Hz and, as noted, above 10 500 Hz. The azimuthal dependence is the difference in level at the left eardrum between a sound presented at an azimuth h and a sound presented at 0 (i.e., directly in front of the listener). We then calculated the ILD h, f as the difference between the azimuthal dependence at h and at Àh (or, in terms of S-V's tabulated data, at 360 -h); note that we assumed left-right symmetry in ILDs.
To derive the fitting equations, we started with a "principal" sinusoid dependent on azimuth h, capturing the overall dependence on azimuth that essentially follows the first half (0-p) of a sinusoid. Next, for some frequencies, the ILD function is front-back asymmetric, in that the ILD at an azimuth of h is considerably different to the ILD at 180-h. We represented this by varying asymmetrically the magnitude of the principal sinusoid by a factor dependent on the argument 2h. Next, for many frequencies, there is a large perturbation, or "dip," at azimuths around 90 . These were represented by adding a normal distribution dependent on azimuth h, whose parameters of magnitude, mean and standard deviation were themselves functions of frequency. A second perturbation around 5000 Hz required another normal distribution. In sum, our general equation for ILD as a function of frequency and azimuth was Fig. 1. (A) ILDs derived from the data reported by Shaw and Vaillancourt (1985); (B) computed ILDs from the equations reported here; (C) the error between the data and the computations, plotted using the same y axis limits in dB as panels A and B; (D) the same error, plotted using much finer y axis limits. ARTICLE asa.scitation.org/journal/jel where P f is the magnitude of the principal sinusoid at frequency f; A f is the magnitude of the front-back asymmetry; D 90,f , l 90,f , and r 90,f are the parameters of the normal distribution accounting for the "dip"; D 5k,f , l 5k , and r 5k are the parameters for the normal distribution accounting for the 5-kHz perturbation; and N is the standard normal distribution. We found the best-fitting values of each parameter separately for each value of frequency, using the generalised reduced gradient (GRG) algorithm within Excel's "Solver" tool. Figure 2 shows these values (circles). Their dependencies on frequency are mostly smooth but in some cases are of considerable extent and complexity. We next needed to determine further equations that would give continuous values of these parameters as a function of frequency. Trial-and-error work demonstrated that we could fit the functions of these parameters across frequency by summing a linear function of f Ã ¼ log10(f) with four perturbing normal distributions [see Eqs.
(2)-(8) below]. The best-fitting values of the parameters of these sums were found by again running the GRG nonlinear algorithm. We set limits of -10 a 10, r 0.03, and the various values of l were at least 0.1 log(kHz) apart. The lines in Fig. 2 show these fits.

Results
The parameters that we found are listed in Eqs.   l 5k ¼ 0:750; r 5k ¼ 0:200 (8) Figure 1(B) shows the resulting ILDs calculated from these equations. Note that we used a much finer "mesh" of frequency by azimuth in order to check there were no issues or instabilities at intermediate values. Figure 1(C) shows the difference between our calculations and the ILDs derived from the S-V data, using the same y-scale as panels (A) and (B). Figure 1(D) shows the same differences using a finer y-scale of 61 dB. It can be seen that the difference is mostly less than half a decibel. The overall RMS error, across the entire grid of 13 azimuths by 33 frequencies, was 0.40 dB, with 97% of the values being less than 1 dB. The RMS error was generally slightly smaller at low frequencies than high ones (RMS ¼ 0.3 dB for 0.2-2 kHz but 0.5 dB for 8-10 kHz).

Discussion
We report here a set of equations that enable ILDs to be calculated for any angle of azimuth up to 10 kHz. The equations are derived from tabulated data reported by Shaw and Vaillancourt (1985) and assume left-right symmetry.
To recap, ILDs are represented first as a sinusoid dependent on azimuth h, whose magnitude is front-back asymmetric and varies with frequency f. This front-back asymmetry depends on 2h and also varies with frequency. Two major corrections (or "perturbations") are then added to the ILDs to represent effects at azimuths around 90 and 5 kHz, which are both modelled as normal distributions dependent on azimuth and frequency. The magnitudes of all of these effects are modelled as linear functions of log(f), corrected by four normal distributions. We appreciate that the equations are somewhat daunting at first sight, and are free of any acoustical theory. Further, though the assumption of left-right symmetry is often made in experimental work-for instance, the popular Gardner and Martin (1995) dataset is symmetric-it is known that HRTFs are not perfectly symmetric [e.g., Zhong et al. (2013)]. An analysis of the CIPIC database of individual HRTFs (Algazi et al., 2001) shows that, in terms of ILD, the asymmetry is on the order of 2 dB up to about 4 kHz and then gradually increases to about 6 dB (also, the standard deviation across listeners of the mean ILDs across azimuths ARTICLE asa.scitation.org/journal/jel