Menu

Advanced_SOFA_to_HeSuVi_conversion

Sergejs

Advanced SOFA to HeSuVi conversion

How to use individual HRTF with HeSuVi for system-wide 7.1 sound on a Windows PC.

Tutorial Status Date Written Date Last Updated
Ready for use. More optimizations likely to come. 2022-09-20 2022-11-13

Help - You are welcome to contact author about any extra information, corrections or other input. New tools and approaches appear literally every month, so this page can be updated as needed.


Introduction

HeSuVi with Equalizer APO enables use of SOFA files for Fixed 2.0 or 7.1-channel virtual surround.

This method creates HeSuVi (or even matrix-convolver) compatible Impulse Responses by applying SOFA HRTF as an effect inside audio editor (Reaper DAW). Key advantage of this method is the ability to bake-in additional audio effects like reverb or headphone equalization into a single file with 14 impulse responses (including extremely resource-intensive algorithms). By borrowing Impulcifer scripts, the whole operation requires very few manual steps.

  • NOTE: This whole tutorial is the "Advanced SOFA to HeSuVi conversion". The more limited but faster approach to convert SOFA to HeSuVi is to use original ffmpeg method (check if the compatibility issues are resolved, did not work in 2022-09).
  • NOTE: This method can produce identical results (sound) as Fully-featured individual 7.1 surround with head-tracking only with-Out head-tracking support (only fixed-to-the-head virtual surround). This method will also use less resources and allows direct comparisons with other virtual surround options.

The following is a step-by-step guide.


1 - Get the Impulcifer

Impulcifer needs to be installed using 1 out of 2 methods depending if Impulcifer still requires Python 3.8!!! (as it did in 2022-09).

  1. In case Impulcifer is compatible with your current system-wide installed version of Python (not very likely scenario) then you can follow the official Impulcifer installation tutorial. As of 2022-09, Impulcifer requires precisely Python 3.8 (not newer).

    • Note, it is not necessary to use git clone command, instead it is sufficient to just download Impulcifer code from GitHub by clicking on Code ==> Download ZIP on the website and unpacking the zip file (similar to Mesh2HRTF installation).
  2. In case you have incompatible Python 3 version installed, then it is necessary to install Python 3.8 for Impulcifer in parallel to existing Python installation. To do that, a practical approach is to use "Conda", as described in Mesh2HRTF tutorial. If you choose the Conda installation, then follow these steps:

    1. Download Zip of Impulcifer files from GitHub by clicking on Code ==> Download ZIP. (alternatively you can clone the repository with git).
    2. Install Conda and create Python 3.8 environment in it. In the end of the Conda installation change directory to your main Impulcifer directory (folder containing “requirements.txt” file): cd c:\your\path\to\Impulcifer
    3. Note, we can skip all installation steps related to "venv" virtual environment, because Conda is in itself a virtual environment, only it includes the whole Python as well.
    4. Install required packages by running pip install -U -r requirements.txt (assuming you are in the correct Terminal/Command-line where Impulcifer environment is activated)
    5. Verify installation by running help command: python impulcifer.py --help (there should be no errors)
      • Note that Impulcifer commands are normally executed directly from a Terminal/Command-line (not from within Python).

Finish Impulcifer installation
The final step to configure Impulcifer is to generate the 7.1 source sweep audio file. It is done similarly as all other Impulcifer operations:

  1. in the correct Terminal/Command-line where Impulcifer environment is activated.
  2. Make sure you have changed to the Impulcifer folder cd c:\your\path\to\Impulcifer
  3. Run command python impulse_response_estimator.py --dir_path=data --fs=48000 --speakers=FL,FC,FR,SR,BR,BL,SL --tracks=7.1 --duration=5 (it is based on this example)

Alternative to Impulcifer
NOTE: in case there is a need to avoid using Impulcifer for some reason, it is possible to get the same results as described in this tutorial by replacing Impulcifer-specific steps by steps from official HeSuVi - How-To Record Impulse Responses tutorial. That tutorial has a bit different purpose; requires more manual steps and would need to be executed in Reaper to get more reliable VST plugin support, but it should still work.

