Skip to main content

Diffraction Enhanced Image Source Method - Arbitrary Room Geometry (DEISM-ARG)

DOI Documentation Status PyPI version

The code in this folder is able to solve the following problem:

A source and a receiver transducer with arbitrary directivity are mounted on one/two speakers; The local scattering and diffraction effects around the transducers result in complex directivity patterns. The directivity patterns can be obtained by analytical expressions, numerical simulations or measurements.

In DEISM-ARG, we can model the room transfer function between transducers mounted on one/two speakers using the image source method while incorporating the local diffraction effects around the transducers. The local diffraction effects are captured using spherical-harmonic directivity coefficients obtained on a sphere around the transducers. In addition to DEISM in shoebox rooms, DEISM-ARG can model more complex room shapes. However, for version 2.0, we now only supports convex shapes. In short, DEISM-ARG has the following features:

  1. Arbitrary directivities of the source and receiver
  2. Angle-dependent reflection coefficients, frequency- and wall-dependent impedance definition.
  3. Convex room shapes

image-20240812131054348

📚 Documentation

📖 Read the full documentation on Read the Docs

Installation

DEISM supports Python 3.10, 3.11, and 3.12 on Windows, Linux, and Apple Silicon macOS. Intel macOS is not supported, because the numba dependency no longer builds there. The current documentation is organized around the class-based workflow implemented by deism.core_deism.DEISM.

Useful entry points:

Check Python version

On macOS or Linux:

python3 --version

On Windows PowerShell:

python --version

If you do not have a supported Python version, install one from python.org.

Installation method 1: Python virtual environment

End users

On macOS or Linux:

python3 -m venv ~/.venv/deism
source ~/.venv/deism/bin/activate
python -m pip install --upgrade pip
python -m pip install deism

On Windows PowerShell:

python -m venv C:\Users\<YourUsername>\venvs\deism
C:\Users\<YourUsername>\venvs\deism\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install deism

If PowerShell blocks activation, run:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Developers

On macOS or Linux:

git clone https://github.com/audiolabs/DEISM.git
cd DEISM
python3 -m venv ~/.venv/deism_dev
source ~/.venv/deism_dev/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -e .

On Windows PowerShell:

git clone https://github.com/audiolabs/DEISM.git
cd DEISM
python -m venv C:\Users\<YourUsername>\venvs\deism_dev
C:\Users\<YourUsername>\venvs\deism_dev\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -e .

DEISM reads pre-generated convex-room .msh files through meshio. Geometry scripts such as .geo must be meshed before they are passed to DEISM. The room must be convex, and every wall must carry exactly one named Physical Surface whose name matches its material key; the reader rejects non-convex rooms, untagged or unnamed walls, and surfaces that cover only part of a wall.

Installation method 2: Conda environment

End users

conda create -n deism python=3.12
conda activate deism
python -m pip install --upgrade pip
python -m pip install deism

Developers

git clone https://github.com/audiolabs/DEISM.git
cd DEISM
conda env create -f deism_env.yml
conda activate DEISM
python -m pip install -e .

Build tools for source installs

Published wheels include DEISM's two C++ extensions. Building from a source checkout or source distribution requires a working C++ compiler.

macOS:

xcode-select --install

Ubuntu or Debian:

sudo apt-get update
sudo apt-get install build-essential g++ python3-dev

RHEL, CentOS, or Fedora:

sudo yum install gcc-c++ python3-devel

Windows:

Verify the installation

Basic import check:

python -c "import deism; print('DEISM import OK')"

Native-extension check:

python -c "from deism import libroom_deism; from deism.count_reflections_wrapper import CPP_COUNTING_AVAILABLE; assert libroom_deism and CPP_COUNTING_AVAILABLE"

Quick help check:

python examples/deism_singleparam_example.py --help

Quick smoke run:

python examples/deism_singleparam_example.py

Additional notes

  • Some plotting utilities use matplotlib with text.usetex = True, so a LaTeX installation may be needed for figure rendering. See the Matplotlib usetex documentation.
  • Most example outputs are written below outputs/.

Running DEISM

The current public workflow is class-based:

from deism.core_deism import DEISM

deism = DEISM("RIR", "shoebox")
deism.update_room()
deism.update_wall_materials()
deism.update_freqs()
deism.update_directivities()
deism.update_source_receiver()
deism.run_DEISM()

