DOA (Base)

class pyroomacoustics.doa.doa.DOA(L, fs, nfft, c=343.0, num_src=1, mode='far', r=None, azimuth=None, colatitude=None, n_grid=None, dim=2, *args, **kwargs)

Bases: object

Abstract parent class for Direction of Arrival (DoA) algorithms. After creating an object (SRP, MUSIC, CSSM, WAVES, or TOPS), run locate_source to apply the corresponding algorithm.

Parameters
  • L (numpy array) – Microphone array positions. Each column should correspond to the cartesian coordinates of a single microphone.

  • fs (float) – Sampling frequency.

  • nfft (int) – FFT length.

  • c (float) – Speed of sound. Default: 343 m/s

  • num_src (int) – Number of sources to detect. Default: 1

  • mode (str) – ‘far’ or ‘near’ for far-field or near-field detection respectively. Default: ‘far’

  • r (numpy array) – Candidate distances from the origin. Default: np.ones(1)

  • azimuth (numpy array) – Candidate azimuth angles (in radians) with respect to x-axis. Default: np.linspace(-180.,180.,30)*np.pi/180

  • colatitude (numpy array) – Candidate elevation angles (in radians) with respect to z-axis. Default is x-y plane search: np.pi/2*np.ones(1)

  • n_grid (int) – If azimuth and colatitude are not specified, we will create a grid with so many points. Default is 360.

  • dim (int) – The dimension of the problem. Set dim=2 to find sources on the circle (x-y plane). Set dim=3 to search on the whole sphere.

locate_sources(X, num_src=None, freq_range=[500.0, 4000.0], freq_bins=None, freq_hz=None)

Locate source(s) using corresponding algorithm.

Parameters
  • X (numpy array) – Set of signals in the frequency (RFFT) domain for current frame. Size should be M x F x S, where M should correspond to the number of microphones, F to nfft/2+1, and S to the number of snapshots (user-defined). It is recommended to have S >> M.

  • num_src (int) – Number of sources to detect. Default is value given to object constructor.

  • freq_range (list of floats, length 2) – Frequency range on which to run DoA: [fmin, fmax].

  • freq_bins (list of int) – freq_bins: List of individual frequency bins on which to run DoA. If defined by user, it will not take into consideration freq_range or freq_hz.

  • freq_hz (list of floats) – List of individual frequencies on which to run DoA. If defined by user, it will not take into consideration freq_range.

polar_plt_dirac(azimuth_ref=None, alpha_ref=None, save_fig=False, file_name=None, plt_dirty_img=True)

Generate polar plot of DoA results.

Parameters
  • azimuth_ref (numpy array) – True direction of sources (in radians).

  • alpha_ref (numpy array) – Estimated amplitude of sources.

  • save_fig (bool) – Whether or not to save figure as pdf.

  • file_name (str) – Name of file (if saved). Default is ‘polar_recon_dirac.pdf’

  • plt_dirty_img (bool) – Whether or not to plot spatial spectrum or ‘dirty image’ in the case of FRI.

class pyroomacoustics.doa.doa.ModeVector(L, fs, nfft, c, grid, mode='far', precompute=False)

Bases: object

This is a class for look-up tables of mode vectors. This look-up table is an outer product of three vectors running along candidate locations, time, and frequency. When the grid becomes large, the look-up table might be too large to store in memory. In that case, this class allows to only compute the outer product elements when needed, only keeping the three vectors in memory. When the table is small, a precompute option can be set to True to compute the whole table in advance.