2 - Get all other software

  1. Install Reaper DAW - this DAW is widely used, suppoted by most effect plugins, quite affordable and has a reasonable never-expiring-trial period.

  2. Download and install SPARTA plugins - all open-source, cross-platform SPARTA VST plugins come as one package with an installer.

3 - Reaper processing

No prior Reaper knowledge needed:

  1. Start from blank "New Project".
  2. Set project to 48 kHz (HeSuVi convention). Go to File ==> Project settings ... and set the projct to 48000 Hz.
  3. Drag-and-drop the "sweep-seg-FL,FC,FR,SR,BR,BL,SL-7.1-6.15s-48000Hz-32bit-2.93Hz-24000Hz.wav" file from ...\Impulcifer\data into the Reaper to create a new track.
  4. Add VST plugin that can apply SOFA HRTF on the sweep as an effect (SPARTA Binauraliser):

    1. Click on FX
    2. Select "sparta_binauraliser"
    3. "Add" it.
  5. Configure SPARTA Binauraliser following this tutorial.

    • Make sure to Import "SPARTA 7.1 config for 7.1 and Windows standard.json" config file - it has correct channel order to match Impulcifer sweep file.
    • fully configured SPARTA Binauraliser in Reaper (note that "Diffuse-field EQ" is optional and "Rotation" should not be used).
  6. Optional: "SPARTA Binauraliser" is not the only VST plugin that can apply SOFA binauralization. You are encouraged to experiment with other binauralizers (one at a time! And repeat the following Rendering step for each binauralizer). For example:.

    1. SPARTA Spreader "uses an optimised framework for rendering spread sound sources over an arbitrary playback system (..) such that the output signals create a diffuse, or rather: “incoherently spead” sound source." It could produce another effect compared to SPARTA Binauraliser's ideal HRTF point sources.

      • SPARTA Spreader needs very similar configuration as SPARTA Binauraliser.
      • Note that there is no "Diffuse-field EQ" option in Speader - any equalization must be applied by other means (for example).
      • Instead of Importing ready made "SPARTA 7.1 config for 7.1 and Windows standard.json" config, it is necessary to maually configure 8 input channels with their Azimuth and Elevation values (See the values from SPARTA Binauraliser).
      • Experiment with "Spread" values for each input! Try 5 degrees or other values to get the speading effect.
    2. Other VST plugins? Note that most binauraliser plugins will do the same thing as SPARTA Binauraliser, so check which plugin features you are interested to test.

  7. Note: use the same process to add any additional VST plugins, for example headphone EQ or some reverb plugins of your choice (add reverb to taste - usually not needed).

  8. Render the SOFA HRTF effect on the Impulcifer sweep file:

    1. Go to File ==> Render...
    2. Set source to "Selected tracks"
    3. Specify filename exactly as FL,FC,FR,SR,BR,BL,SL and specify a name of the NEW folder, for example ...\Impulcifer\data\mySOFA_forHeSuVi (Reaper will create the new "mySOFA_forHeSuVi" folder automatically).
    4. Specify Stereo for channels (because after binauralization there are only 2 channels left - for left and right ear over headphones).
    5. Format "WAV" with bit depth "32bit PCM".
    6. Press "Render 1 file".
  9. Check and fix any clipping issues:

    1. If you see that Peak level is positive (+)m that means the output file is too loud and must be re-rendered after the level adjustment:
    2. Use the fader on the right track to lower the volume a bit more than the Peak value from the first rendering attempt. To get more exact control, try Right-Clicking the fader and in the "Routing" window it is possible to enter exact dB value.
    3. Re-render the file and overwrite existing "FL,FC,FR,SR,BR,BL,SL.wav" from the initial attempt. Now you should see Peak gain as some negative value.

