Sound Field Analysis Toolbox for NumPy/Python¶
The Sound Field Analysis Toolbox for NumPy/Python provides implementations of various techniques for the analysis of sound fields and beamforming using microphone arrays.
- Source code and issue tracker:
- https://github.com/spatialaudio/sfa-numpy
- License:
- MIT – see the file
LICENSE
for details. - Quick start:
- Install NumPy, SciPy and for the examples Matplotlib
git clone https://github.com/spatialaudio/sfa-numpy.git
cd sfa-numpy
python setup.py install --user
Usage¶
Requirements¶
Obviously, you’ll need Python. We normally use Python 3.x, but it should also work with Python 2.x. NumPy and SciPy are needed for the calculations. If you also want to plot the resulting sound fields, you’ll need matplotlib.
Instead of installing all of them separately, you should probably get a Python distribution that already includes everything, e.g. Anaconda.
How to Get Started¶
Various examples are located in the directory
Modal Beamforming¶
Submodules for modal beamforming
Angular¶
-
micarray.modal.angular.
Legendre_matrix
(N, ctheta)[source]¶ (N+1) x M matrix of weighted Legendre Polynominals 2*n+1/4*pi * P_n(ctheta)
Radial¶
-
micarray.modal.radial.
spherical_pw
(N, k, r, setup)[source]¶ Radial coefficients for a plane wave
Computes the radial component of the spherical harmonics expansion of a plane wave impinging on a spherical array.
\[\mathring{P}_n(k) = 4 \pi i^n b_n(kr)\]Parameters: - N (int) – Maximum order.
- k (array_like) – Wavenumber.
- r (float) – Radius of microphone array.
- setup ({‘open’, ‘card’, ‘rigid’}) – Array configuration (open, cardioids, rigid).
Returns: numpy.ndarray – Radial weights for all orders up to N and the given wavenumbers.
-
micarray.modal.radial.
spherical_ps
(N, k, r, rs, setup)[source]¶ Radial coefficients for a point source
Computes the radial component of the spherical harmonics expansion of a point source impinging on a spherical array.
\[\mathring{P}_n(k) = 4 \pi (-i) k h_n^{(2)}(k r_s) b_n(kr)\]Parameters: - N (int) – Maximum order.
- k (array_like) – Wavenumber.
- r (float) – Radius of microphone array.
- rs (float) – Distance of source.
- setup ({‘open’, ‘card’, ‘rigid’}) – Array configuration (open, cardioids, rigid).
Returns: numpy.ndarray – Radial weights for all orders up to N and the given wavenumbers.
-
micarray.modal.radial.
weights
(N, kr, setup)[source]¶ Radial weighing functions
Computes the radial weighting functions for diferent array types (cf. eq.(2.62), Rafaely 2015).
For instance for an rigid array
\[b_n(kr) = j_n(kr) - \frac{j_n^\prime(kr)}{h_n^{(2)\prime}(kr)}h_n^{(2)}(kr)\]Parameters: - N (int) – Maximum order.
- kr (array_like) – Wavenumber * radius.
- setup ({‘open’, ‘card’, ‘rigid’}) – Array configuration (open, cardioids, rigid).
Returns: numpy.ndarray – Radial weights for all orders up to N and the given wavenumbers.
Utilities¶
-
micarray.util.
asarray_1d
(a, **kwargs)[source]¶ Squeeze the input and check if the result is one-dimensional.
Returns a converted to a
numpy.ndarray
and stripped of all singleton dimensions. Scalars are “upgraded” to 1D arrays. The result must have exactly one dimension. If not, an error is raised.