Skip to content

compas_acoustics.room

The room a simulation runs in: its geometry (geometry), air (air), diffuse-field prediction (diffuse), the scene as pyroomacoustics objects (pra), and the image source, ray tracing and directional histogram runs (raytracing).

Classes

AirConditions dataclass

AirConditions(temperature: float = 20.0, humidity: float = 50.0, pressure: float = 101325.0)

Air at a temperature (deg C), relative humidity (%) and static pressure (Pa).

Within Cramer's range, 0 to 30 deg C and 75 to 102 kPa.

Attributes

speed_of_sound property
speed_of_sound: float

Speed of sound in m/s, after Cramer (1993).

Methods:

air_attenuation
air_attenuation(frequencies) -> ndarray

Energy attenuation coefficient m per metre at frequencies in Hz (above 50 Hz), after ISO 9613-1.

The coefficient is ISO 9613-1's pure-tone one; the package takes it at each band's centre frequency and applies it to the whole band.

RoomGeometry dataclass

RoomGeometry(vertices: ndarray, faces: Tuple[Tuple[int, ...], ...], face_materials: Tuple[str, ...], face_names: Tuple[str, ...], face_roles: Tuple[str, ...], materials: Dict[str, SurfaceMaterial], is_closed: bool, open_edge: Optional[Tuple[Tuple[float, ...], Tuple[float, ...]]] = None, obstacle_faces: Tuple[Tuple[int, ...], ...] = (), obstacle_face_materials: Tuple[str, ...] = ())

Every surface of a scene as one room: welded, oriented, materials on SYNTHESIS_BANDS.

Faces are listed boundary first, then the front and then the back copy of every obstacle face. is_closed says whether the boundary faces close a volume; open_edge holds the end points of the first edge that prevents it.

Attributes

surface_area property
surface_area: float

Total area exposed to the air: the S of Sabine, Eyring and the mean free path 4 V / S.

surfaces property
surfaces: List[Tuple[float, SurfaceMaterial]]

(area, material) per material over the faces exposed to the air (see _exposed_faces).

volume cached property
volume: float

The air volume: the boundary's less the volume each closed obstacle encloses; a closed room only.

Methods:

area_normals
area_normals() -> ndarray

The unit normal of every exposed face times its area, (n_exposed, 3); the boundary faces come first.

faces_with_materials
faces_with_materials() -> List[Tuple[ndarray, str]]

Every face as (vertices (k, 3), material name), obstacle copies included.

from_mesh classmethod
from_mesh(vertices, faces, face_materials, materials, obstacles=(), merge_coplanar: bool = False) -> RoomGeometry

A room from shared vertices and faces, as from_scene; materials maps names to SurfaceMaterial, and the faces of the names in obstacles are obstacles.

from_scene classmethod
from_scene(scene, merge_coplanar: bool = True) -> RoomGeometry

Collect, weld, orient and validate every surface of scene.

Boundary faces that close a volume are wound outward; otherwise they are kept as drawn, with a UserWarning. Obstacle faces are stored twice, OBSTACLE_OFFSET either side and wound opposite, since a wall reflects off one side only. merge_coplanar joins coplanar faces of one object and material into larger walls (a triangulated CAD mesh); False keeps them and warns where it could. Vertices within 1 mm, a CAD model's usual absolute tolerance, are welded.

is_inside
is_inside(point) -> bool

Whether point is in the air: inside a closed boundary (anywhere in an open scene) and outside every closed obstacle, by generalised winding numbers over the drawn faces.

to_pra
to_pra(fs: int, max_order: int, ray_tracing: bool = False, air_absorption: bool = False, air: Optional[AirConditions] = None) -> Room

The pyroomacoustics room, one wall per face, materials resampled to its octave grid (nine bands at 48 kHz).

Bands above 8 kHz hold the 8 kHz value, where linear extrapolation could pass 1. A material without scattering scatters DEFAULT_SCATTERING. The room answers is_inside with is_inside. air (default AirConditions()) sets the speed of sound (Cramer 1993) and, with air_absorption, the ISO 9613-1 absorption, in place of pyroomacoustics' own 343 m/s and absorption table.