Default configuration files

DEISM selects its default YAML configuration from the pair (mode, roomtype):

Mode Room type Default config file
RTF shoebox examples/configSingleParam_RTF.yml
RIR shoebox examples/configSingleParam_RIR.yml
RTF convex examples/configSingleParam_ARG_RTF.yml
RIR convex examples/configSingleParam_ARG_RIR.yml

These files are also bundled with installed wheels and source distributions. Repository-local files retain precedence, while an installed package falls back to its bundled defaults when invoked from another working directory.

Workflow order

Shoebox workflow:

  • update_room()
  • update_wall_materials()
  • update_freqs()
  • update_directivities() and update_source_receiver() in either order
  • run_DEISM()

Convex workflow:

  • update_room()
  • update_wall_materials()
  • update_freqs()
  • update_source_receiver()
  • update_directivities()
  • run_DEISM()

The convex order is stricter because ARG directivity setup depends on reflection-path state computed during update_source_receiver().

Beginner examples:

  • examples/deism_singleparam_example.py for the current shoebox path
  • examples/deism_arg_singleparam_example.py for the current convex path

Advanced or research-oriented examples:

  • examples/deisms_lc_mix_test.py
  • examples/shoebox_images_cal_compare.py
  • examples/deism_args_compare.py
  • examples/deism_arg_pra_compare.py
  • examples/deism_arg_IWAENC_fig5_fig6.py
  • examples/deism_JASA_fig8.py
  • examples/deism_JASA_fig9.py

For more detail, use the docs pages linked above instead of relying only on the older example scripts.

Directivities

Modeling the directivities of the source and receiver in the room acoustics simulation is receiving increasing attention. The directivities of the source or receiver can include both the transducer directional properties and the local diffraction and scatterring effects caused by the enclosure where the transducers are mounted. Modern smart speakers are typical embodiments of such scenarios. Human heads are also a very common case.

Simple directivities

  • Monopole

Arbitrary directivities

Some key information should be provided if you want to include your own directivity data:

  1. Frequencies at which the directivities are simulated or measured. A 1D array.
  2. The spherical sampling directions around the transducer: azimuth from $0$ ( $+x$ direction) to $2 \pi$, inclination angle from $0$ ($+z$ direction) to $\pi$. A 2D array with size (number of directions, 2).
  3. The sampled pressure field at the specified directions and frequencies. A 2D array with size (number of frequencies, number of directions).
  4. The radius of the sampling sphere. A 1D array or float number.

For more information about directivity definition used in DEISM and DEISM-ARG, please refer to the following publication:

Zeyu Xu, Adrian Herzog, Alexander Lodermeyer, Emanuël A. P. Habets, Albert G. Prinn; Acoustic reciprocity in the spherical harmonic domain: A formulation for directional sources and receivers. JASA Express Lett. 1 December 2022; 2 (12): 124801. https://doi.org/10.1121/10.0016542

Contributors

  • M. Sc. Zeyu Xu
  • Songjiang Tan
  • M. Sc. Hasan Nazım Biçer
  • Dr. Albert Prinn
  • Prof. Dr. ir. Emanuël Habets
  • Anjana Rajasekhar

Academic publications

If you use this package in your research, please cite our paper:

Zeyu Xu, Adrian Herzog, Alexander Lodermeyer, Emanuël A. P. Habets, Albert G. Prinn; Simulating room transfer functions between transducers mounted on audio devices using a modified image source method. J. Acoust. Soc. Am. 1 January 2024; 155 (1): 343–357. https://doi.org/10.1121/10.0023935

Z. Xu, E.A.P. Habets and A.G. Prinn; Simulating sound fields in rooms with arbitrary geometries using the diffraction-enhanced image source method, Proc. of International Workshop on Acoustic Signal Enhancement (IWAENC), 2024.

Configuration files

The current default configuration files are:

  • examples/configSingleParam_RTF.yml for shoebox RTF
  • examples/configSingleParam_RIR.yml for shoebox RIR
  • examples/configSingleParam_ARG_RTF.yml for convex RTF
  • examples/configSingleParam_ARG_RIR.yml for convex RIR

See docs/configuration.rst for the configuration groups and runtime parameter mappings.

