.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_cuboid_room_auralization.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_cuboid_room_auralization.py: Creating an Auralization ======================== Simulate the energy decay in a cuboid room using the Finite Volume diffusion equation. .. GENERATED FROM PYTHON SOURCE LINES 9-18 .. code-block:: Python 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 .. GENERATED FROM PYTHON SOURCE LINES 19-22 ############################################################################## Import anechoic file ############################################################################## .. GENERATED FROM PYTHON SOURCE LINES 22-29 .. code-block:: Python 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" ) .. rst-class:: sphx-glr-script-out .. code-block:: none 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. .. GENERATED FROM PYTHON SOURCE LINES 30-33 ############################################################################## Import FVM or FDM results ############################################################################## .. GENERATED FROM PYTHON SOURCE LINES 33-41 .. code-block:: Python 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" ) .. rst-class:: sphx-glr-script-out .. code-block:: none 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. .. GENERATED FROM PYTHON SOURCE LINES 42-45 ############################################################################## Run script ############################################################################## .. GENERATED FROM PYTHON SOURCE LINES 45-47 .. code-block:: Python results = run_auralization(anechoic_file_path,results_fvm_path) .. rst-class:: sphx-glr-script-out .. code-block:: none Starting convolution... Removing unpickleable object: f Simulation finished successfully! Results in resultsAuralization.pkl file .. GENERATED FROM PYTHON SOURCE LINES 48-51 ############################################################################## Plotting convolved signal ############################################################################## .. GENERATED FROM PYTHON SOURCE LINES 51-59 .. code-block:: Python 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() .. image-sg:: /auto_examples/images/sphx_glr_plot_cuboid_room_auralization_001.png :alt: plot cuboid room auralization :srcset: /auto_examples/images/sphx_glr_plot_cuboid_room_auralization_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 60-63 .. code-block:: Python Audio( results['sh_conv_normalized']/np.max(np.abs(results['sh_conv_normalized'])), rate=results['fs']) .. raw:: html


.. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 13.368 seconds) .. _sphx_glr_download_auto_examples_plot_cuboid_room_auralization.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_cuboid_room_auralization.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_cuboid_room_auralization.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_cuboid_room_auralization.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_