4 - Impulcifer processing

  1. Generate the HeSuVi file by running Impulcifer command: python impulcifer.py --test_signal="data/sweep-6.15s-48000Hz-32bit-2.93Hz-24000Hz.wav" --dir_path="data/mySOFA_forHeSuVi" --plot --no_headphone_compensation --no_room_correction

    • Note that the "test_signal" is specified as a 1-channel equivalent of the 7.1 sweep used in Reaper.
    • "--plot" command makes the processing slow, but produces interesing, detailed plots. NOTE - current version crashes if "--plot" option is not used! (unless "plots" folder is created manually in the output folder)
    • There are more features and options that can be used in Impulcifer itself, for example Target Curve, bass boost or tilt controls which can be used not only to personalize the sound but also as a method to apply headphone EQ. See details here or run python impulcifer.py --help
  2. Move and test the HeSuVi results: To test the processed SOFA HRTF in HeSuVi copy hesuvi.wav into C:\Program Files\Equalizer APO\config\Hesuvi\hrir\, (re)start HeSuVi and select hesuvi.wav from the Common HRIRs list on Virtualization tab to use it.

    • You are free to rename the hesuvi.wav to anything you want.
    • Note, Impulcifer produces hrir.wav and hesuvi.wav which can be used not only with HeSuVi on Windows, but also with other matrix convolvers. For example SPARTA MatrixConv could work also on Apple MacOS and Linux. Only make sure the channel order is correct, see "Confusion of 7.1 and 5.1 channel order". From MatrixConv tooltips:

      • "Example 4, virtual monitoring of a multichannel setup: if you have a set of binaural head-related impulse responses (BRIRs) which correspond to the loudspeaker directions of a measured listening room, you may use this 2 x L matrix of filters to reproduce loudspeaker mixes (L-channels) over headphones. Simply concatenate the BRIRs for each input channel into a two channel wav file and load them into the plugin, then set the number of inputs to be the number of BRIRs/virtual-loudspeakers in the mix."
  3. Do not forget to preserve the resulting files hrir.wav and hesuvi.wav next to your source SOFA HRTF files together with description of the processing parameters applied in Reaper and Impulcifer.

  4. Optional - edit away silence at the end of hesuvi.wavfile. Trimming silence can further reduce resource usage, but otherwise makes no difference.

Done!

5 - extra Steps & Effects

ToDo - list of additional VST plugins and tricks to customize the HRTF sound

Also see additional tools and options in Everyday use of SOFA HRTF wiki article.


HeSuVi

If you do not yet have HeSuVi installed, there are Tips to configure HeSuVi in this Wiki or you are welcome to use HeSuVi tutorials and YouTube videos.

Summary

Using this method:

  • You can use individual SOFA HRTF for all content on Windows computers with minimal resource usage and low latency. (Gaming, movies, music in up to 7.1 channel surround using SOFA files created by Mesh2HRTF or any other method).

  • You can bake-in very complex effects into your individual SOFA HRTF. For example render in non-realtime very computationally heavy "room simulation" that applies complex reverb effects based on virtual placement of sound sources in a room of a specific size, etc.

  • You can directly compare any SOFA HRTF against most commercial virtual-surround technologies with the help of HeSuVi. Same comparison works against individual BRIRs generated by Impulcifer method.

  • Easy approach to try Mesh2HRTF for existing HeSuVi users - If you previously used HeSuVi, this method makes trying out Mesh2HRTF individual HRTFs painless - just load another Impulse Response and you are done.

  • You can save stereo files with your individual HRTF baked-in for playback on any device by converting any 2.0/5.1/7.1 audio file following this tutorial: "Apply HeSuVi to Any Audio File for Mobile Usage".

  • With some additional work this method should also work cross-platform on Apple MacOS and Linux with the help of SPARTA MatrixConv (More testing and fixes are needed).

Note, If you try this method, consider providing your feedback on Binaural Audio Discord by 3DJ, https://www.reddit.com/r/HRTF or other forums!


Related

Wiki: Confusion_of_7-1 and 5-1_channel_order_in_Windows
Wiki: Earful_tutorial
Wiki: Everyday_use_of_SOFA_HRTF
Wiki: Home
Wiki: virtual_surround_with_headtracking_tutorial

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.