Skip to main content

sofamyroom

This project proposes a fast, accurate, and flexible "shoebox" room acoustics simulator that supports both specular and diffuse reflections. The simulator extends the work released by Schimmel et al., called Roomsim, by adding the rendering of Binaural Room Impulse Responses (BRIR) using arbitrary Head Related Transfer Functions (HRTFs) stored with the AES Spatially Oriented Format for Acoustics (SOFA) file format. Moreover, SofaMyRoom can be launched directly from your console of choice.

The SOFA support is possible thanks to MySofa library (hereinafter referred as libmysofa) and it can export the results of the simulation to a WAVE file.

Thanks to the Virtual Acoustic Space Traveling (VAST) framework [1], we added the possibility to systematically generate labeled datasets to train and test machine learning algorithms.

The full documentation is available at robaru.github.io/sofamyroom. A pre-print describing sofamyroom is available on arXiv.

Note (October 2026): the git history was rewritten to merge the old repositories into a single line. If you cloned sofamyroom before, please re-clone it; existing clones will not pull cleanly.

Installing sofamyroom

sofamyroom is built from source with CMake (see Building). The third-party code it needs (libmysofa, PocketFFT, SFMT) is included in the repository and compiled together with it, so the resulting program is self-contained. The only system library is zlib, which macOS, the Linux distributions and MATLAB already provide; on Ubuntu Linux the development package is needed to build (sudo apt-get install zlib1g-dev), on Windows see Building on Windows. Only 64-bit platforms are supported.

Usage

sofamyroom reads a text file with the setup parameters and writes one WAVE file per receiver in the current directory. From the repository root, after building and downloading the KEMAR HRTF set (see Testing):

build/cmake/sofamyroom data/sampleroomsetup.txt

data/sampleroomsetup.txt is a commented sample of the setup file; the paths in it (SOFA file, output name) are relative to the directory you run the command from.

The setup file

The setup file lists the room, the simulation options and the sources and receivers, one name = value; assignment per line (% starts a comment). The complete list of parameters is in the documentation. Two options concern the output: options.outputname is the first part of the name of the WAVE files (one per source-receiver pair, the extension is added by sofamyroom), and options.mex_saveaswav makes the MEX file write WAVE files instead of returning a cell array (MATLAB only).

A binaural receiver is described by a string of the form

'SOFA PATH_TO_HRTF_FILE interp=VALUE norm=VALUE resampling=VALUE delay=VALUE'

where PATH_TO_HRTF_FILE is the relative or absolute path of the .sofa file and the options are:

  • interp: interpolate the neighbouring HRTFs instead of picking the closest measured direction.
  • norm: normalise the HRTF data.
  • resampling: resample the HRTFs to options.fs.
  • delay: apply the per-ear Data.Delay stored in the SOFA file, rounded to whole samples; use it with HRTF sets whose impulse responses are time-aligned and carry the interaural time difference in Data.Delay.

A value is T[RUE], t[rue] or 1 to enable an option and F[ALSE], f[alse] or 0 to disable it (only the first character is read). All options are optional and off by default; unrecognised options are skipped and, if an option is repeated, the last value is used. Valid examples:

'SOFA ./mySofaFile.sofa'
'SOFA ./mySofaFile.sofa interp=TRUE norm=0 resampling=t'
'SOFA ./myTimeAlignedFile.sofa delay=1'

Usage with MATLAB

The MEX-file takes the same parameters as a MATLAB structure. readsetup evaluates a setup file written as a MATLAB script (data/sampleroomsetup.m, same content as the .txt sample):

addpath matlab
setup = readsetup('data/sampleroomsetup.m');
output = sofamyroom(setup);

Usage with Python

The pysofamyroom package (pip install pysofamyroom, Python 3.10 or later) drives the same library in-process with the same parameters and returns the same samples:

import pysofamyroom as smr

setup = smr.read_setup("data/sampleroomsetup.txt")   # or build a smr.Setup(...)
setup.receivers[0] = smr.Receiver.sofa("data/MIT_KEMAR_normal_pinna.sofa", (3, 5, 1.2))
brirs = smr.simulate(setup)          # brirs[source][receiver]: (n_samples, n_channels)

pysofamyroom.vast generates annotated multi-room BRIR datasets in the VAST format (examples/vast_demo.py). See the Python documentation for details.

Building SofaMyRoom

These instructions will guide you through the steps to build SofaMyRoom on your local machine. CMake is required.

