PDF

Head and Torso HRTF Computation
Introduction
This tutorial model shows how to import a 3D scanned geometry of a human head and torso and compute the head related transfer function (HRTF). The scan is imported as a stl file and converted into a COMSOL geometry. The HRTF is computed using the reciprocity principle, locating the source at the ear canal entrance; this approach greatly reduces the computational cost to get a full 3D response. The acoustics are modeled using the Pressure Acoustics, Boundary Element interface of the Acoustics Module. The simulated results are compared to measured data form the actual subject and show good agreement.
The HRTF gives a complete description of the way the head and torso of an individual distorts incident sound fields. The HRTF is an important component of spatial hearing. The HRTF includes both so-called monaural and binaural cues. Binaural cues include the interaural time differenced (ITD) and interaural level differences (ILD), whereas the monaural cues represent a spectral distortion of the sound that is identical for both ears, see Ref. 1. The HRTF is defined as the sound pressure level (SPL) measured at the eardrum (or the ear canal entrance as in this model) relative to the SPL when no head is present.
When virtual sound is used (or acoustic virtual reality) the HRTF is important in order to make the test subject experience a virtual sound scene. The HRTF can be measured, which can be a tedious task, or it can be simulated based on a scan of the individual. This model presents the latter approach on a scanned head geometry provided by the Teaching and Research Area of Medical Acoustics, Institute of Technical Acoustics, RWTH Aachen University, Germany, Ref. 2. The scan is of an actual individual where the facial features have been removed, while all the details of the ear geometry have been retained.
Note: The scanned geometry (stl mesh) and measured data is with courtesy of the Teaching and Research Area of Medical Acoustics, Institute of Technical Acoustics, RWTH Aachen University, Germany. The stl mesh is licensed under the Creative Commons Attribution 4.0 International License and is provided “as is” with all warranties disclaimed, as stated in that license. See Ref. 7 and Ref. 8 for details.
Model Definition
A common approach when simulating the HRTF is to use the reciprocity principle; the source and receiver locations are reverted, Ref. 3. This means that, in the model, the source is located at the entrance of the ear canal and the evaluation is performed along a circle (or on a sphere for the full bubble) with its center in the middle of the head, between the ears. In this way, the HRTF can be deduced for all spatial directions for each frequency with just one simulation. Not using reciprocity requires solving one problem per incidence direction per frequency, which is not practical. Reciprocity is used for similar application in Ref. 4 and Ref. 5.
The acoustic problem is modeled using the boundary element method (BEM) with the Pressure Acoustics, Boundary Element interface. This is especially efficient since the present model represents is a pure radiation problem.
The imported stl mesh is depicted in Figure 1 and the COMSOL geometry generated from the stl mesh is depicted in Figure 2. Notice that the geometry has been moved and rotated (in Figure 2) to align the coordinate axis with the commonly used directions for directivity assessment. The evaluation circle for the HRTF that is use in the model, is represented in Figure 2. The evaluation is performed using a Radiation Pattern plot.
Figure 1: The imported stl mesh. The imported stl mesh is courtesy of the Teaching and Research Area of Medical Acoustics, Institute of Technical Acoustics, RWTH Aachen University, Germany. The stl mesh is licensed under the Creative Commons Attribution 4.0 International License and is provided “as is” with all warranties disclaimed, as stated in that license. See Ref. 7 and Ref. 8.
Figure 2: The generated COMSOL geometry from the stl mesh. Representation of the location for the HRTF evaluation on a circle in the horizontal plane.
Results and Discussion
The pressure field generated from the excitation at the ear canal entrance is depicted in Figure 3 for the frequencies f = 1033.6 Hz, 2067.5 Hz, and 3962.1 Hz. These have been selected as they coincide with the measurement data (octave band center frequencies). A unit normal velocity is assigned to the ear canal entrance.
The acoustic pressure is also depicted in a cross-section plane in Figure 4 and the corresponding sound pressure level (SPL) is depicted in Figure 5. Both are evaluated at 4 kHz octave band center frequency. The SPL plot clearly shows the presence of notches (cancellations) for certain directions. These are more evident at the higher frequencies.
Figure 3: Acoustic pressure at the surface of the head and torso evaluated at three frequencies.
Figure 4: Acoustic pressure on the head and torso and in a cut plane.
Figure 5: Sound pressure level on the surface of the head and torso and in a cut plane.
The HRTF in the horizontal plane (the xy-plane) is depicted for the three evaluation frequencies in Figure 6. In the plot, the HRTF is normalized to 0 dB toward the front (polar angle θ = 0). In the following three plots — Figure 7, Figure 8, and Figure 9 — the computed HRTFs are compared to measurement data; see Ref. 6 and Ref. 8. In the plots, the HRTF data has been rotated by θ0 = 4.5° to make to location of the notches match (defined by the parameter theta0).
Notice that the model assumes that the head and torso is located in free space. This is consistent with the measured data where the floor reflections have been removed. A time-windowed approach is used, so that the reflections will not affect the data. In the measurements, there is a maximum length of the impulse response of about 330 samples at a 44100 Hz sampling rate.
The COMSOL models results agree well with the measurement data. There are some general small discrepancies; these can be due to head movement during the measurements. In the current measurement setup at RWTH, head movement is tracked and compensated for. A larger discrepancy can be seen in the 1 kHz plot toward 30° (in Figure 7). Shoulder reflections are typically seen at around 1.5 kHz so a slight under- or overestimate of the shoulder size, when generating the head scan, could introduce this error.
Figure 6: Comparison of the normalized HRTF evaluated at the three frequencies.
Figure 7: Comparison of the simulated HRTF with measured data at 1033 Hz.
Figure 8: Comparison of the simulated HRTF with measured data at 2066 Hz.
Figure 9: Comparison of the simulated HRTF with measured data at 3962 Hz.
References
1. M. Vorländer, Auralization, Springer, 2008.
2. Web link: www.akustik.rwth-aachen.de/cms/Technische-Akustik/Das-Institut/~dwry/medizinische-Akustik/lidx/1/.
3. A. D. Pierce, “Acoustics — An Introduction to Its Physical Principles and Applications”, Acoustical Society of America, 1991.
4. Z. Conrad, “Hats Off to the Boundary Element Method,” IEEE Spectrum Multiphysics Simulation, October 2018, p. 30, web link: www.comsol.com/zmags/multiphysics-simulation-2018.
5. M. H. Jensen, “Improving the Performance of Hearing Aids Using Acoustic Simulations,” COMSOL Conference 2009, web link: www.comsol.com/paper/7227.
6. Web link: www.akustik.rwth-aachen.de/cms/Technische-Akustik/Forschung/~lxfd/Downloads/lidx/1/.
7. H. S. Braren and J. Fels, “A High-Resolution Individual 3D Adult Head and Torso Model for HRTF Simulation and Validation: 3D Data,” web link (DOI):
https://doi.org/10.18154/RWTH-2020-06760
8. H. S. Braren and J. Fels, “A High-Resolution Individual 3D Adult Head and Torso Model for HRTF Simulation and Validation: HRTF Measurement,” web link (DOI):
https://doi.org/10.18154/RWTH-2020-06761
Application Library path: Acoustics_Module/Tutorials,_Pressure_Acoustics/head_torso_hrtf
Modeling Instructions
From the File menu, choose New.
New
In the New window, click  Model Wizard.
Model Wizard
1
In the Model Wizard window, click  3D.
2
In the Select Physics tree, select Acoustics>Pressure Acoustics>Pressure Acoustics, Boundary Elements (pabe).
3
Click Add.
4
Click  Study.
5
In the Select Study tree, select General Studies>Frequency Domain.
6
Global Definitions
Parameters 1
1
In the Model Builder window, under Global Definitions click Parameters 1.
2
In the Settings window for Parameters, locate the Parameters section.
3
Click  Load from File.
4
Interpolation 1 (int1)
1
In the Home toolbar, click  Functions and choose Global>Interpolation.
2
In the Settings window for Interpolation, locate the Definition section.
3
From the Data source list, choose File.
4
Click Browse.
5
6
In the Number of arguments text field, type 1.
7
Find the Functions subsection. In the table, enter the following settings:
8
Locate the Interpolation and Extrapolation section. From the Interpolation list, choose Piecewise cubic.
9
From the Extrapolation list, choose Linear.
10
Locate the Units section. In the Arguments text field, type rad.
11
In the Function text field, type Pa.
12
Locate the Definition section. Click Import.
Analytic 1 (an1)
1
In the Home toolbar, click  Functions and choose Global>Analytic.
2
In the Settings window for Analytic, type p1033 in the Function name text field.
3
Locate the Definition section. In the Expression text field, type HRTF_1033_real(theta+theta0)+i*HRTF_1033_imag(theta+theta0).
4
In the Arguments text field, type theta.
5
Click to expand the Periodic Extension section. Select the Make periodic check box.
6
In the Upper limit text field, type 2*pi.
7
Locate the Units section. In the Arguments text field, type rad.
8
In the Function text field, type Pa.
9
Click to expand the Advanced section. Select the May produce complex output for real arguments check box.
10
Locate the Plot Parameters section. In the table, enter the following settings:
11
Analytic 2 (p1034)
1
Right-click Analytic 1 (an1) and choose Duplicate.
2
In the Settings window for Analytic, type p2067 in the Function name text field.
3
Locate the Definition section. In the Expression text field, type HRTF_2067_real(theta+theta0)+i*HRTF_2067_imag(theta+theta0).
4
Analytic 3 (p2068)
1
Right-click Analytic 2 (p1034) and choose Duplicate.
2
In the Settings window for Analytic, type p3962 in the Function name text field.
3
Locate the Definition section. In the Expression text field, type HRTF_3962_real(theta+theta0)+i*HRTF_3962_imag(theta+theta0).
4
5
In the Model Builder window, right-click Global Definitions and choose Mesh Parts>3D Part.
Mesh Part 1
1
In the Settings window for Mesh Part, locate the Units section.
2
Select the Use units check box.
3
From the Length unit list, choose mm.
Import 1
1
In the Model Builder window, under Global Definitions>Mesh Parts>Mesh Part 1 click Import 1.
2
In the Settings window for Import, locate the Import section.
3
Click Browse.
4
5
Click Import.
6
From the Boundary partitioning list, choose Detect boundaries.
7
Locate the Detect Faces section. In the Maximum neighbor angle text field, type 180.
Now, cut the surface mesh (using a cylinder) in order to create selections for the entrance of the ear canal.
Partition with Cylinder 1
1
In the Mesh toolbar, click  Intersections and Partitions and choose Partition with Cylinder.
2
In the Settings window for Partition with Cylinder, locate the Size and Shape section.
3
In the Radius text field, type 2.8.
4
Locate the Position section. In the x text field, type -1.5.
5
In the z text field, type -1.
6
Locate the Axis section. From the Axis type list, choose y-axis.
Finalize
In the Model Builder window, right-click Finalize and choose Build All.
The final mesh part created from the imported .stl file, of the scanned head and torso, should look like the image in Figure 1. Use the mouse to rotate, zoom, and move the geometry in the graphics window.
Geometry 1
In the Model Builder window, under Component 1 (comp1) click Geometry 1.
Import 1 (imp1)
1
In the Home toolbar, click  Import.
2
In the Settings window for Import, locate the Import section.
3
From the Source list, choose Mesh or 3D printing file (STL, 3MF, PLY).
4
From the Mesh list, choose Mesh Part 1.
5
Click  Build Selected.
Work Plane 1 (wp1)
1
In the Geometry toolbar, click  Work Plane.
2
In the Settings window for Work Plane, locate the Plane Definition section.
3
From the Plane type list, choose Coordinates.
4
In row Point 1, set z to 0.1.
5
In row Point 2, set x to 0.01 and z to 0.105.
6
In row Point 3, set y to 0.001 and z to 0.1.
Leave all other components at their default zero value.
Partition Objects 1 (par1)
1
In the Geometry toolbar, click  Booleans and Partitions and choose Partition Objects.
2
3
In the Settings window for Partition Objects, locate the Partition Objects section.
4
From the Partition with list, choose Work plane.
5
Click  Build Selected.
Mirror 1 (mir1)
1
In the Geometry toolbar, click  Transforms and choose Mirror.
2
3
In the Settings window for Mirror, click  Build Selected.
Form Union (fin)
1
In the Model Builder window, click Form Union (fin).
2
In the Settings window for Form Union/Assembly, click  Build Selected.
Remove Details 1 (rmd1)
1
In the Geometry toolbar, click  Remove Details.
2
In the Settings window for Remove Details, click  Build Selected.
In the Information section the number of details removed can be seen.
Use the mouse to rotate, zoom, and move the geometry to see it from the front. The geometry should look like the image in Figure 2.
Add Material
1
In the Home toolbar, click  Add Material to open the Add Material window.
2
Go to the Add Material window.
3
4
Click Add to Component in the window toolbar.
5
In the Home toolbar, click  Add Material to close the Add Material window.
Materials
Air (mat1)
1
In the Settings window for Material, locate the Geometric Entity Selection section.
2
From the Selection list, choose All voids.
Pressure Acoustics, Boundary Elements (pabe)
1
In the Model Builder window, under Component 1 (comp1) click Pressure Acoustics, Boundary Elements (pabe).
2
In the Settings window for Pressure Acoustics, Boundary Elements, locate the Domain Selection section.
3
From the Selection list, choose All voids.
Normal Velocity 1
1
In the Physics toolbar, click  Boundaries and choose Normal Velocity.
2
3
In the Settings window for Normal Velocity, locate the Normal Velocity section.
4
In the vn text field, type 1.
Mesh 1
Free Triangular 1
In the Mesh toolbar, click  Boundary and choose Free Triangular.
Size
1
In the Model Builder window, click Size.
2
In the Settings window for Size, locate the Element Size section.
3
Click the Custom button.
4
Locate the Element Size Parameters section. In the Maximum element size text field, type min(20[mm],lam0/4).
5
In the Minimum element size text field, type 3[mm].
6
In the Resolution of narrow regions text field, type 2.
Free Triangular 1
1
In the Model Builder window, click Free Triangular 1.
2
In the Settings window for Free Triangular, locate the Boundary Selection section.
3
From the Selection list, choose All boundaries.
Size 1
1
Right-click Free Triangular 1 and choose Size.
2
In the Settings window for Size, locate the Element Size section.
3
Click the Custom button.
4
Locate the Element Size Parameters section. Select the Maximum element size check box.
5
6
Locate the Geometric Entity Selection section. In the list, select 1.
7
Click  Clear Selection.
8
9
In the Model Builder window, right-click Mesh 1 and choose Build All.
The mesh should look like the image below, here meshed to resolve a frequency of 4000 Hz. You can change the parameter f0 and build the mesh again, to see how it looks at different frequencies.
Definitions (comp1)
Before solving the model, add a variable theta that defines the horizontal polar angle. The variable is used when postprocessing the measured HRTF data.
Variables 1
1
In the Model Builder window, expand the Component 1 (comp1)>Definitions node.
2
Right-click Component 1 (comp1)>Definitions and choose Variables.
3
In the Settings window for Variables, locate the Variables section.
4
Study 1
Step 1: Frequency Domain
1
In the Model Builder window, under Study 1 click Step 1: Frequency Domain.
2
In the Settings window for Frequency Domain, locate the Study Settings section.
3
In the Frequencies text field, type f0.
Parametric Sweep
1
In the Study toolbar, click  Parametric Sweep.
2
In the Settings window for Parametric Sweep, locate the Study Settings section.
3
4
5
In the Study toolbar, click  Compute.
Results
Grid 3D 1
1
In the Model Builder window, expand the Results>Datasets node, then click Grid 3D 1.
2
In the Settings window for Grid 3D, locate the Parameter Bounds section.
3
Find the First parameter subsection. In the Minimum text field, type -0.3.
4
In the Maximum text field, type 0.3.
5
Find the Second parameter subsection. In the Minimum text field, type -0.5.
6
In the Maximum text field, type 0.5.
7
Find the Third parameter subsection. In the Minimum text field, type -0.5.
8
In the Maximum text field, type 0.5.
9
Click to expand the Resolution section. In the x resolution text field, type 40.
10
In the y resolution text field, type 60.
11
In the z resolution text field, type 80.
To visualize the extent of the grid dataset, where the BEM solution is visualized, plot the dataset.
12
Show More Options
In preparation for setting up the plots, enable custom result views.
1
Click the  Show More Options button in the Model Builder toolbar.
2
In the Show More Options dialog box, in the tree, select the check box for the node Results>Views.
3
Results
Acoustic Pressure, Boundaries (pabe)
The first default plot shows the pressure on the surface of the head and torso.
1
In the Model Builder window, click Acoustic Pressure, Boundaries (pabe).
2
In the Settings window for 3D Plot Group, locate the Plot Settings section.
3
From the View list, choose New view. This allows you to set up and use a dedicated view for this plot group.
4
Locate the Data section. From the Parameter value (f0 (Hz)) list, choose 1033.6.
5
In the Acoustic Pressure, Boundaries (pabe) toolbar, click  Plot.
Use the mouse and the Graphics window toolbar buttons to rotate and zoom the geometry so that the left side of the head and torso is clearly visible.
Change the frequency parameter f0 as needed. The three solved frequencies are shown in Figure 3.
Before turning the attention to the second default plot, lock the view for this one.
Acoustic Pressure (pabe)
This plot shows the pressure on the surface of the head and torso and in slices through the grid dataset. Adjust the plot for better visualization.
1
In the Model Builder window, expand the Results>Views node.
Multislice 1
1
In the Model Builder window, expand the Acoustic Pressure (pabe) node, then click Multislice 1.
2
In the Settings window for Multislice, locate the Multiplane Data section.
3
Find the y-planes subsection. In the Planes text field, type 0.
4
Find the z-planes subsection. In the Planes text field, type 0.
5
Click to expand the Range section. Select the Manual color range check box.
6
In the Minimum text field, type -20.
7
In the Maximum text field, type 20.
8
In the Acoustic Pressure (pabe) toolbar, click  Plot.
Zoom out to get a better view of the space around the head and torso. The image should look like that in Figure 4 at 3962 Hz.
Change the frequency parameter f0 as needed. If you do, note that you need to modify f0 separately for the Surface plot, because it uses a different dataset than its parent plot group.
Multislice 1
1
In the Model Builder window, expand the Sound Pressure Level (pabe) node, then click Multislice 1.
2
In the Settings window for Multislice, locate the Multiplane Data section.
3
Find the y-planes subsection. In the Planes text field, type 0.
4
Find the z-planes subsection. In the Planes text field, type 0.
5
In the Sound Pressure Level (pabe) toolbar, click  Plot.
The third default plot shows the SPL on the surface of the head and torso and in slices through the grid dataset. Change the frequency parameter f0 if needed. Remember to change it separately for the Surface plot. The image should look like that in Figure 5 at 3962 Hz.
HRTF
1
In the Home toolbar, click  Add Plot Group and choose Polar Plot Group.
2
In the Settings window for Polar Plot Group, type HRTF in the Label text field.
3
Locate the Data section. From the Dataset list, choose Study 1/Parametric Solutions 1 (sol2).
Radiation Pattern 1
1
In the HRTF toolbar, click  More Plots and choose Radiation Pattern.
2
In the Settings window for Radiation Pattern, locate the Expression section.
3
In the Expression text field, type pabe.Lp_t.
4
Locate the Evaluation section. Find the Angles subsection. In the Number of angles text field, type 360.
Next, inspect the location of the evaluation plane/circle.
5
Click Preview Evaluation Plane.
HRTF
1
In the Model Builder window, click HRTF.
2
In the Settings window for Polar Plot Group, locate the Axis section.
3
From the Zero angle list, choose Up.
4
In the HRTF toolbar, click  Plot.
First, plot the HRTF (without normalization) using the Radiation Pattern plot and then add a second plot where it is normalized with reference to the front.
HRTF (normalized)
1
Right-click HRTF and choose Duplicate.
2
In the Settings window for Polar Plot Group, type HRTF (normalized) in the Label text field.
Radiation Pattern 1
1
In the Model Builder window, expand the HRTF (normalized) node, then click Radiation Pattern 1.
2
In the Settings window for Radiation Pattern, locate the Expression section.
3
In the Expression text field, type pabe.Lp_t-at3_spatial(1[m],0,0,pabe.Lp_t,'minc').
4
In the HRTF (normalized) toolbar, click  Plot.
The plot should look like that in Figure 6.
HRTF Comparison (1033 Hz), R = 1.4 m
1
In the Home toolbar, click  Add Plot Group and choose Polar Plot Group.
2
In the Settings window for Polar Plot Group, type HRTF Comparison (1033 Hz), R = 1.4 m in the Label text field.
3
Locate the Data section. From the Dataset list, choose Study 1/Parametric Solutions 1 (sol2).
4
From the Parameter selection (f0) list, choose From list.
5
In the Parameter values (f0 (Hz)) list, select 1033.6.
6
Click to expand the Title section. From the Title type list, choose Manual.
7
In the Title text area, type HRTF at 1033 Hz.
8
Locate the Axis section. From the Zero angle list, choose Up.
Radiation Pattern 1
1
In the HRTF Comparison (1033 Hz), R = 1.4 m toolbar, click  More Plots and choose Radiation Pattern.
2
In the Settings window for Radiation Pattern, locate the Expression section.
3
In the Expression text field, type pabe.Lp_t-at3_spatial(1.4[m],0,0,pabe.Lp_t,'minc').
4
Locate the Evaluation section. Find the Angles subsection. In the Number of angles text field, type 360.
5
Find the Evaluation distance subsection. In the Radius text field, type 1.4.
6
Click to expand the Legends section. Select the Show legends check box.
7
From the Legends list, choose Manual.
8
HRTF Comparison (1033 Hz), R = 1.4 m
In the Model Builder window, click HRTF Comparison (1033 Hz), R = 1.4 m.
Radiation Pattern 2
1
In the HRTF Comparison (1033 Hz), R = 1.4 m toolbar, click  More Plots and choose Radiation Pattern.
2
In the Settings window for Radiation Pattern, locate the Expression section.
3
In the Expression text field, type 20*log10(abs(p1033(theta)/p1033(0))).
4
Locate the Evaluation section. Find the Angles subsection. In the Number of angles text field, type 360.
5
Find the Evaluation distance subsection. In the Radius text field, type 1.4.
6
Locate the Legends section. Select the Show legends check box.
7
From the Legends list, choose Manual.
8
9
In the HRTF Comparison (1033 Hz), R = 1.4 m toolbar, click  Plot.
The plot should look like that in Figure 7.
HRTF Comparison (2067 Hz), R = 1.4 m
1
Right-click HRTF Comparison (1033 Hz), R = 1.4 m and choose Duplicate.
2
In the Settings window for Polar Plot Group, type HRTF Comparison (2067 Hz), R = 1.4 m in the Label text field.
3
Locate the Data section. In the Parameter values (f0 (Hz)) list, select 2067.2.
4
Locate the Title section. In the Title text area, type HRTF at 2067 Hz.
Radiation Pattern 2
1
In the Model Builder window, expand the HRTF Comparison (2067 Hz), R = 1.4 m node, then click Radiation Pattern 2.
2
In the Settings window for Radiation Pattern, locate the Expression section.
3
In the Expression text field, type 20*log10(abs(p2067(theta)/p2067(0))).
4
In the HRTF Comparison (2067 Hz), R = 1.4 m toolbar, click  Plot.
The plot should look like that in Figure 8.
HRTF Comparison (3962 Hz), R = 1.4 m
1
In the Model Builder window, right-click HRTF Comparison (2067 Hz), R = 1.4 m and choose Duplicate.
2
In the Settings window for Polar Plot Group, type HRTF Comparison (3962 Hz), R = 1.4 m in the Label text field.
3
Locate the Data section. In the Parameter values (f0 (Hz)) list, select 3962.1.
4
Locate the Title section. In the Title text area, type HRTF at 3962 Hz.
Radiation Pattern 2
1
In the Model Builder window, expand the HRTF Comparison (3962 Hz), R = 1.4 m node, then click Radiation Pattern 2.
2
In the Settings window for Radiation Pattern, locate the Expression section.
3
In the Expression text field, type 20*log10(abs(p3962(theta)/p3962(0))).
4
In the HRTF Comparison (3962 Hz), R = 1.4 m toolbar, click  Plot.
The plot should look like that in Figure 9.