Compact image storage

Image generation and reflection attenuation are decoupled by default in both room types ("compact" mode): the image-source engine emits frequency- independent path geometry, and the frequency-dependent attenuation is rebuilt from it by a parallel numba kernel. This makes image generation independent of the number of frequencies and avoids holding the full (n_images, n_frequencies) attenuation array.

Each room type has its own flag, because the two paths were implemented separately and rebuild attenuation at different points:

Room type Flag Default Attenuation rebuilt
Convex (DEISM-ARG) convexCompactImages 1 (compact) Once, in get_ref_paths_ARG
Shoebox shoeboxCompactImages 1 (compact) Per batch, inside the solver

Set either flag to 0 for the legacy materialized path. Neither flag is read from the YAML configuration files or the command line — both are set programmatically, e.g. deism.params["convexCompactImages"] = 0.

Shoebox rooms

Compact shoebox storage is produced only by the numba image generator (shoeboxImageCalcVersion="v2-numba", the default). Selecting a serial generator degrades to materialized storage rather than failing. Two further consequences:

  • images["atten_all"] (and the atten_all_early / atten_all_late pair) is absent in compact mode. Code that reads those arrays directly must set shoeboxCompactImages=0.
  • The legacy Ray backend cannot consume compact storage and raises NotImplementedError. Use the numba backend (run_DEISM), which is the faster and supported path.

RTFs agree with materialized storage to ~1e-8 relative error for ORG, LC, and MIX, with real and complex impedance alike.

Convex rooms (DEISM-ARG)

For convex rooms the compact geometry is the wall sequence and incidence cosine per image.

Configuration (in the parameter dictionary / config):

  • convexCompactImages (default 1): 0 selects the legacy path.
  • convexCompactEngine (default "cpp"): which engine produces the compact geometry when compact mode is on — "cpp" (the libroom C++ extension) or "python" (Room_deism_python, the reference producer). The C++ engine is the default because it is faster at every band count measured and matches the Python producer exactly on wall sequences, to 1e-4 on incidence cosines and to 1e-5 end to end; select "python" when the extension cannot be built. Rebuild the extension after updating the sources: python setup.py build_ext --inplace.

Neither flag is read from the YAML configuration files or the command line — both are set programmatically on the parameter dictionary, e.g. deism.params["convexCompactImages"] = 0 to select the legacy path.

convexCompactEngine is ignored in legacy mode (convexCompactImages=0), which keeps the original C++ behavior with per-frequency attenuation computed in libroom.

Notes:

  • Compact mode supports exactly one receiver per run (the standard DEISM-ARG setup). Multiple receivers raise an error.
  • This DEISM-ARG compact path is 3D-only and applies to convex rooms. Shoebox rooms have their own compact storage, described above, selected with shoeboxCompactImages.
  • Complex impedance is handled exactly in compact mode (the attenuation is rebuilt by _build_arg_attenuation_batch); the legacy C++ path truncates complex impedance to its real part — a known parity gap of order 1e-2.
  • Compatible with the ORG, LC, and MIX DEISM variants and with ifRemoveDirectPath; output shapes are unchanged relative to legacy mode.
  • Cross-engine agreement is implementation parity, not acoustic validation: the known DEISM-ARG limitations for arbitrary geometries (reflection- boundary discontinuities, missing spherical-wave reflection effects, edge/ corner diffraction) apply to all backends equally.

Metadata

Release files for deism 2.2.1.16

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

Source distribution (sdist)

Source distribution for deism 2.2.1.16
File Size Uploaded
deism-2.2.1.16.tar.gz 998.3 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for deism 2.2.1.16
File
deism-2.2.1.16-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
deism-2.2.1.16-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
deism-2.2.1.16-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
deism-2.2.1.16-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
deism-2.2.1.16-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
deism-2.2.1.16-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
deism-2.2.1.16-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
deism-2.2.1.16-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
deism-2.2.1.16-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details

Total release size: 54.3 MB

Release files / deism-2.2.1.16.tar.gz

Download URL deism-2.2.1.16.tar.gz
Size 998.3 kB
Tags Source
SHA-256 checksum
How to use checksums
018d7f55e44455d627c4e76d91a842b0cdb0f2f77ad63bf97d2e326ee4ad293f
BLAKE2b-256 checksum
How to use checksums
24a33cca8a0d483f297f87fe0d23eb7c2b639a72004e2c59f1e51292b7844e8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / deism-2.2.1.16-cp312-cp312-win_amd64.whl

