pyroomacoustics.directivities module¶
- class pyroomacoustics.directivities.CardioidFamily(orientation, pattern_enum, gain=1.0)¶
Bases:
Directivity
Object for directivities coming from the cardioid family.
- Parameters:
orientation (DirectionVector) – Indicates direction of the pattern.
pattern_enum (DirectivityPattern) – Desired pattern for the cardioid.
- property directivity_pattern¶
Name of cardioid directivity pattern.
- get_response(azimuth, colatitude=None, magnitude=False, frequency=None, degrees=True)¶
Get response for provided angles.
- Parameters:
azimuth (array_like) – Azimuth in degrees
colatitude (array_like, optional) – Colatitude in degrees. Default is to be on XY plane.
magnitude (bool, optional) – Whether to return magnitude of response.
frequency (float, optional) – For which frequency to compute the response. Cardioid are frequency-independent so this value has no effect.
degrees (bool, optional) – Whether provided angles are in degrees.
- Returns:
resp – Response at provided angles.
- Return type:
ndarray
- plot_response(**kwargs)¶
- class pyroomacoustics.directivities.DirectionVector(azimuth, colatitude=None, degrees=True)¶
Bases:
object
Object for representing direction vectors in 3D, parameterized by an azimuth and colatitude angle.
- Parameters:
azimuth (float)
colatitude (float, optional) – Default to PI / 2, only XY plane.
degrees (bool) – Whether provided values are in degrees (True) or radians (False).
- get_azimuth(degrees=False)¶
- get_colatitude(degrees=False)¶
- property unit_vector¶
Direction vector in cartesian coordinates.
- class pyroomacoustics.directivities.Directivity(orientation)¶
Bases:
ABC
Abstract class for directivity patterns.
- get_azimuth(degrees=True)¶
- get_colatitude(degrees=True)¶
- abstract get_response(azimuth, colatitude=None, magnitude=False, frequency=None, degrees=True)¶
Get response for provided angles and frequency.
- set_orientation(orientation)¶
Set orientation of directivity pattern.
- Parameters:
orientation (DirectionVector) – New direction for the directivity pattern.
- class pyroomacoustics.directivities.DirectivityPattern(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
Enum
Common cardioid patterns and their corresponding coefficient for the expression:
\[r = a (1 + \cos \theta),\]where \(a\) is the coefficient that determines the cardioid pattern and \(r\) yields the gain at angle \(\theta\).
- CARDIOID = 0.5¶
- FIGURE_EIGHT = 0¶
- HYPERCARDIOID = 0.25¶
- OMNI = 1.0¶
- SUBCARDIOID = 0.75¶
- pyroomacoustics.directivities.cardioid_func(x, direction, coef, gain=1.0, normalize=True, magnitude=False)¶
One-shot function for computing cardioid response.
- Parameters:
x (array_like, shape (..., n_dim)) – Cartesian coordinates
direction (array_like, shape (n_dim)) – Direction vector, should be normalized.
coef (float) – Parameter for the cardioid function.
gain (float) – The gain.
normalize (bool) – Whether to normalize coordinates and direction vector.
magnitude (bool) – Whether to return magnitude, default is False.
- Returns:
resp – Response at provided angles for the speficied cardioid function.
- Return type:
ndarray
- pyroomacoustics.directivities.source_angle_shoebox(image_source_loc, wall_flips, mic_loc)¶
Determine outgoing angle for each image source for a ShoeBox configuration.
Implementation of the method described in the paper: https://www2.ak.tu-berlin.de/~akgroup/ak_pub/2018/000458.pdf
- Parameters:
image_source_loc (array_like) – Locations of image sources.
wall_flips (array_like) – Number of x, y, z flips for each image source.
mic_loc (array_like) – Microphone location.
- Returns:
azimuth (
ndarray
) – Azimith for each image source, in radianscolatitude (
ndarray
) – Colatitude for each image source, in radians.