Time Domain¶
Time Domain Sources¶
Compute the sound field generated by a sound source.
The Green’s function describes the spatial sound propagation over time.
-
sfs.time.source.
point
(xs, signal, observation_time, grid, c=None)[source]¶ Source model for a point source: 3D Green’s function.
Calculates the scalar sound pressure field for a given point in time, evoked by source excitation signal.
Parameters: - xs ((3,) array_like) – Position of source in cartesian coordinates.
- signal ((N,) array_like + float) – Excitation signal consisting of (mono) audio data and a sampling
rate (in Hertz). A
DelayedSignal
object can also be used. - observation_time (float) – Observed point in time.
- grid (triple of array_like) – The grid that is used for the sound field calculations.
See
sfs.util.xyz_grid()
. - c (float, optional) – Speed of sound.
Returns: numpy.ndarray – Scalar sound pressure field, evaluated at positions given by grid.
Notes
\[g(x-x_s,t) = \frac{1}{4 \pi |x - x_s|} \dirac{t - \frac{|x - x_s|}{c}}\]
-
sfs.time.source.
point_image_sources
(x0, signal, observation_time, grid, L, max_order, coeffs=None, c=None)[source]¶ Point source in a rectangular room using the mirror image source model.
Parameters: - x0 ((3,) array_like) – Position of source in cartesian coordinates.
- signal ((N,) array_like + float) – Excitation signal consisting of (mono) audio data and a sampling
rate (in Hertz). A
DelayedSignal
object can also be used. - observation_time (float) – Observed point in time.
- grid (triple of array_like) – The grid that is used for the sound field calculations.
See
sfs.util.xyz_grid()
. - L ((3,) array_like) – Dimensions of the rectangular room.
- max_order (int) – Maximum number of reflections for each image source.
- coeffs ((6,) array_like, optional) – Reflection coeffecients of the walls. If not given, the reflection coefficients are set to one.
- c (float, optional) – Speed of sound.
Returns: numpy.ndarray – Scalar sound pressure field, evaluated at positions given by grid.
Time Domain Driving Functions¶
Compute time based driving functions for various systems.
-
sfs.time.drivingfunction.
wfs_25d_plane
(x0, n0, n=[0, 1, 0], xref=[0, 0, 0], c=None)[source]¶ Plane wave model by 2.5-dimensional WFS.
Parameters: - x0 ((N, 3) array_like) – Sequence of secondary source positions.
- n0 ((N, 3) array_like) – Sequence of secondary source orientations.
- n ((3,) array_like, optional) – Normal vector (propagation direction) of synthesized plane wave.
- xref ((3,) array_like, optional) – Reference position
- c (float, optional) – Speed of sound
Returns: - delays ((N,) numpy.ndarray) – Delays of secondary sources in seconds.
- weights ((N,) numpy.ndarray) – Weights of secondary sources.
Notes
2.5D correction factor
\[g_0 = \sqrt{2 \pi |x_\mathrm{ref} - x_0|}\]d using a plane wave as source model
\[d_{2.5D}(x_0,t) = h(t) 2 g_0 \scalarprod{n}{n_0} \dirac{t - \frac{1}{c} \scalarprod{n}{x_0}}\]with wfs(2.5D) prefilter h(t), which is not implemented yet.
References
-
sfs.time.drivingfunction.
wfs_25d_point
(x0, n0, xs, xref=[0, 0, 0], c=None)[source]¶ Point source by 2.5-dimensional WFS.
Parameters: - x0 ((N, 3) array_like) – Sequence of secondary source positions.
- n0 ((N, 3) array_like) – Sequence of secondary source orientations.
- xs ((3,) array_like) – Virtual source position.
- xref ((3,) array_like, optional) – Reference position
- c (float, optional) – Speed of sound
Returns: - delays ((N,) numpy.ndarray) – Delays of secondary sources in seconds.
- weights ((N,) numpy.ndarray) – Weights of secondary sources.
Notes
2.5D correction factor
\[g_0 = \sqrt{2 \pi |x_\mathrm{ref} - x_0|}\]d using a point source as source model
\[d_{2.5D}(x_0,t) = h(t) \frac{g_0 \scalarprod{(x_0 - x_s)}{n_0}} {2\pi |x_0 - x_s|^{3/2}} \dirac{t - \frac{|x_0 - x_s|}{c}}\]with wfs(2.5D) prefilter h(t), which is not implemented yet.
References
-
sfs.time.drivingfunction.
wfs_25d_focused
(x0, n0, xs, xref=[0, 0, 0], c=None)[source]¶ Point source by 2.5-dimensional WFS.
Parameters: - x0 ((N, 3) array_like) – Sequence of secondary source positions.
- n0 ((N, 3) array_like) – Sequence of secondary source orientations.
- xs ((3,) array_like) – Virtual source position.
- xref ((3,) array_like, optional) – Reference position
- c (float, optional) – Speed of sound
Returns: - delays ((N,) numpy.ndarray) – Delays of secondary sources in seconds.
- weights ((N,) numpy.ndarray) – Weights of secondary sources.
Notes
2.5D correction factor
\[g_0 = \sqrt{\frac{|x_\mathrm{ref} - x_0|} {|x_0-x_s| + |x_\mathrm{ref}-x_0|}}\]d using a point source as source model
\[d_{2.5D}(x_0,t) = h(t) \frac{g_0 \scalarprod{(x_0 - x_s)}{n_0}} {|x_0 - x_s|^{3/2}} \dirac{t + \frac{|x_0 - x_s|}{c}}\]with wfs(2.5D) prefilter h(t), which is not implemented yet.
References
-
sfs.time.drivingfunction.
driving_signals
(delays, weights, signal)[source]¶ Get driving signals per secondary source.
Returned signals are the delayed and weighted mono input signal (with N samples) per channel (C).
Parameters: - delays ((C,) array_like) – Delay in seconds for each channel, negative values allowed.
- weights ((C,) array_like) – Amplitude weighting factor for each channel.
- signal ((N,) array_like + float) – Excitation signal consisting of (mono) audio data and a sampling
rate (in Hertz). A
DelayedSignal
object can also be used.
Returns: DelayedSignal
– A tuple containing the driving signals (in anumpy.ndarray
with shape(N, C)
), followed by the sampling rate (in Hertz) and a (possibly negative) time offset (in seconds).
-
sfs.time.drivingfunction.
apply_delays
(signal, delays)[source]¶ Apply delays for every channel.
Parameters: - signal ((N,) array_like + float) – Excitation signal consisting of (mono) audio data and a sampling
rate (in Hertz). A
DelayedSignal
object can also be used. - delays ((C,) array_like) – Delay in seconds for each channel (C), negative values allowed.
Returns: DelayedSignal
– A tuple containing the delayed signals (in anumpy.ndarray
with shape(N, C)
), followed by the sampling rate (in Hertz) and a (possibly negative) time offset (in seconds).- signal ((N,) array_like + float) – Excitation signal consisting of (mono) audio data and a sampling
rate (in Hertz). A
Time Domain Sound Fields¶
Compute sound field.
-
sfs.time.soundfield.
p_array
(x0, signals, weights, observation_time, grid, source=<function point>, c=None)[source]¶ Compute sound field for an array of secondary sources.
Parameters: - x0 ((N, 3) array_like) – Sequence of secondary source positions.
- signals ((N, C) array_like + float) – Driving signals consisting of audio data (C channels) and a
sampling rate (in Hertz).
A
DelayedSignal
object can also be used. - weights ((C,) array_like) – Additional weights applied during integration, e.g. source tapering.
- observation_time (float) – Simulation point in time (seconds).
- grid (triple of array_like) – The grid that is used for the sound field calculations.
See
sfs.util.xyz_grid()
. - source (function, optional) – Source type is a function, returning scalar field.
For default, see
sfs.time.source.point()
. - c (float, optional) – Speed of sound.
Returns: numpy.ndarray – Sound pressure at grid positions.