pyroomacoustics.parameters module

This file defines the main physical constants of the system:
  • Speed of sound

  • Absorption of materials

  • Scattering coefficients

  • Air absorption

class pyroomacoustics.parameters.Constants

Bases: object

A class to provide easy access package wide to user settable constants.

get(name)
set(name, val)
class pyroomacoustics.parameters.Material(energy_absorption, scattering=None)

Bases: object

A class that describes the energy absorption and scattering properties of walls.

energy_absorption

A dictionary containing keys description, coeffs, and center_freqs.

Type

dict

scattering

A dictionary containing keys description, coeffs, and center_freqs.

Type

dict

Parameters
  • energy_absorption (float, str, or dict) –

    • float: The material created will be equally absorbing at all frequencies

      (i.e. flat).

    • str: The absorption values will be obtained from the database.

    • dict: A dictionary containing keys description, coeffs, and

      center_freqs.

  • scattering (float, str, or dict) –

    • float: The material created will be equally scattering at all frequencies

      (i.e. flat).

    • str: The scattering values will be obtained from the database.

    • dict: A dictionary containing keys description, coeffs, and

      center_freqs.

property absorption_coeffs

shorthand to the energy absorption coefficients

classmethod all_flat(materials)

Checks if all materials in a list are frequency flat

Parameters

materials (list or dict of Material objects) – The list of materials to check

Return type

True if all materials have a single parameter, else False

is_freq_flat()

Returns True if the material has flat characteristics over frequency, False otherwise.

resample(octave_bands)

resample at given octave bands

property scattering_coeffs

shorthand to the scattering coefficients

class pyroomacoustics.parameters.Physics(temperature=None, humidity=None)

Bases: object

A Physics object allows to compute the room physical properties depending on temperature and humidity.

Parameters
  • temperature (float, optional) – The room temperature

  • humidity (float in range (0, 100), optional) – The room relative humidity in %. Default is 0.

classmethod from_speed(c)

Choose a temperature and humidity matching a desired speed of sound

get_air_absorption()
Returns

  • (air_absorption, center_freqs) where air_absorption is a list

  • corresponding to the center frequencies in center_freqs

get_sound_speed()
Return type

the speed of sound

pyroomacoustics.parameters.calculate_speed_of_sound(t, h, p)

Compute the speed of sound as a function of temperature, humidity and pressure

Parameters
  • t (float) – temperature [Celsius]

  • h (float) – relative humidity [%]

  • p (float) – atmospheric pressure [kpa]

Return type

Speed of sound in [m/s]

pyroomacoustics.parameters.make_materials(*args, **kwargs)

Helper method to conveniently create multiple materials.

Each positional and keyword argument should be a valid input for the Material class. Then, for each of the argument, a Material will be created by calling the constructor.

If at least one positional argument is provided, a list of Material objects constructed using the provided positional arguments is returned.

If at least one keyword argument is provided, a dict with keys corresponding to the keywords and containing Material objects constructed with the keyword values is returned.

If only positional arguments are provided, only the list is returned. If only keyword arguments are provided, only the dict is returned. If both are provided, both are returned. If no argument is provided, an empty list is returned.

 1# energy absorption parameters
 2floor_eabs = {
 3    "description": "Example floor material",
 4    "coeffs": [0.1, 0.2, 0.1, 0.1, 0.1, 0.05],
 5    "center_freqs": [125, 250, 500, 1000, 2000, 4000],
 6}
 7
 8# scattering parameters
 9audience_scat = {
10    "description": "Theatre Audience",
11    "coeffs": [0.3, 0.5, 0.6, 0.6, 0.7, 0.7, 0.7]
12    "center_freqs": [125, 250, 500, 1000, 2000, 4000],
13}
14
15# create a list of materials
16my_mat_list = pra.make_materials((floor_eabs, audience_scat))
17
18# create a dict of materials
19my_mat_dict = pra.make_materials(floor=(floor_abs, audience_scat))