An image source-based method used to simulate room transfer functions for arbitrary room shapes.
Project description
Diffraction Enhanced Image Source Method - Arbitrary Room Geometry (DEISM-ARG)
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:
- Arbitrary directivities of the source and receiver
- Angle-dependent reflection coefficients, frequency- and wall-dependent impedance definition.
- Convex room shapes
📚 Documentation
📖 Read the full documentation on Read the Docs
Preparation and installing
DEISM supports Python versions 3.9, 3.10, and 3.11, and works on Windows, macOS, and Linux. You can install DEISM using either Python virtual environments or Conda.
Check Python Version
First, verify you have Python 3.9, 3.10, or 3.11 installed. Click on your operating system below:
macOS
Open the Terminal by pressing 'Command+Spacebar' and searching for 'Terminal'. Once the Terminal is open, type:
python3 --version
Tip: If you have not used the terminal before, you may be prompted to install Xcode Command Line Tools. Follow the prompts to install the package, then try the command again.
If you don't have Python or have an older version, download and install Python from python.org.
Linux/WSL
In your shell, run:
python3 --version
To check available Python versions for your distribution:
sudo apt update
apt show python3
If you need to install Python, run:
sudo apt install python3 python3-pip python3-venv
Windows
Open PowerShell by typing "PowerShell" in the Windows search bar. Once inside PowerShell, type:
python3 --version
Alternatively, you can type python and press Enter to open the Microsoft Store's installation page for Python.
If you don't have Python or have an older version, download and install Python from python.org.
Installation Method 1: Python Virtual Environment
Install DEISM (End Users)
macOS
In the terminal, run:
# Create virtual environment (recommended location)
python3 -m venv ~/.venv/deism
source ~/.venv/deism/bin/activate
# Install DEISM
pip install --upgrade pip
pip install deism
Linux/WSL
In your shell, run:
# Create virtual environment (recommended location)
python3 -m venv ~/.venv/deism
source ~/.venv/deism/bin/activate
# Install DEISM
pip install --upgrade pip
pip install deism
Windows
In PowerShell, run:
# Create virtual environment (recommended location)
python -m venv C:\Users\<YourUsername>\venvs\deism
C:\Users\<YourUsername>\venvs\deism\Scripts\Activate.ps1
# Install DEISM
python -m pip install --upgrade pip
pip install deism
Tip: If you get an execution policy error, run PowerShell as Administrator and execute:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Install DEISM (Developers)
macOS
In the terminal, run:
# Clone repository
git clone https://github.com/audiolabs/DEISM.git
cd DEISM
# Create virtual environment (recommended location)
python3 -m venv ~/.venv/deism_dev
source ~/.venv/deism_dev/bin/activate
# Install in editable mode
pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
Linux/WSL
In your shell, run:
# Clone repository
git clone https://github.com/audiolabs/DEISM.git
cd DEISM
# Create virtual environment (recommended location)
python3 -m venv ~/.venv/deism_dev
source ~/.venv/deism_dev/bin/activate
# Install in editable mode
pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
Windows
In PowerShell, run:
# Clone repository
git clone https://github.com/audiolabs/DEISM.git
cd DEISM
# Create virtual environment (recommended location)
python -m venv C:\Users\<YourUsername>\venvs\deism_dev
C:\Users\<YourUsername>\venvs\deism_dev\Scripts\Activate.ps1
# Install in editable mode
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
Installation Method 2: Conda Environment
Install DEISM (End Users)
All Platforms:
# Create conda environment
conda create -n deism python=3.9
conda activate deism
# Install DEISM
pip install --upgrade pip
pip install deism
Install DEISM (Developers)
All Platforms:
# Clone repository
git clone https://github.com/audiolabs/DEISM.git
cd DEISM
# Create conda environment from file
conda env create -f deism_env.yml
conda activate DEISM
# Install in editable mode
pip install -e .
Alternative: If deism_env.yml doesn't work, try the exact versions file:
conda env create -f deism_env_exact.yml
conda activate DEISM
pip install -e .
Build Tools Requirements
DEISM compiles C++ extensions during installation. You'll need a C++ compiler. Click on your operating system:
macOS
Install Xcode Command Line Tools:
xcode-select --install
Linux/WSL
Ubuntu/Debian:
sudo apt-get update
sudo apt-get install build-essential g++ python3-dev
RHEL/CentOS/Fedora:
sudo yum install gcc-c++ python3-devel
Windows
Option 1: Install MinGW-w64 and add to PATH
Option 2: Install Visual Studio Build Tools (select "C++ build tools" during installation)
Note: If the compiler is missing, DEISM will still install but the optional
count_reflectionsC++ library won't be compiled (Python fallback will be used).
Troubleshooting
PowerShell execution policy error (Windows):
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
"g++: command not found" (Linux/macOS):
- Linux:
sudo apt-get install build-essential - macOS:
xcode-select --install
"ModuleNotFoundError: No module named 'pybind11'":
pip install pybind11>=2.2
pip install deism # or pip install -e .
Conda environment issues:
- If you encounter errors with
deism_env.yml, trydeism_env_exact.ymlwhich contains exact package versions - Ensure conda is up to date:
conda update conda
Additional heads up
- You would need to an external LaTeX installation to render text properly when running the examples, since we enable
plt.rcParams["text.usetex"] = Truewhen plotting the simulated room transfer functions. Please refer to this page for more information Matplotlib usetex Documentation.
Running codes
Single set of parameters
The default parameters are defined in file configSingleParam.yml or configSingleParam_ARG.yml, depending on whether you want to run for shoebox rooms or more complicated room shapes. Take DEISM-ARG (configSingleParam_ARG.yml) as an example, there are two ways of running the codes:
- You can directly run deism_arg_singleparam_example.py in an IDE, which utilizes the parameters defined in configSingleParam_arg.yml.
- You can run deism_arg_singleparam_example.py from the command line after activating the conda environment. In addition, you can access help information quickly by
python deism_arg_singleparam_example.py --help. You can then change the parameters based on the instructions from the help message, e.g.,python deism_arg_singleparam_example.py -c 350 -zs 20will change the parameter sound speed and the wall impedance. The new input value of the parameters then overrides the ones in file configSingleParam_arg.yml. After choosing the needed values, you can run the codes using, e.g.,python deism_arg_singleparam_example.py -c 350 -zs 20 --run. - You need to specify additionally the following parameters in the function
init_parametersof deism_arg_singleparam_example.py:- The vertices of the room
- If rotate the room w.r.t the origin. This can be useful if you want to have some comparisons with the rooms created using pyroomacoustics.
- The rotation angles of the room if it needs to be rotated.
- You can suppress all output information in the command line by adding flag "--quiet" or by setting the first parameters in the configuration.yml file SilentMode to 1.
Examples
DEISM-ARG
- An example of running DEISM-ARG is examples/deism_arg_single_example.py
- You can run this from IDEs or via the command line, as introduced in the previous section
- An example of comparing different versions of DEISM-ARG is given in examples/deism_args_compare.py. A frequency- and wall-dependent impedance definition can also be applied for a convex room. The room transfer functions are compared among:
- Original version (most computation-costly)
- LC version (fastest)
- Mix version (Trade-offs between Original and LC versions): Early reflections up to some changeable order (default is 2) are calculated using the original version and the higher orders are calculated using the LC version.
- An example of comparing DEISM-ARG and pyroomacoustics is examples/deism_arg_pra_compare.py, Comparisons are done regarding if the following results are identical or mismatched only by a small deviation:
- number of images
- the positions of the images
DEISM for shoebox
We provide two examples for running the original DEISM for shoebox rooms
- An example of running DEISM-shoebox is examples/deism_singleparam_example.py
- You can either run this from IDEs or via the cmd
- An example of comparing different DEISM versions are shown in examples/deisms_lc_mix_test.py. In this script, the following methods are compared
- DEISM - original
- DEISM - MIX (original + LC vectorized)
- DEISM - LC vectorized
- FEM as groundtruth (only for this specific parameter settings)
Tips
The example code only provides essential functionalities based on DEISM. For more complex scenarios, please contact the authors (zeyu.xu@audiolabs-erlangen.de) for support. In the following, a few important tips might be helpful for you:
- If you want to simulate the scenario where both the source and receiver are positioned on the same speaker, you need to run DEISM for all reflection path except for the direct path.
- It is recommended to set the distance at least 1m between the transducers and the walls.
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:
- Frequencies at which the directivities are simulated or measured. A 1D array.
- 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).
- The sampled pressure field at the specified directions and frequencies. A 2D array with size (number of frequencies, number of directions).
- 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.
Description of the codes and functions
configSingleParam_ARG.yml
In this file you define the default parameters for DEISM-ARG to run. Note that this file is different from the configSingleParam.yml on these parameters:
- The dimensions are defined separately in the example script.
- You also need to specify if you want to rotate the room, and the rotation angles as well.
configSingleParam.yml
In this file you define the default parameters for DEISM-shoebox to run.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deism-2.2.1.7.tar.gz.
File metadata
- Download URL: deism-2.2.1.7.tar.gz
- Upload date:
- Size: 2.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bc17a941564c0ea0c251a7a987aca1860a1b5043e59d4080b29c620c5228ca3
|
|
| MD5 |
32d40283dd9de26aacb9985ae8ae36d1
|
|
| BLAKE2b-256 |
0e849b85de5af941f77d1da474ec72b05968d266d4628fe05f0ee13f4e7bc84f
|
File details
Details for the file deism-2.2.1.7-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: deism-2.2.1.7-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 3.6 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f5ac08c29296827871a833238409edd401a9b13c41d2b78e4cef976afa52ef7
|
|
| MD5 |
42a63f635e0c7520dcd98d6ffe56164b
|
|
| BLAKE2b-256 |
4f59e34add6fe0cff4012623d92809a7ef1e72ba6f47f99231513134c4088027
|
File details
Details for the file deism-2.2.1.7-cp311-cp311-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: deism-2.2.1.7-cp311-cp311-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 17.3 MB
- Tags: CPython 3.11, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26925b1f34f4bcf9bac535e2de95b824060d5bcef021d23c456527f7facc0206
|
|
| MD5 |
4c7df4803b0157096b5e0f4bd2b3c78e
|
|
| BLAKE2b-256 |
a9a29e40266aed3b54b44b3dda3be0d002852c3b8dfe2f5fd3baaa26f90af9a7
|
File details
Details for the file deism-2.2.1.7-cp311-cp311-macosx_15_0_universal2.whl.
File metadata
- Download URL: deism-2.2.1.7-cp311-cp311-macosx_15_0_universal2.whl
- Upload date:
- Size: 3.6 MB
- Tags: CPython 3.11, macOS 15.0+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f643a98ca418f1570237bc0efd5dd67f876cf5505be1bb9d671e24debe25780
|
|
| MD5 |
7c499a35e1db2e6fa3a4ba381f723669
|
|
| BLAKE2b-256 |
e5991944330943bb7b97220307af09f0bc263b5baf49e4bf71c0fcecaafacdf0
|
File details
Details for the file deism-2.2.1.7-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: deism-2.2.1.7-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 3.5 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8592ac5dc7bc87c76ff3430ea6c281b1d58ca7a80d5bb7159fd984b45c229c40
|
|
| MD5 |
9ffd3b3d85969b7a5809a3d46fe75e46
|
|
| BLAKE2b-256 |
6600bea58af59f3cbb6f89b6d64e62dabaac30dc518f0b952aa5458a17904286
|
File details
Details for the file deism-2.2.1.7-cp310-cp310-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: deism-2.2.1.7-cp310-cp310-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 17.3 MB
- Tags: CPython 3.10, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5160e468f0b1062425ce16c0d42ab66b55712109e918fe7f2d43dd0b3dc8d496
|
|
| MD5 |
96f333e1ffefd546ec97d2009f175bb6
|
|
| BLAKE2b-256 |
b96bb11b8a5bd18de3302af721864515fc9e354ca5bf2be33639655ec7c7de43
|
File details
Details for the file deism-2.2.1.7-cp310-cp310-macosx_15_0_universal2.whl.
File metadata
- Download URL: deism-2.2.1.7-cp310-cp310-macosx_15_0_universal2.whl
- Upload date:
- Size: 3.6 MB
- Tags: CPython 3.10, macOS 15.0+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90d5842142a361a55192fbc35b5c01112a2f09f2dac13d1e3b8a6687c0aa0e02
|
|
| MD5 |
a43deb966db3cf669e0ccf0e23c93c67
|
|
| BLAKE2b-256 |
e980d7f7f0a66ef977e8465e5ab04287b06fda20d6ce86a486356c8036e762e1
|
File details
Details for the file deism-2.2.1.7-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: deism-2.2.1.7-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 3.6 MB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
287012d451d587c621c20ff46b8d251dfa5bf1fe47a3e6a8cf1925716ece5765
|
|
| MD5 |
0eb2fd41c70408ca044d59d888b53c3d
|
|
| BLAKE2b-256 |
49e20acc9016baf8ee2c2551c2aa6dd6ba292b5a9da94469d47658be09820f99
|
File details
Details for the file deism-2.2.1.7-cp39-cp39-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: deism-2.2.1.7-cp39-cp39-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 17.3 MB
- Tags: CPython 3.9, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9441857faee74c11e32e49c582a88a8eef03d1424a85fc1e0efb12c60659b33
|
|
| MD5 |
0e73f2194810bc9915711289b2e6a639
|
|
| BLAKE2b-256 |
b27b706f174bf531cfecc410d301db4051e6d0d1e469c417a1079c5127edfc56
|