Head-related transfer functions (HRTFs) describe the direction dependent free field sound propagation from a point source to the listener's ears and are an important tool for audio in virtual and augmented reality. Classically, HRTFs are measured acoustically with the listener being positioned in the center of a spherical loudspeaker array. Alternatively, they can be approximated by numerical simulation, for example applying the boundary element method (BEM) to a piece wise linear representation (a surface mesh) of the listener's head. Numerical approximation may be more economical, particularly in combination with methods for the synthesis of head geometry. To decrease the computation time of the BEM, it has been suggested to gradually decrease the resolution of the mesh with increasing distance from the ear for which the HRTF is approximated. We improve this approach by also considering the curvature of the geometry. The resulting graded meshes lead to faster simulation with the same or better accuracy in the HRTF compared to previous work.
https://cg-tub.github.io/hrtf_mesh_grading/
Although the PMP library can also be used on Windows and MacOS, we only support Linux. There are two options for getting started with the HRTF mesh grading:
- Clone the repository and locally build the code
- Use a pre-compiled docker image (requires docker)
Both options will make the hrtf_mesh_grading
tool available as explained in
- HRTF mesh grading
Clone the repository
git clone --recursive https://github.com/cg-tub/hrtf_mesh_grading.git
Note that recursive cloning requires SSH key and we recommend that you generating it and adding it to GitHub. If you do not want to do this. You can separately clone
git clone https://github.com/cg-tub/hrtf_mesh_grading.git
cd hrtf_mesh_grading
git clone --recursive https://github.com/cg-tub/pmp-library.git
Configure and build
There are two options for building the project from which you can chose:
Locally
Build the project locally on your machine. This could work on Linux, MacOS, and Windows, however, we only test on Linux. Note that this requires the dependencies listed at PMP-Library installation together with more detailed instructions for installation.
cd pmp-library && mkdir build && cd build && cmake .. && make
Docker Container
Build a docker container to run the mesh-grading inside the container. Note that this requires Docker. To build and run the container use
docker build --tag ubuntu:hrtf-mesh-grading .
docker run -dit --name hrtf-mesh-grading ubuntu:hrtf-mesh-grading /bin/bash
Pull the docker image with
docker pull fabrin/hrtf-mesh-grading
Please note that the mesh grading tool expects the mesh to meet the following requirements
- The interaural center must be in the origin of coordinates. The interaural center is the midpoint between the axis that passes through the left and right ear channel entrances.
- The mesh must be viewing in positive x-direction with the y-axis acting as the interaural axis, i.e., the left ear is pointing in positive y-direction.
- The mesh must be watertight (does not have any holes) and clean (no duplicate vertices or edges, no isolated vertices or edges, and no overlapping faces). This can for example be checked with the Blender 3D print addon.
If you are using Blender for exporting meshes, make sure to apply all transforms before exporting, export only the selected object, and use the settings Forward: Y Forward
and Up: Z up
during export.
The binary for remeshing is located at
pmp-library/build/hrtf_mesh_grading
Mesh grading without docker
Add it to you search path, e.g., via a symbolic link
ln -s pmp-library/build/hrtf_mesh_grading /usr/local/bin
Use the mesh grading via
hrtf_mesh_grading -x 0.5 -y 10 -s "left" -i data/head.ply -o data/head_graded_left.ply
Call without any parameters for getting the complete description
hrtf_mesh_grading
Mesh grading with docker
In this case you need to run the docker container before you start with the mesh grading. This can be done with
docker run -dit --name hrtf-mesh-grading -v '</local/folder>:/home/data' <tag> /bin/bash
</local/folder>
should be the absolute path to a folder on your disc containing the meshes for grading, e.g., thedata
folder inside this repository (without<
and>
).<tag>
is the tag of the docker container. If you followed 1 Clone and build locally it isubuntu:hrtf-mesh-grading
. If you followed 2 Use pre-compiled docker image it isfabrin/hrtf-mesh-grading
.
Once the container is running, you have different options for using it
- use the exec command, e.g.,
docker exec hrtf-mesh-grading hrtf_mesh_grading
(Note that hrtf-mesh-grading is the name of the container and hrtf_mesh_grading the command to be executed) - use the Python API
- Start the container's command line interface from the Docker Desktop app.
For more examples see Mesh grading without docker.
In some cases the mesh grading fails
- make sure the mesh meets all requirements listed in the section
Mesh preparation
- Try to move the reference point of the ear channel entrance a little closer to the origin. This can be done using the gamma scaling parameters
-g
and-h
or by directly passing a y-coordinate with the paramerers-l
and-r
In some cases there are small triangles left at the contralateral ear. In this case try to move the reference point of the ear channel entrance of the contralateral ear closer to the origin (see above).
The code is provided under a simple and flexible MIT-style license, thereby allowing for both open-source and commercial usage.
The following changes were made to the original PMP library
-
HRTF remeshing algorithm was added to
pmp-library/src/pmp/algorithms/SurfaceRemeshing.cpp
-
pmp-library/src/apps/MeshProcessingViewer.cpp
was updated to include the HRTF remeshing algorithm -
The command line application
pmp-library/src/apps/hrtf-mesh-grading
was added. It callsSurfaceRemeshing.cpp
-
The command line application was added to
pmp-library/src/apps/CMakeList.txt
Some reminders for the developers.
To update the pmp-library submodule use
git submodule update --remote pmp-library
Manualy compile hrtf-mesh-grading command line application
g++ hrtf-mesh-grading.cpp -o hrtf-mesh-grading -I /usr/include/eigen3/ /usr/local/lib/libpmp.so
To update the docker image on hub.docker run
docker build -t fabrin/hrtf-mesh-grading .
docker pull fabrin/hrtf-mesh-grading
Running the tests requires
pip install docker trimesh numpy pytest