import matplotlib.pyplot as plt
import numpy as np
import sfs
grid = sfs.util.xyz_grid([-2, 2], [-2, 2], 0, spacing=0.02)
x0 = 0, 1.5, 0
f = 1000 # Hz
omega = 2 * np.pi * f # rad/s
p_point = sfs.fd.source.point(omega, x0, grid)
p_point *= 4 * np.pi
sfs.plot2d.amplitude(p_point, grid)
plt.title("Point Source at {} m".format(x0))
Text(0.5, 1.0, 'Point Source at (0, 1.5, 0) m')
x0 = 0, 1.5
f = 1000 # Hz
omega = 2 * np.pi * f # rad/s
p_line = sfs.fd.source.line(omega, x0, grid)
p_line *= np.sqrt(8 * np.pi * omega / sfs.default.c) * np.exp(1j * np.pi / 4)
sfs.plot2d.amplitude(p_line, grid)
plt.title("Line Source at {} m".format(x0[:2]))
Text(0.5, 1.0, 'Line Source at (0, 1.5) m')
Difference between point source and line source: When doubling the distance, the sound level of a ...
... point source is attenuated by 6 dB
... line source is attenuated by 3 dB
x0 = 0, 1.5, 0
n0 = 0, -1, 0
f = 1000 # Hz
omega = 2 * np.pi * f # rad/s
p_plane = sfs.fd.source.plane(omega, x0, n0, grid)
sfs.plot2d.amplitude(p_plane, grid)
plt.title("Plane wave with $n_0 =$ {}".format(n0))
Text(0.5, 1.0, 'Plane wave with $n_0 =$ (0, -1, 0)')
From this snapshot, it's not possible to recognize if the plane wave is travelling up or down. One would need an animation of some kind to see the direction of propagation (this was a trick question!).
The level doesn't decay over distance (another trick question!).
def plot_stereo(f, weights=[1, 1], ax=None):
"""Plot a monochromatic stereo sound field.
f: frequency in Hz
"""
if ax is None:
ax = plt.gca()
omega = 2 * np.pi * f # rad/s
r, phi = np.sqrt(3), 30
x0_1 = -r * np.sin(phi*np.pi/180), r * np.cos(phi*np.pi/180), 0
x0_2 = +r * np.sin(phi*np.pi/180), r * np.cos(phi*np.pi/180), 0
scaling_factor_point_source = 4 * np.pi
weight_l, weight_r = np.asarray(weights) * scaling_factor_point_source
grid = sfs.util.xyz_grid([-2, 2], [-2, 2], 0, spacing=0.02)
p_1 = weight_l * sfs.fd.source.point(omega, x0_1, grid)
p_2 = weight_r * sfs.fd.source.point(omega, x0_2, grid)
sfs.plot2d.amplitude(p_1 + p_2, grid, ax=ax)
plot_stereo(1000)
If the weighting factors are equal, the phantom source is halfway between the two loudspeakers.
intensity stereophony: $6\,\text{dB}$ level difference $\frac{A_1}{A_2} = 10^\left(\frac{6}{20}\right)$
fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(12, 5))
plot_stereo(1000, [10**(6 / 20), 1], ax=ax1)
ax1.set_title('intensity stereophony $6\,$dB')
plot_stereo(1000, [1, 1], ax=ax2)
ax2.set_title('intensity stereophony $0\,$dB')
Text(0.5, 1.0, 'intensity stereophony $0\\,$dB')
time-of-arrival stereophony: Change of the phase of a complex wave with $e^{\text{j}\phi}$.
Most visible effect at $\phi=\omega \frac{T}{2}=\pi$. But since it is a psychoacoustical effect you cannot see the direction of the phantom source in the sound field.
f = 1000 # Hz
omega = 2 * np.pi * f # rad/s
fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(12, 5))
plot_stereo(f, [1, np.exp(1j * omega * 1 / (2 * f))], ax=ax1)
ax1.set_title('time-of-arrival stereophony $\phi = \omega T/2 = \pi$')
plot_stereo(f, [1, 1], ax=ax2)
ax2.set_title('time-of-arrival stereophony $\phi = 0$')
Text(0.5, 1.0, 'time-of-arrival stereophony $\\phi = 0$')
Wave Field Systhesis: Reason for artifacts: spatial aliasing.
2.5 D: The combination of a 2D secondary source setup with secondary sources that exhibit 3D characteristics has led to naming such configurations 2.5D synthesis.
WFS vs. NFC-HOA artifacts: HOA has a circular area (shrinking with higher frequencies) in the center without aliasing, but around that area the artifacts are stronger than in WFS.