Download URL deism-2.2.1.16-cp312-cp312-win_amd64.whl
Size 529.2 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
a19167511e93fd5f633a09e3a585cf52618055918253b908a539554ab53782cf
BLAKE2b-256 checksum
How to use checksums
1ea1c90103f652a2a8735c15aeacdb9eb50cb43c713982cf912e6712acf8353f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / deism-2.2.1.16-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL deism-2.2.1.16-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 16.7 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
95046375d8c48386b8d135c8cd345527f333fbaf7338ecb868c0b9c752061dff
BLAKE2b-256 checksum
How to use checksums
dc8b04d440f81039a6773d9516c5a3e85ffac108b989468506a4ee44422ec8b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / deism-2.2.1.16-cp312-cp312-macosx_11_0_arm64.whl

Download URL deism-2.2.1.16-cp312-cp312-macosx_11_0_arm64.whl
Size 627.3 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
cf64855a0806f416c5a47aa3fd07b00e080e3aac73a23e3d0daaeed20ce077e8
BLAKE2b-256 checksum
How to use checksums
ea50dd56203c18be7fbc90ea0462901423b300c2baf84b68a80d40be09ba1e8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / deism-2.2.1.16-cp311-cp311-win_amd64.whl

Download URL deism-2.2.1.16-cp311-cp311-win_amd64.whl
Size 524.8 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
c0e7b45c078bcceb98eb775a4e7efa99857a5d1dd366e6b2a57b586594756f30
BLAKE2b-256 checksum
How to use checksums
d0cfc098acd81d3ee2a1eed4cfb875e13abe4f58831504c781471d16db3629de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / deism-2.2.1.16-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL deism-2.2.1.16-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 16.6 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
436a456ade8749949d755a425fca02c378981bb05f9b9bd7dace8cd540199b15
BLAKE2b-256 checksum
How to use checksums
aedc256a527a36b2041249276eec1a78237b44e32d0ffff3e9984e158e12b158
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / deism-2.2.1.16-cp311-cp311-macosx_11_0_arm64.whl

Download URL deism-2.2.1.16-cp311-cp311-macosx_11_0_arm64.whl
Size 622.5 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
96ed1193c9b51ec7f677cf8a665beb77469ee0bd2ee9389276ad68c33dabd858
BLAKE2b-256 checksum
How to use checksums
657db3deea5f11db14db761830786e6b14c258528bcce0e4d65b5c6c808303c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / deism-2.2.1.16-cp310-cp310-win_amd64.whl

Download URL deism-2.2.1.16-cp310-cp310-win_amd64.whl
Size 523.1 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
fa62f58c1c95a176fbd66ba51b24542d80cf6d02ef4417fc2d156ff15d9b7be0
BLAKE2b-256 checksum
How to use checksums
6740d41e1e6c22e78f61c562f2ed02c0c3978d64dc6d15e6dfad68f74e869ad7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / deism-2.2.1.16-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL deism-2.2.1.16-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 16.6 MB
Tags CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
f3829b8d1bd24513bae0adad0508061ae9359011253f8dc1fec43f203135b6c4
BLAKE2b-256 checksum
How to use checksums
f4dc7e74064cd082050920685d9baf3928dfbe5f5871d6884c294814db604ab3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / deism-2.2.1.16-cp310-cp310-macosx_11_0_arm64.whl

Download URL deism-2.2.1.16-cp310-cp310-macosx_11_0_arm64.whl
Size 619.7 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
83c6b26465a522b88a74fef71b562bc15e49183590410ed5b585a17c318e7811
BLAKE2b-256 checksum
How to use checksums
f5a984138d6d283d4de63c61c0ec92da7a778a000a7c2aebdaca10d5276a087e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release history Release notifications | RSS feed

2.3.1

10 release files

2.3.0

10 release files

This release

2.2.1.16 This release

10 release files

2.1.3

9 release files

2.1.2

9 release files

2.1.1

9 release files

2.1.0

9 release files

2.0.2

9 release files

2.0

10 release files

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