Note
Go to the end to download the full example code.
Creating an Auralization
Simulate the energy decay in a cuboid room using the Finite Volume diffusion equation.
import tempfile
import matplotlib.pyplot as plt
from IPython.display import Audio
import numpy as np
import pooch
from acousticDE.Auralization.Auralization import run_auralization
tmp_dir = tempfile.TemporaryDirectory()
script_dir = tmp_dir.name
Import anechoic file
anechoic_file_path = pooch.retrieve(
url="https://github.com/Building-acoustics-TU-Eindhoven/acousticDE/raw/refs/heads/master/examples/anechoic_file.wav",
known_hash=None,
path=script_dir,
fname="anechoic_file.wav"
)
Downloading data from 'https://github.com/Building-acoustics-TU-Eindhoven/acousticDE/raw/refs/heads/master/examples/anechoic_file.wav' to file '/tmp/tmpbc6nuhkp/anechoic_file.wav'.
SHA256 hash of downloaded file: 56734d159175745fcfb31b717dae58a65c794ae62e670537ae993b61f898a03f
Use this value as the 'known_hash' argument of 'pooch.retrieve' to ensure that the file hasn't changed if it is downloaded again in the future.
Import FVM or FDM results
results_fvm_path = pooch.retrieve(
url="https://github.com/Building-acoustics-TU-Eindhoven/acousticDE/raw/eba9989df48768f8c2574b4fd50c5d4d75bf0213/examples/resultsFVM.pkl",
known_hash=None,
path=script_dir,
fname="resultsFVM.pkl"
)
Downloading data from 'https://github.com/Building-acoustics-TU-Eindhoven/acousticDE/raw/eba9989df48768f8c2574b4fd50c5d4d75bf0213/examples/resultsFVM.pkl' to file '/tmp/tmpbc6nuhkp/resultsFVM.pkl'.
SHA256 hash of downloaded file: 752af0b2e6e2c78a46d021458ec557976f1807e19636bf7508e4977bf5ba1670
Use this value as the 'known_hash' argument of 'pooch.retrieve' to ensure that the file hasn't changed if it is downloaded again in the future.
Run script
results = run_auralization(anechoic_file_path,results_fvm_path)
Starting convolution...
Removing unpickleable object: f
Simulation finished successfully! Results in resultsAuralization.pkl file
Plotting convolved signal
plt.figure()
plt.plot(
results['t_conv'],
results['sh_conv_normalized']/np.max(np.abs(results['sh_conv_normalized'])))
plt.grid(True)
plt.ylabel('Normalized sound pressure (-)')
plt.xlabel('Time (s)')
plt.show()

Audio(
results['sh_conv_normalized']/np.max(np.abs(results['sh_conv_normalized'])),
rate=results['fs'])
Total running time of the script: (0 minutes 13.368 seconds)