pyrato.parametric#

Module for room acoustics related functions.

Parametric room acoustics calculations using simple geometric considerations such as Sabine’s theory of sound in rooms.

Functions:

critical_distance(volume, reverberation_time)

Calculate the critical distance of a room with given volume and reverberation time.

energy_decay_curve(times, reverberation_time)

Calculate the energy decay curve for the reverberation time and energy.

mean_free_path(volume, surface_area)

Calculate the mean free path.

reverberation_time_eyring(volume, ...[, ...])

Calculate the reverberation time in rooms as defined by Carl Eyring.

reverberation_time_sabine(volume, ...[, ...])

Calculate the reverberation time in rooms as defined by Wallace Sabine.

pyrato.parametric.critical_distance(volume, reverberation_time)[source]#

Calculate the critical distance of a room with given volume and reverberation time. Assumes the source directivity is 1 (omnidirectional source). See [1].

\[d_c = 0.057 \sqrt{\frac{V}{T_{60}}}\]
Parameters:
  • volume (double) – Volume of the room in cubic meters.

  • reverberation_time (double) – Reverberation time of the room in seconds.

Returns:

critical_dist – The resulting critical distance in meters.

Return type:

double

References

pyrato.parametric.energy_decay_curve(times: ndarray, reverberation_time: float | ndarray, energy: float | ndarray = 1) TimeData[source]#

Calculate the energy decay curve for the reverberation time and energy.

The energy decay curve is calculated as

\[E(t) = E_0 e^{-\frac{6 \ln(10)}{T_{60}} t}\]

where \(E_0\) is the initial energy, \(T_{60}\) the reverberation time, and \(t\) the time [2].

Parameters:
  • times (numpy.ndarray[float]) – The times at which the energy decay curve is evaluated.

  • reverberation_time (float | numpy.ndarray[float]) – The reverberation time in seconds. If an array is passed, an energy decay curve is calculated for each reverberation time.

  • energy (float | numpy.ndarray[float], optional) – The initial energy of the sound field, by default 1. If reverberation_time is an array, the shape of energy is required to match the shape or be broadcastable to the shape of reverberation_time.

Returns:

energy_decay_curve – The energy decay curve with a cshape equal to the shape of the passed reverberation_time.

Return type:

pyfar.TimeData

Example

Calculate and plot an energy decay curve with a reverberation time of 2 seconds.

>>> import numpy as np
>>> import pyrato
>>> import pyfar as pf
>>>
>>> times = np.linspace(0, 3, 50)
>>> T_60 = [2, 1]
>>> edc = pyrato.parametric.energy_decay_curve(times, T_60)
>>> pf.plot.time(edc, log_prefix=10, dB=True)

(Source code, png, hires.png, pdf)

../_images/parametric-1.png

References

pyrato.parametric.mean_free_path(volume, surface_area)[source]#

Calculate the mean free path. Source https://ccrma.stanford.edu/~jos/smith-nam/Mean_Free_Path.html.

Parameters:
  • volume (double) – Room volume

  • surface_area (double) – Total surface area

Returns:

mean free path – The calculated mean free path

Return type:

double

pyrato.parametric.reverberation_time_eyring(volume: float, surface_area: float, mean_absorption: float | ndarray, speed_of_sound: float = 343.4) ndarray[source]#

Calculate the reverberation time in rooms as defined by Carl Eyring.

The reverberation time is calculated according to Ref. [3] as

\[T_{60} = -\frac{24 \cdot \ln(10)}{c} \cdot \frac{V}{S \ln(1 - \tilde{\alpha})}\]

where \(V\) is the room volume, \(S\) is the total surface area of the room, \(\tilde{\alpha}\) is the average absorption coefficient of the room surfaces, and \(c\) is the speed of sound.

Parameters:
  • volume (float) – Room volume in \(\mathrm{m}^3\)

  • surface_area (float) – Total surface area of the room in \(\mathrm{m}^2\)

  • mean_absorption (float, numpy.ndarray) – Average absorption coefficient of room surfaces between 0 and 1. If an array is passed, the reverberation time is calculated for each value in the array.

  • speed_of_sound (float) – Speed of sound in m/s. Default is 343.4 m/s, which corresponds to the speed of sound in air at 20 °C.

Returns:

Reverberation time in seconds. The shape matches the shape of the input variable mean_absorption.

Return type:

numpy.ndarray

Examples

>>> from pyrato.parametric import reverberation_time_eyring
>>> import numpy as np
>>> volume = 64
>>> surface_area = 96
>>> mean_absorption = [0.1, 0.3, 0.4]
>>> reverb_time = reverberation_time_eyring(
...     volume, surface_area, mean_absorption)
>>> np.round(reverb_time, 2)
... array([1.02, 0.3 , 0.21])

References

pyrato.parametric.reverberation_time_sabine(volume: float, surface_area: float, mean_absorption: float | ndarray, speed_of_sound: float = 343.4) ndarray[source]#

Calculate the reverberation time in rooms as defined by Wallace Sabine.

The reverberation time is calculated according to Ref. [4] as

\[T_{60} = \frac{24 \cdot \ln(10)}{c} \cdot \frac{V}{S\tilde{\alpha}}\]

where \(V\) is the room volume, \(S\) is the total surface area of the room, \(\tilde{\alpha}\) is the average absorption coefficient of the room surfaces, and \(c\) is the speed of sound.

Parameters:
  • surface_area (float) – Total surface area of the room in \(\mathrm{m}^2\).

  • mean_absorption (float, numpy.ndarray) – Average absorption coefficient of room surfaces between 0 and 1. If an array is passed, the reverberation time is calculated for each value in the array.

  • volume (float) – Room volume in \(\mathrm{m}^3\).

  • speed_of_sound (float) – Speed of sound in m/s. Default is 343.4 m/s, which corresponds to the speed of sound in air at 20 °C.

Returns:

Reverberation time in seconds.

Return type:

numpy.ndarray

References