Building on Windows

You can use CMake to generate a Visual Studio solution that can be used to build sofamyroom. Open a new Command Prompt window and type the following commands:

> cd build
> cmake ../src -G"Visual Studio 16 2019" -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake

zlib must be available to the compiler; the command above takes it from vcpkg (vcpkg install zlib). To know how to generate solutions for other versions of Visual Studio, type cmake --help.

Building on Ubuntu Linux

You can use CMake to generate a Makefile for sofamyroom. Open a new Terminal window and type the following commands:

cd build
cmake ../src -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=BUILD_TYPE
make

CMAKE_BUILD_TYPE can be Debug, Release or Unittest. If CMAKE_BUILD_TYPE is not set, the default build type is Release. Before building the project, install the zlib headers:

sudo apt-get install zlib1g-dev

Building on MacOS

You can use CMake to generate a XCode project. Open a new Terminal window and type the following commands:

cd sofamyroom/build
cmake ../src -G"XCode"

Building with MATLAB

You can use MATLAB to generate a MEX-file. Type the following command in the Command Window:

cd src
make

You can build the MEX-file in Debug mode. Type the following command:

make debug

You can also build it in Unittest mode, to check the validity of sofamyroom functions. Type the following command:

make test

On Windows, pass the location of zlib as extra arguments, for example make('-IC:\vcpkg\installed\x64-windows\include', '-LC:\vcpkg\installed\x64-windows\lib', '-lzlib').

Known issues and limitations

  • When using the MEX library, MATLAB can crash since the memory allocation performed by libmysofa is not persistent.
  • The library is single-threaded and keeps the loaded sensors in global state: run one simulation at a time per process. To simulate many rooms in parallel, start several processes; the Python VAST generator does this for you with generate(..., workers=n).
  • Image sources are placed at integer sample delays (no fractional-delay interpolation).
  • room.surface.absorption is the energy absorption coefficient: each specular reflection multiplies the amplitude by sqrt(1 - absorption). room.surface.diffusion is the scattering coefficient: the specular image source is weighted by (1 - diffusion) and the diffuse part by diffusion, both in amplitude. The latter is the original Roomsim convention and is kept so that existing results can be reproduced; an energy-consistent weighting may be added later as an option. Both coefficients must be in [0, 1] (values above 1 found in some material tables have to be clipped by the user, the setup is rejected otherwise).
  • Reflections are positive real numbers and the analytical directivity patterns (cardioid, dipole, ...) use the magnitude of the pattern only, so a dipole has two in-phase lobes. This is a simplification shared by the Roomsim family.
  • SOFA receivers must use the SimpleFreeFieldHRIR convention with exactly two receivers (ears).
  • The SOFA Data.Delay is ignored unless the receiver description contains delay=1, in which case it is applied as a whole-sample shift per ear.
  • The diffuse tail is rendered from six spatial directions.

Testing

The unit tests need the MIT KEMAR HRTF set in data/:

curl -L -o data/MIT_KEMAR_normal_pinna.sofa http://sofacoustics.org/data/database/mit/mit_kemar_normal_pinna.sofa

Then build with CMake and run ctest:

cmake -S src -B build/cmake -DCMAKE_BUILD_TYPE=Release
cmake --build build/cmake
ctest --test-dir build/cmake --output-on-failure

The Python package is tested with pytest (the SOFA file is downloaded automatically if missing; one test compares the Python output with the sofamyroom executable above, bit for bit, when it has been built):

pip install -e ".[tests]"
pytest

Building the Python package

pip install . (or pip install -e . for development) compiles the library through the same CMake project with -DSOFAMYROOM_PYTHON=ON; it needs a C compiler and the zlib development files, CMake and ninja are fetched automatically if they are not installed. python -m build produces the sdist and the wheel.

Building the documentation

The documentation is built with Sphinx only; the Python pages use autodoc, so the package must be installed:

pip install -e ".[docs]"
sphinx-build -b html src/docsrc/sphinx build/html

The site at robaru.github.io/sofamyroom is rebuilt from master by the docs GitHub workflow.

License

