sparrowpy.sound_object#

SoundObject class for spatial audio reproduction.

Classes:

DirectivityMS(file_path[, source_index])

Directivity class for FreeFieldDirectivityTF convention.

Receiver(position, view, up)

Receiver object inhered from SoundObject.

SoundObject(position, view, up)

A class holding the common properties for Source and Receiver.

SoundSource(position, view, up[, ...])

Acoustic sound source inhered from SoundObject.

class sparrowpy.sound_object.DirectivityMS(file_path: str, source_index=0)[source]#

Bases: object

Directivity class for FreeFieldDirectivityTF convention.

Attributes:

Methods:

get_directivity(source_pos, source_view, ...)

Get Directivity for certain position.

data: FrequencyData#
get_directivity(source_pos: ndarray, source_view: ndarray, source_up: ndarray, target_position: ndarray, i_freq: int) float[source]#

Get Directivity for certain position.

Parameters:
  • source_pos (np.ndarray) – cartesian source position in m

  • source_view (np.ndarray) – cartesian source view in m

  • source_up (np.ndarray) – cartesian source up in m

  • target_position (np.ndarray) – cartesian target position in m

  • i_freq (int) – frequency bin index

Returns:

nearest directivity factor for given position and orientation.

Return type:

float

receivers: Coordinates#
class sparrowpy.sound_object.Receiver(position: ndarray, view: ndarray, up: ndarray)[source]#

Bases: SoundObject

Receiver object inhered from SoundObject.

Methods:

plot(ax, **kwargs)

Plot Receiver position and orientation.

plot(ax, **kwargs)[source]#

Plot Receiver position and orientation.

Parameters:
  • ax (matplotlib.axes.Axes) – Axes to plot on.

  • **kwargs – Keyword arguments that are passed to matplotlib.pyplot.scatter().

class sparrowpy.sound_object.SoundObject(position: ndarray, view: ndarray, up: ndarray)[source]#

Bases: object

A class holding the common properties for Source and Receiver.

Methods:

plot(ax, **kwargs)

Plot SoundObject position and orientation.

Attributes:

plot(ax: Axes, **kwargs)[source]#

Plot SoundObject position and orientation.

Parameters:
  • ax (matplotlib.axes.Axes) – Axes to plot on.

  • **kwargs – Keyword arguments that are passed to matplotlib.pyplot.scatter().

position: ndarray#
up: ndarray#
view: ndarray#
class sparrowpy.sound_object.SoundSource(position: ndarray, view: ndarray, up: ndarray, directivity: DirectivityMS = None, sound_power: float = 1)[source]#

Bases: SoundObject

Acoustic sound source inhered from SoundObject.

Attributes:

Methods:

get_directivity(target_position, frequency)

Get Directivity for certain position and frequency.

plot(ax, **kwargs)

Plot Source position and orientation.

directivity: DirectivityMS#
get_directivity(target_position: ndarray, frequency: float) float[source]#

Get Directivity for certain position and frequency.

Parameters:
  • target_position (np.ndarray) – cartesian target position in m of shape (3,) or (n, 3).

  • frequency (float) – frequency in Hz.

Returns:

nearest directivity factor for given position and frequency.

Return type:

float

plot(ax, **kwargs)[source]#

Plot Source position and orientation.

Parameters:
  • ax (matplotlib.axes.Axes) – Axes to plot on.

  • **kwargs – Keyword arguments that are passed to matplotlib.pyplot.scatter().

position: ndarray#
sound_power: float#
up: ndarray#
view: ndarray#