WARNING: |
---|
This Tutorial is valid ONLY for Mesh2HRTF files from 2022-06-23. Update for the 1.0 version will be made closer to the release. |
------------------------------------------------------------ | Part of the the Complete Beginner’s tutorial | ------------------------------------------------------------ |
---|---|---|
Previous <<< tutorial introduction | \\\ Express tutorial /// | Next >>> 3D scanning |
Video version of this tutorial:
Note: these instructions are primarily focused on Windows (but should work great for Linux / Mac as well). Most of the steps are equally applicable to Linux and Max as well, However, Windows is not the main Mesh2HRTF platform and gets only limited development team support.
The main instructions can be found here: [Installation] and cover the primary Linux and Mac OS platforms.
To run common Mesh2HRTF workflows (as needed for this Complete Beginner’s tutorial) you need to:
Download Mesh2HRTF code from GitHub by clicking on Code ==> Download ZIP
and unpacking the zip file. Alternatively (for advanced users), clone the git repository to be able to use Git for fetching future updates.
develop
branch is considered to be up-to-date for Mesh2HRTF v1 (any older code is no longer supported).Download extra Mesh2HRTF tools from SourceForge the same way (click on Download Snapshot
and unpack the zip file, or clone the repository).
Download & Install Blender (latest version or at least v2.80)
Download "3d_Model_uniform.blend" example Blender file that will be used as a template. (it contains mesh from Ziegelwanger et al (2013)).
Python -See next paragraph.
Python (3.9 or newer v3.x) is necessary for Mesh2HRTF workflow.
There are multiple options how to install Python (and there can be many parallel Python installations on one computer). Here are some alternatives:
Direct installation - fast & very convenient approach, but comes with a limited risk of disturbing other Python tools that you previously-installed in the same Python environment (if issues ever occur, you may need to re-install affected software or the default Python environment).
Anaconda/Miniconda installation - safe approach, but may be unnecessary if you do not use many different custom Python-based tools.
You can create venv
virtual environments from Python command line or any other advanced method.
Check that all packages are up to date! if you are using existing Python environment. You could run into unpredictable errors if for example "NumPy", "pyfar" or "sofar" is too old. Typical commands are: pip list --outdated
and pip install --user --upgrade ThePackageYouNeed
.
This alternative is the fastest and will install Mesh2HRTF into your main Python 3 installation. It allows for direct access to all Mesh2HRTF tools from any command line or even directly from Windows Explorer. The downside is the possibility for package conflicts with other custom Python tools.
cmd.exe
) and type in python
. exit()
to quit. Note, in case the installed Python version is 3.6
or older, then it is best to use the Anaconda approach (upgrading to a newer Python could cause previously installed Python software to stop working).cmd
and hit Enter.This alternative will crate a separate Python installation (environment) only for Mesh2HRTF. Anaconda makes use of virtual Python environments quite easy.
The downside is that Anaconda creates a Lot of files in your C:\Users\%username%
folder which can remain there even after uninstalling Anaconda.
Another reason to choose Anaconda is if you plan to use other scientific software or Matlab-like Python editor - Spyder (Conda is practically required to use Spyder with custom Python package support).
conda install anaconda-navigator
conda create --name mesh2hrtf python=3.9
conda activate mesh2hrtf
conda install -c anaconda spyder
cd c:\your\path\to\mesh2hrtf
This is a continuation of Python installation from either Direct or Anaconda Python installation.
pip install psutil
to install prerequisite to run "NumCalcManager.py".python
or python3
to open Python.import pip
, followed by pip.main(['install', 'psutil'])
.import psutil
you should not get any errors and you are done (maybe you will need to re-start the Python to see the effect).pip install -e .
to Install mesh2hrtf Python package using pip (into the current Python environment). It will install all external Python dependencies and the mesh2hrtf Python package that generates final SOFA files (Output2HRTF). -e
option will make changes in Mesh2HRTF Python files immediately available. This is helpful if you download updates or make your own changes to the code. If you do not want this, omit this option.Optional: Testing
If you want to develop or test mesh2HRTF make sure to also install the requirements listed in setup.py under test_requirements
, e.g.
pip install pytest numpy>=1.14.0 scipy>=1.5.0 matplotlib
Don't forget to
pip install ipykernel
in case you want to interactively debug your changes.
Mesh2Input module is used to export Mesh2HRTF projects from Blender.
Start Blender
./blender
inside the directory.)Go to Edit -> Preferences -> Add-ons -> Install...
exportMesh2HRTF.py
file which is located in for example: path/to/your/mesh2hrtf-git/mesh2hrtf/Mesh2Input/exportMesh2HRTF.pyInstall Add-on
to install it.mesh2
in the search fieldFile -> Export
you should now see an option Mesh2HRTF
)Advanced Blender setup: Instructions how to modify default settings of the export script - it is possible to customize the default Blender export settings so, but it is not necessary for most users.
The main simulation solver of the Mesh2HRTF is called "NumCalc" and is the executable that will run for hours and requires many GigaBytes of memory to find the HRTF solutions.
On Windows, if you have already extracted Mesh2HRTF tools then you are already Done.
In Linux/Mac, you do need to compile NumCalc from source, but it is extremely easy:
1. Compile it: in the directory path/to/your/mesh2hrtf-git/mesh2hrtf/NumCalc/Source run the command make
(in the command line, type "make" and hit Enter)
2. "Install" (copy) NumCalc to a folder in your program path: in the same directory run sudo cp NumCalc /usr/local/bin/
3. Done.
Note: NumCalc is only a single-threaded solver code that could be given a whole project to execute sequentially, but in practice that would be extremely slow, inefficient and risky (if NumCalc is launched without extra parameters, it deletes all previously existing output data and starts-over simulation from the 1st step).
Therefore it is highly recommended to also use NumCalcManager.py
from Mesh2HRTF tools or some other scheduler that can efficiently monitor resource usage and correctly launch multiple NumCalc instances in parallel.
If you need to re-compile NumCalc.exe (compiled binaries are obsolete), then it can be compiled by any MinGW 64bit compiler. This method uses MSYS2 version of MinGW64 compiler, but there are also other valid approaches to use MinGW compiler variants on Windows.
Sidenote MSYS2 is also used to compile hrtf_mesh_grading.exe for Mesh2HRTF.
Go to https://www.msys2.org and get the MSYS2 by following the excellent Installation instructions on the front-page.
pacman -Syu
(Update the package database and base packages.)pacman -Su
(Update the rest of the base packages)pacman -S --needed base-devel mingw-w64-x86_64-toolchain
Open “MSYS2 MinGW 64-bit.exe” that you just installed and proceed to compile NumCalc.exe:
Use the following commands to change to the “Source” folder from which the compilation needs to be started. (To be on the safe side, do not use paths with spaces and non-standard characters):
cd C:
cd path/to/your/mesh2hrtf-git/mesh2hrtf/NumCalc/Source
Compile (using the normal Linux make command):
make
Fixing the DLLs to make your NumCalc.exe work. (Note, it is somehow possible to include all the necessary DLLs into .exe file during compilation, but this method works too):
C:\msys64\mingw64\bin
folder. Just copy the files with the right name next to the “NumCalc.exe”. Most likely the needed DLLs are: “libgcc_s_seh-1.dll”, “libstdc++-6.dll”, “libwinpthread-1.dll”.Fully compiled and ready to run NumCalc instance for running on Windows includes see example here:
"NumCalc.exe"
(most likely) 3 different necessary .dll files
Optional, just for testing - "- run_NumCalc_instance.bat"
The following modules should be installed only if Necessary.
Most users will not use the following modules.
There is an alternative code for Matlab to generate SOFA files.
Warning Matlab Output2HRTF code currently is not equivalent to the Python alternative and may be missing some features (for example SOFA compatibility fixes and ability to merge left and right side SOFA simulations).
addpath()
and initialize the SOFA API (SOFAstart
) to use Matlab Mesh2HRTF scripts.addpath('path/to/your/mesh2hrtf-git/mesh2hrtf/Output2HRTF')
addpath('path/to/your/SOFA API for Matlab and Octave\API_MO\')
These steps are required to visualize the sound pressure on the Mesh, e.g., a 3D head model.
Requirements: Matlab, Paraview
This software is not required and not related to Mesh2HRTF, but can be useful for Mesh2HRTF users:
https://www.meshlab.net/#download - Meshlab is a very powerful but quirky open-source tool for merging and fixing 3D scan data.
https://www.meshmixer.com/download.html - Quite easy to use, but very slow software for 3D scan merging, cleanup and smoothing.
...
Next tutorial step >>> 3D scanning
Wiki: Basic_HRTF_NumCalc_Simulation
Wiki: Basic_HRTF_tutorial
Wiki: Basic_tutorial_3d_scanning
Wiki: Change_Blender_export_defaults
Wiki: Express_Basic_HRTF_tutorial
Wiki: Installation
Wiki: NumCalc