The code written for sofamyroom is licensed under the EUPL-1.2 (LICENSE.txt). The files inherited from Roomsim by Steven M. Schimmel (University of Zurich, 2009) keep their original GNU GPL-3.0-or-later licence, and our modifications to them are released under the same GPL terms. Each of these files carries the original Roomsim header followed by a notice that states whether, and how, it was changed for sofamyroom:

  • src/libroomsim/ (all .c and .h files, except include/global.h which is new and EUPL-1.2)
  • src/libroomsim.h, src/main.c, src/mexmain.c, src/unittest.c
  • data/materials.mat (the Roomsim absorption-coefficient database used by editabsorption.m)
  • matlab/ estimateRT60.m, editabsorption.m, plotabsorption.m, estimateroombreakfreq.m, plotcoordsystem.m, plotbrir.m, readsetup.m, rsound.m, yprTr2s.m, yprTs2r.m, selectabsorption.m, plotroom.m, setcomplexity.m

Since the simulator core is GPL, every compiled form of sofamyroom (command line tool, MEX file, or a package that links it) is a combined work distributed under the GNU GPL-3.0-or-later; the EUPL-1.2 permits this through its compatibility clause. The GPL text is in LICENSE-GPL-3.0.txt; the Python wheel declares EUPL-1.2 AND GPL-3.0-or-later and ships both texts.

The third-party code included in src/ (libmysofa, PocketFFT, SFMT) is listed with its licence texts in THIRD_PARTY_LICENSES.md.

Credits

References

[1] C. Gaultier, S. Kataria, and A. Deleforge. "VAST: The virtual acoustic space traveler dataset." International Conference on Latent Variable Analysis and Signal Separation. Springer, Cham, 2017.

Metadata

Release files for pysofamyroom 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pysofamyroom 0.2.0
File Size Uploaded Provenance Actions
pysofamyroom-0.2.0.tar.gz 333.8 kB With provenance Details for pysofamyroom-0.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pysofamyroom 0.2.0
File Actions
pysofamyroom-0.2.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for pysofamyroom-0.2.0-py3-none-win_amd64.whl
pysofamyroom-0.2.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for pysofamyroom-0.2.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
pysofamyroom-0.2.0-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.27+ ARM64, Linux glibc 2.28+ ARM64 Details for pysofamyroom-0.2.0-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
pysofamyroom-0.2.0-py3-none-macosx_11_0_universal2.whl Python 3 none macOS 11.0+ universal2 (ARM64, x86-64) Details for pysofamyroom-0.2.0-py3-none-macosx_11_0_universal2.whl

Total release size: 1.1 MB

Release files / pysofamyroom-0.2.0.tar.gz

Download URL pysofamyroom-0.2.0.tar.gz
Size 333.8 kB
Tags Source
SHA-256 checksum
How to use checksums
411cc78554b6709bad4184b7a4e832a4f59e843ae35e3d79dac77ec470eefa57
BLAKE2b-256 checksum
How to use checksums
3a7aefafc2f9eea08879f628929e553481e8477f4b8476a48146baa52ef49487
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / pysofamyroom-0.2.0-py3-none-win_amd64.whl

Download URL pysofamyroom-0.2.0-py3-none-win_amd64.whl
Size 154.2 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
c6e086669482f7366914e95a64d7ef299a0d71c9319763c1a2491b9250efb632
BLAKE2b-256 checksum
How to use checksums
4d192d6e5556606d48ca84eb617968968f3d945d8fe19af6a32974b20c2d77c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / pysofamyroom-0.2.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pysofamyroom-0.2.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 146.9 kB
Tags Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
607c1f17e9c4a7debd051e00ea6c83ccdbf47510ab968e094465e377500f9591
BLAKE2b-256 checksum
How to use checksums
f73e8739686a92bd44f156482c6e09c4456475551dd315a850e6e0fd808a21c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / pysofamyroom-0.2.0-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL pysofamyroom-0.2.0-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 149.1 kB
Tags Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
1de16df699d94101dfdf9f515c4b310e9124e28b153508e71a0c286ac7799dd0
BLAKE2b-256 checksum
How to use checksums
793e0a232d6efedcc375de301c66231cd19381d5fa89cf79e8aec8da751880fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / pysofamyroom-0.2.0-py3-none-macosx_11_0_universal2.whl

Download URL pysofamyroom-0.2.0-py3-none-macosx_11_0_universal2.whl
Size 272.6 kB
Tags Python 3 macOS 11.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
34c38646420dba12810a1f125a0d6c40040501616fbbea2f227b1d38dcc97d17
BLAKE2b-256 checksum
How to use checksums
b96f7a0307ea2ae3d4b884d4a81b753c4c9367aa2c14f3d8c7d626808dee1df5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for pysofamyroom 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for pysofamyroom-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

5 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page