< Back to IRCAM Forum

Using SOFA files in the browser

I am planning to set up a web-based application environment for a research project and would like to order custom HRTFs from a service (earfish.eu) to use in the project.

Since I am completely new to the field of spatial audio, I was wondering about the current state of things concerning custom HRTFs in the browser and if someone could point me in the proper direction.

I have read a paper from 2015 that uses custom HRTFs by compiling them into a custom Chromium build:

Then there is a project by IRCAM that provides a special Node to be used with the Web Audio API:

Both approaches seem doable (with the Chromium build being the less attractive option), but are both rather old. Is there anything more recent or would this still be the options to go with?

Another newbie question: What do I need to go from SOFA to the list of IR Composite audio files that are used both in the Chromium build and the binauralFIR node? Do you have any tips on relevant documentation or converters?

Thanks in advance!

Hi Anton,

Back in 2015, I wrote a paper about loading custom HRTFs in the browser:

I hope you will find it useful.
I have not really followed closely the evolution of the WebAudioAPI, but I’m afraid that nothing has changed with regard to loading custom HRTFs.

As the WAA built-in PannerNode cannot load custom HRTF, we have developed our own custom binauralFIR Node (as you saw).
This node used to work in collaboration with : GitHub - Ircam-RnD/serveSofaHrir: NodeJS module to fetch and shape SOFA formated HRIR sets from server
which fetches SOFA data from openDAP server (http://opendap.ircam.fr), and the server converts SOFA to JSON. I have no idea if this workflow is still working today. (hopefully yes)
The whole openDAP world was quite poorly documented. (no idea if this has improved since 2015)

Building your own Chromium with hard-coded HRTF is another option, but certainly not simple to do.

Back in 2015, I remember having a look at the “composite HRTF” hard-coded in Chromium/WAA. If I remember correctly, these look like Frankenstein-HRTFs, obtained via unorthodox processing.

We had asked the WAA committee to support custom SOFA files (Permit loading of custom HRTFs (including SOFA) · Issue #17 · WebAudio/web-audio-api-v2 · GitHub and loadHRTFDatabase for SpatialPanner · Issue #2417 · WebAudio/web-audio-api · GitHub). The ticket has been closed, but I doubt this was ever implemented, unfortunately.

Again: all this is my recollection from 2015; it’s possible that things have changed.

Hope this helps,

Dear Thibaut,

thanks a lot for the in-depth feedback! This is a lot of interesting info and I’ll check out your paper tomorrow. I also added my wish for custom SOFA files in the Web Audio repo. I think with all the stuff going on with XR, it would be time to add this functionality.

There is a tool to create SOFA files from 3D scans that I wanted to look into: https://github.com/Any2HRTF/Mesh2HRTF. I think it should work a bit like the custom spatial audio feature in iOS, which would be quite cool.

Now, if I understand correctly then the openDAP server is hosting a collection of existing SOFA files. Is it possible for me to host my own database and have my SOFA files converted to JSON? I could not find the code for the server to set up my own database.

I think what is acutely missing for me now is how I go from the SOFA file to the separate IRC audio files. The JSON files contain these files as buffers (I suppose), but it is not clear to me how I generate them from the SOFA file. Then again, maybe I just did not read enough about it yet…

In any case, thanks a lot so far, this really helps!


Hello Anton,

I’m not sure if we can host your database on our openDAP server. I’d have to check with our IT department.
Is your database already publicly available somewhere ?

I think what is acutely missing for me now is how I go from the SOFA file to the separate IRC audio files.
What do you mean by “separate IRC audio files” ? I’m not sure what you’re referring to.