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
- Convex room shapes
Preparation and installing
Build locally
- In you encounter errors like "unrecognized arguments: deism_envs_exact.yml", please type the following commands manuelly in the command line.
- Clone or download the repository to your local directory
- Use the command
conda env create -f deism_env.yml
to create a Conda environment for the DEISM algorithms. If this does not work, tryconda env create -f deism_env_exact.yml
as the file deism_envs_exact.yml records the versions of all packages. - Activate the created environment by "conda activate DEISM"
- Running
pip install -e .
will build the deism package including the c++ extensions locally. You can also modify the sources codes and check out the effects. In case you receiver errors like "ModuleNotFoundError: No module named 'pybind11" even after activated the conda environment, you can usepython -m pip install -e .
to try install again. - Run scripts in the test folder.
Using pip to install remotely
- To be added later
Running codes
Single set of parameters
The default parameters are defined in file configSingleParam_ARG.yml. 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 20
will 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_parameters
of 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
- An example of running DEISM-ARG is test/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 test/deism_args_compare.py. 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 test/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
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.
Contributors
- M. Sc. Zeyu Xu
- Songjiang Tan
- M. Sc. Hasan Nazım Biçer
- Dr. Albert Prinn
- Prof. Dr. ir. Emanuël Habets
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 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.
Parameters
# here is the configuration file for single set of parameters
# Note:
# Use space instead of tab for indentation at the beginning of each line
# Environment parameters
Environment:
soundSpeed: 343 # speed of sound
airDensity: 1.2 # constant of air
# Boundary conditions and max. reflection order
Reflections:
# format of reflection coefficient: [Z_x0,Z_x1,Z_y0,Z_y1,Z_z0,Z_z1]
acoustImpendence: 18
# input:
# 1. AcoustImpendence: 18+0j # A single value for 6 walls, no frequency-dependency
maxReflectionOrder: 5 # maximal reflection order
reverberationTime: 1 # in seconds
# Simulation parameters #
# positions of sound source and receiver in 3-dimensional Cartesian coordinate
# unit(meter)
# Note:
# The source and receiver should be at least 1m away from the walls;
# The distance between the source and receiver should be not less than the sum of the radii of transparent spheres
Positions:
source:
x: 1.1
y: 1.1
z: 1.3
receiver:
x: 2.9
y: 1.9
z: 1.3
# frequency terms
Frequencies:
# unit of frequency(Hz)
startFrequency: 20
endFrequency: 1000
frequencyStep: 2
samplingRate: 2000
# Directivity parameters #
# maximal spherical harmonic directivity order
MaxSphDirectivityOrder:
nSourceOrder: 5
vReceiverOrder: 5
# Facing/Rotation of the directivities
# Three angles are need to describe the Z-X-Z convention of rotation;
# The rotation matrix calculation used in COMSOL, see:
# https://doc.comsol.com/5.5/doc/com.comsol.help.comsol/comsol_ref_definitions.12.092.html
Orientations:
source:
alpha: 0
beta: 0
gamma: 0
receiver:
alpha: 180
beta: 0
gamma: 0
# parameters of the transparent sphere around the source and receiver
# The values should be consistent with the loaded directivity files
# For different max. sph. orders at different frequency ranges, this should allow adjustments
Radius:
source: 0.4
receiver: 0.5
# Directivity data
# !!! Add more directivity data here !!!
Directivities:
# Choices for source:
# Analytic: "monopole"
# Simulated or measured: "speaker_cuboid_cyldriver_1"
source: "speaker_cuboid_cyldriver_1"
# Choices for source:
# Analytic: "monopole"
# Simulated or measured: "speaker_cuboid_cyldriver_1"
receiver: "speaker_cuboid_cyldriver_1"
# Other functional parameters
# DEISM modes: You can run DEISM using different versions
# 1. ORG: Original DEISM, which is supposed to be the most accurate, but takes the longest time
# 2. LC: Low-complexity DEISM with vectorized calculation, which is supposed to be faster than ORG, but less accurate
# 3. MIX: Early reflections up to order 2 are calculated using ORG, and the rest are calculated using LC
DEISM_specs:
ifRemoveDirect: 0 # If remove the direct sound from the image sources
Mode: "ORG" # DEISM-ARG now only supports "ORG" !!!
# mixEarlyOrder: 2 # The order of reflections using DEISM-ORG if choose "MIX"
numParaImages: 50000 # Number of images parallel for the calculation, information for users about RAM consumption
# If normalize the receiver directivity if the receiver directivity is obtained by placing a point source
# with flow strength QFlowStrength at the receiver position and measuring the sound pressure at a sphere around the receiver
# You need to specify QFlowStrength after the following flag
ifRecerverNormalize: 1
QFlowStrength: 0.001
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
Hashes for deism-2.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9fc7117cc548032b07e76524b09d35fdb9bd0dcdbf6b4cce656ad8550495fe2a |
|
MD5 | 4b49b4a1e0cf94dfca60ce26e54174e3 |
|
BLAKE2b-256 | 27234d97a6f7dbc6454ee029259834b7a8a3dc350a3e7bf2808098ddff5ad3de |
Hashes for deism-2.0-cp311-cp311-macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fe793ade6ba5324f47354765ffc9b164929903e20c13561600a4ec45c644a32 |
|
MD5 | acc704c87ebffe1038df9247fa6a24ee |
|
BLAKE2b-256 | a66b29ae56104e1047a38ac4a726de6fd6adebbdad578e19513dafa06789650b |
Hashes for deism-2.0-cp311-cp311-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20a18caa980766597debb3c3d0f80d5b2f24e54dd97905a0890de854aeea37ba |
|
MD5 | 09e91773ffa56cabdf547295f654a78f |
|
BLAKE2b-256 | f1551cbeadbb828b81c83b5948b8a95fd343b9fb95dce9f82f7cf869a00bc14f |
Hashes for deism-2.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02c1022fc62f602530ee95ee0bb6b14924ab779bab1d188530e450fd880f866b |
|
MD5 | 8bd0cbd4a98e477823d7c4cbc906559e |
|
BLAKE2b-256 | a22c4fdd4f5c48c5a5b18e59555cbe8cabdc53af8997713352f028d4f2a8093a |
Hashes for deism-2.0-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 173c6dee5bd634da815852a122cb4648da4e9b3e35da0a24050840bc9846d143 |
|
MD5 | dc9126d493e30a6744eb5bd9f8d844ff |
|
BLAKE2b-256 | c7df171dd33e8b0c1a70e2f5ff3c19eed26e61dcbe7e187315089d33adc20c47 |
Hashes for deism-2.0-cp310-cp310-macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 856446df48de3e63e5f5a8afae150a3f84d7c997eaec66c0f83c5b3310daed31 |
|
MD5 | 8a6b689689ddc2aa0ab98d52c94a6a76 |
|
BLAKE2b-256 | 7408d82435b95ea3c39d0200df48f41dab8001e96487b9287e41ca23d506f8be |
Hashes for deism-2.0-cp310-cp310-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6b6b1fda62198276eff8f99e7c0e80c43214d807373d2648f3c6aff12b54135 |
|
MD5 | 190544041e378f8fa9878322de5ccd7c |
|
BLAKE2b-256 | b6f892df4fedb750704122457a5152897dbbe3073f605d2fdcb741fdc307d71f |
Hashes for deism-2.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14ad4cbb6359cfa9af6b17756e2cdb5bdc92f402adacb15aee47d6bc7e7b1404 |
|
MD5 | 3c6f3ae4ce9816fc8ff5157522af175f |
|
BLAKE2b-256 | f21f64b8cb74b8e5d82161396856dcce211800b70aeda1094d3723c4aa179c74 |
Hashes for deism-2.0-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20febc2cf97a43e4e0acb0fd71c0806f662ff11d65f184f9557537b95bc69a44 |
|
MD5 | 346e5cb7c0ce5a62e5aa7083dcbb731a |
|
BLAKE2b-256 | fe9e9b222ef6fc5ddd2cec94827205f269abdd97fca29f4c87664153eb660394 |