Tools for FRIDA (azimuth only)

pyroomacoustics.doa.tools_fri_doa_plane.Rmtx_ri(coef_ri, K, D, L)

Split T matrix in rea/imaginary representation

pyroomacoustics.doa.tools_fri_doa_plane.Rmtx_ri_half(coef_half, K, D, L, D_coef)

Split T matrix in rea/imaginary conjugate symmetric representation

pyroomacoustics.doa.tools_fri_doa_plane.Rmtx_ri_half_out_half(coef_half, K, D, L, D_coef, mtx_shrink)

if both b and annihilation filter coefficients are Hermitian symmetric, then the output will also be Hermitian symmetric => the effectively output is half the size

pyroomacoustics.doa.tools_fri_doa_plane.Tmtx_ri(b_ri, K, D, L)

build convolution matrix associated with b_ri

Parameters
  • b_ri – a real-valued vector

  • K – number of Diracs

  • D1 – expansion matrix for the real-part

  • D2 – expansion matrix for the imaginary-part

pyroomacoustics.doa.tools_fri_doa_plane.Tmtx_ri_half(b_ri, K, D, L, D_coef)

Split T matrix in conjugate symmetric representation

pyroomacoustics.doa.tools_fri_doa_plane.Tmtx_ri_half_out_half(b_ri, K, D, L, D_coef, mtx_shrink)

if both b and annihilation filter coefficients are Hermitian symmetric, then the output will also be Hermitian symmetric => the effectively output is half the size

pyroomacoustics.doa.tools_fri_doa_plane.build_mtx_amp(phi_k, p_mic_x, p_mic_y)

the matrix that maps Diracs’ amplitudes to the visibility

Parameters
  • phi_k – Diracs’ location (azimuth)

  • p_mic_x – a vector that contains microphones’ x-coordinates

  • p_mic_y – a vector that contains microphones’ y-coordinates

pyroomacoustics.doa.tools_fri_doa_plane.build_mtx_amp_ri(p_mic_x, p_mic_y, phi_k)

builds real/imaginary amplitude matrix

pyroomacoustics.doa.tools_fri_doa_plane.build_mtx_raw_amp(p_mic_x, p_mic_y, phi_k)

the matrix that maps Diracs’ amplitudes to the visibility

Parameters
  • phi_k – Diracs’ location (azimuth)

  • p_mic_x – a vector that contains microphones’ x-coordinates

  • p_mic_y – a vector that contains microphones’ y-coordinates

pyroomacoustics.doa.tools_fri_doa_plane.coef_expan_mtx(K)

expansion matrix for an annihilating filter of size K + 1

Parameters

K – number of Dirac. The filter size is K + 1

pyroomacoustics.doa.tools_fri_doa_plane.compute_b(G_lst, GtG_lst, beta_lst, Rc0, num_bands, a_ri, use_lu=False, GtG_inv_lst=None)

compute the uniform sinusoidal samples b from the updated annihilating filter coeffiients.

Parameters
  • GtG_lst – list of G^H G for different subbands

  • beta_lst – list of beta-s for different subbands

  • Rc0 – right-dual matrix, here it is the convolution matrix associated with c

  • num_bands – number of bands

  • a_ri – a 2D numpy array. each column corresponds to the measurements within a subband

pyroomacoustics.doa.tools_fri_doa_plane.compute_mtx_obj(GtG_lst, Tbeta_lst, Rc0, num_bands, K)
compute the matrix (M) in the objective function:

min c^H M c s.t. c0^H c = 1

Parameters
  • GtG_lst – list of G^H * G

  • Tbeta_lst – list of Teoplitz matrices for beta-s

  • Rc0 – right dual matrix for the annihilating filter (same of each block -> not a list)

pyroomacoustics.doa.tools_fri_doa_plane.compute_obj_val(GtG_inv_lst, Tbeta_lst, Rc0, c_ri_half, num_bands, K)

compute the fitting error. CAUTION: Here we assume use_lu = True

pyroomacoustics.doa.tools_fri_doa_plane.cov_mtx_est(y_mic)

estimate covariance matrix

Parameters

y_mic – received signal (complex based band representation) at microphones

pyroomacoustics.doa.tools_fri_doa_plane.cpx_mtx2real(mtx)

extend complex valued matrix to an extended matrix of real values only

Parameters

mtx – input complex valued matrix

pyroomacoustics.doa.tools_fri_doa_plane.dirac_recon_ri(G, a_ri, K, M, noise_level, max_ini=100, stop_cri='mse')

Reconstruct point sources’ locations (azimuth) from the visibility measurements

Parameters
  • G – the linear transformation matrix that links the visibilities to uniformly sampled sinusoids

  • a_ri – the visibility measurements

  • K – number of Diracs

  • M – the Fourier series expansion is between -M and M

  • noise_level – level of noise (ell_2 norm) in the measurements

  • max_ini – maximum number of initialisations

  • stop_cri – stopping criterion, either ‘mse’ or ‘max_iter’

pyroomacoustics.doa.tools_fri_doa_plane.dirac_recon_ri_half(G, a_ri, K, M, noise_level, max_ini=100, stop_cri='mse')

Reconstruct point sources’ locations (azimuth) from the visibility measurements. Here we enforce hermitian symmetry in the annihilating filter coefficients so that roots on the unit circle are encouraged.

Parameters
  • G (param) – the linear transformation matrix that links the visibilities to uniformly sampled sinusoids

  • a_ri – the visibility measurements

  • K – number of Diracs

  • M – the Fourier series expansion is between -M and M

  • noise_level – level of noise (ell_2 norm) in the measurements

  • max_ini – maximum number of initialisations

  • stop_cri – stopping criterion, either ‘mse’ or ‘max_iter’

pyroomacoustics.doa.tools_fri_doa_plane.dirac_recon_ri_half_multiband(G_lst, a_ri, K, M, max_ini=100)

Reconstruct point sources’ locations (azimuth) from the visibility measurements. Here we enforce hermitian symmetry in the annihilating filter coefficients so that roots on the unit circle are encouraged.

Parameters
  • G_lst – a list of the linear transformation matrices that links the visibilities to uniformly sampled sinusoids

  • a_ri – the visibility measurements

  • K – number of Diracs

  • M – the Fourier series expansion is between -M and M

  • noise_level – level of noise (ell_2 norm) in the measurements

  • max_ini – maximum number of initialisations

  • stop_cri – stopping criterion, either ‘mse’ or ‘max_iter’

pyroomacoustics.doa.tools_fri_doa_plane.dirac_recon_ri_half_multiband_lu(G_lst, GtG_lst, GtG_inv_lst, a_ri, K, M, max_ini=100, max_iter=50)

Here we use LU decomposition to precompute a few entries. Reconstruct point sources’ locations (azimuth) from the visibility measurements. Here we enforce hermitian symmetry in the annihilating filter coefficients so that roots on the unit circle are encouraged.

Parameters
  • G_lst – a list of the linear transformation matrices that links the visibilities to uniformly sampled sinusoids

  • a_ri – the visibility measurements

  • K – number of Diracs

  • M – the Fourier series expansion is between -M and M

  • noise_level – level of noise (ell_2 norm) in the measurements

  • max_ini – maximum number of initialisations

  • stop_cri – stopping criterion, either ‘mse’ or ‘max_iter’

pyroomacoustics.doa.tools_fri_doa_plane.dirac_recon_ri_half_multiband_parallel(G, a_ri, K, M, max_ini=100)

Reconstruct point sources’ locations (azimuth) from the visibility measurements. Here we enforce hermitian symmetry in the annihilating filter coefficients so that roots on the unit circle are encouraged. We use parallel implementation when stop_cri == ‘max_iter’

Parameters
  • G – the linear transformation matrix that links the visibilities to uniformly sampled sinusoids

  • a_ri – the visibility measurements

  • K – number of Diracs

  • M – the Fourier series expansion is between -M and M

  • noise_level – level of noise (ell_2 norm) in the measurements

  • max_ini – maximum number of initialisations

  • stop_cri – stopping criterion, either ‘mse’ or ‘max_iter’

pyroomacoustics.doa.tools_fri_doa_plane.dirac_recon_ri_half_parallel(G, a_ri, K, M, max_ini=100)

Reconstruct point sources’ locations (azimuth) from the visibility measurements. Here we enforce hermitian symmetry in the annihilating filter coefficients so that roots on the unit circle are encouraged. We use parallel implementation when stop_cri == ‘max_iter’

Parameters
  • G – the linear transformation matrix that links the visibilities to uniformly sampled sinusoids

  • a_ri – the visibility measurements

  • K – number of Diracs

  • M – the Fourier series expansion is between -M and M

  • noise_level – level of noise (ell_2 norm) in the measurements

  • max_ini – maximum number of initialisations

  • stop_cri – stopping criterion, either ‘mse’ or ‘max_iter’

pyroomacoustics.doa.tools_fri_doa_plane.dirac_recon_ri_inner(c_ri_half, a_ri, rhs, rhs_bl, K, M, D1, D2, D_coef, mtx_shrink, Tbeta_ri, G, max_iter)

inner loop of the dirac_recon_ri_half_parallel function

pyroomacoustics.doa.tools_fri_doa_plane.dirac_recon_ri_multiband_inner(c_ri_half, a_ri, num_bands, rhs, rhs_bl, K, M, D1, D2, D_coef, mtx_shrink, Tbeta_ri, G, GtG, max_iter)

Inner loop of the dirac_recon_ri_multiband function

pyroomacoustics.doa.tools_fri_doa_plane.extract_off_diag(mtx)

extract off diagonal entries in mtx. The output vector is order in a column major manner.

Parameters

mtx – input matrix to extract the off diagonal entries

pyroomacoustics.doa.tools_fri_doa_plane.hermitian_expan(half_vec_len)

expand a real-valued vector to a Hermitian symmetric vector. The input vector is a concatenation of the real parts with NON-POSITIVE indices and the imaginary parts with STRICTLY-NEGATIVE indices.

Parameters

half_vec_len – length of the first half vector

pyroomacoustics.doa.tools_fri_doa_plane.lu_compute_mtx_obj(Tbeta_lst, num_bands, K, lu_R_GtGinv_Rt_lst)
compute the matrix (M) in the objective function:

min c^H M c s.t. c0^H c = 1

Parameters
  • GtG_lst – list of G^H * G

  • Tbeta_lst – list of Teoplitz matrices for beta-s

  • Rc0 – right dual matrix for the annihilating filter (same of each block -> not a list)

pyroomacoustics.doa.tools_fri_doa_plane.lu_compute_mtx_obj_initial(GtG_inv_lst, Tbeta_lst, Rc0, num_bands, K)
compute the matrix (M) in the objective function:

min c^H M c s.t. c0^H c = 1

Parameters
  • GtG_lst – list of G^H * G

  • Tbeta_lst – list of Teoplitz matrices for beta-s

  • Rc0 – right dual matrix for the annihilating filter (same of each block -> not a list)

pyroomacoustics.doa.tools_fri_doa_plane.make_G(p_mic_x, p_mic_y, omega_bands, sound_speed, M, signal_type='visibility')

reconstruct point sources on the circle from the visibility measurements from multi-bands.

Parameters
  • p_mic_x – a vector that contains microphones’ x-coordinates

  • p_mic_y – a vector that contains microphones’ y-coordinates

  • omega_bands – mid-band (ANGULAR) frequencies [radian/sec]

  • sound_speed – speed of sound

  • signal_type – The type of the signal a, possible values are ‘visibility’ for covariance matrix and ‘raw’ for microphone inputs

Return type

The list of mapping matrices from measurements to sinusoids

pyroomacoustics.doa.tools_fri_doa_plane.make_GtG_and_inv(G_lst)
pyroomacoustics.doa.tools_fri_doa_plane.mtx_freq2raw(M, p_mic_x, p_mic_y)

build the matrix that maps the Fourier series to the raw microphone signals

Parameters
  • M – the Fourier series expansion is limited from -M to M

  • p_mic_x – a vector that contains microphones x coordinates

  • p_mic_y – a vector that contains microphones y coordinates

pyroomacoustics.doa.tools_fri_doa_plane.mtx_freq2visi(M, p_mic_x, p_mic_y)

build the matrix that maps the Fourier series to the visibility

Parameters
  • M – the Fourier series expansion is limited from -M to M

  • p_mic_x – a vector that constains microphones x coordinates

  • p_mic_y – a vector that constains microphones y coordinates

pyroomacoustics.doa.tools_fri_doa_plane.mtx_fri2signal_ri(M, p_mic_x, p_mic_y, D1, D2, signal='visibility')

build the matrix that maps the Fourier series to the visibility in terms of REAL-VALUED entries only. (matrix size double)

Parameters
  • M – the Fourier series expansion is limited from -M to M

  • p_mic_x – a vector that contains microphones x coordinates

  • p_mic_y – a vector that contains microphones y coordinates

  • D1 – expansion matrix for the real-part

  • D2 – expansion matrix for the imaginary-part

  • signal – The type of signal considered (‘visibility’ for covariance matrix, ‘raw’ for microphone inputs)

pyroomacoustics.doa.tools_fri_doa_plane.mtx_fri2signal_ri_multiband(M, p_mic_x_all, p_mic_y_all, D1, D2, aslist=False, signal='visibility')

build the matrix that maps the Fourier series to the visibility in terms of REAL-VALUED entries only. (matrix size double)

Parameters
  • M – the Fourier series expansion is limited from -M to M

  • p_mic_x_all – a matrix that contains microphones x coordinates

  • p_mic_y_all – a matrix that contains microphones y coordinates

  • D1 – expansion matrix for the real-part

  • D2 – expansion matrix for the imaginary-part aslist: whether the linear mapping for each subband is returned as a list or a block diagonal matrix

  • signal – The type of signal considered (‘visibility’ for covariance matrix, ‘raw’ for microphone inputs)

pyroomacoustics.doa.tools_fri_doa_plane.mtx_updated_G(phi_recon, M, mtx_amp2visi_ri, mtx_fri2visi_ri)

Update the linear transformation matrix that links the FRI sequence to the visibilities by using the reconstructed Dirac locations. :param phi_recon: the reconstructed Dirac locations (azimuths) :param M: the Fourier series expansion is between -M to M :param p_mic_x: a vector that contains microphones’ x-coordinates :param p_mic_y: a vector that contains microphones’ y-coordinates :param mtx_freq2visi: the linear mapping from Fourier series to visibilities

pyroomacoustics.doa.tools_fri_doa_plane.mtx_updated_G_multiband(phi_recon, M, mtx_amp2visi_ri, mtx_fri2visi_ri, num_bands)

Update the linear transformation matrix that links the FRI sequence to the visibilities by using the reconstructed Dirac locations.

Parameters
  • phi_recon – the reconstructed Dirac locations (azimuths)

  • M – the Fourier series expansion is between -M to M

  • p_mic_x – a vector that contains microphones’ x-coordinates

  • p_mic_y – a vector that contains microphones’ y-coordinates

  • mtx_fri2visi – the linear mapping from Fourier series to visibilities

pyroomacoustics.doa.tools_fri_doa_plane.mtx_updated_G_multiband_new(phi_opt, M, p_x, p_y, G0_lst, num_bands)

Update the linear transformation matrix that links the FRI sequence to the visibilities by using the reconstructed Dirac locations.

Parameters
  • phi_opt – the reconstructed Dirac locations (azimuths)

  • M – the Fourier series expansion is between -M to M

  • p_mic_x – a vector that contains microphones’ x-coordinates

  • p_mic_y – a vector that contains microphones’ y-coordinates

  • G0_lst – the original linear mapping from Fourier series to visibilities

  • num_bands – number of subbands

pyroomacoustics.doa.tools_fri_doa_plane.multiband_cov_mtx_est(y_mic)

estimate covariance matrix based on the received signals at microphones

Parameters

y_mic – received signal (complex base-band representation) at microphones

pyroomacoustics.doa.tools_fri_doa_plane.multiband_extract_off_diag(mtx)

extract off-diagonal entries in mtx The output vector is order in a column major manner

Parameters

mtx (input matrix to extract the off-diagonal entries) –

pyroomacoustics.doa.tools_fri_doa_plane.output_shrink(K, L)

shrink the convolution output to half the size. used when both the annihilating filter and the uniform samples of sinusoids satisfy Hermitian symmetric.

Parameters
  • K – the annihilating filter size: K + 1

  • L – length of the (complex-valued) b vector

pyroomacoustics.doa.tools_fri_doa_plane.polar2cart(rho, phi)

convert from polar to cartesian coordinates

Parameters
  • rho – radius

  • phi – azimuth

pyroomacoustics.doa.tools_fri_doa_plane.pt_src_recon(a, p_mic_x, p_mic_y, omega_band, sound_speed, K, M, noise_level, max_ini=50, stop_cri='mse', update_G=False, verbose=False, signal_type='visibility', **kwargs)

reconstruct point sources on the circle from the visibility measurements

Parameters
  • a – the measured visibilities

  • p_mic_x – a vector that contains microphones’ x-coordinates

  • p_mic_y – a vector that contains microphones’ y-coordinates

  • omega_band – mid-band (ANGULAR) frequency [radian/sec]

  • sound_speed – speed of sound

  • K – number of point sources

  • M – the Fourier series expansion is between -M to M

  • noise_level – noise level in the measured visibilities

  • max_ini – maximum number of random initialisation used

  • stop_cri – either ‘mse’ or ‘max_iter’

  • update_G – update the linear mapping that links the uniformly sampled sinusoids to the visibility or not.

  • verbose – whether output intermediate results for debugging or not

  • signal_type – The type of the signal a, possible values are ‘visibility’ for covariance matrix and ‘raw’ for microphone inputs

  • kwargs (possible optional input: G_iter: number of iterations for the G updates) –

pyroomacoustics.doa.tools_fri_doa_plane.pt_src_recon_multiband(a, p_mic_x, p_mic_y, omega_bands, sound_speed, K, M, noise_level, max_ini=50, update_G=False, verbose=False, signal_type='visibility', max_iter=50, G_lst=None, GtG_lst=None, GtG_inv_lst=None, **kwargs)

reconstruct point sources on the circle from the visibility measurements from multi-bands.

Parameters
  • a – the measured visibilities in a matrix form, where the second dimension corresponds to different subbands

  • p_mic_x – a vector that contains microphones’ x-coordinates

  • p_mic_y – a vector that contains microphones’ y-coordinates

  • omega_bands – mid-band (ANGULAR) frequencies [radian/sec]

  • sound_speed – speed of sound

  • K – number of point sources

  • M – the Fourier series expansion is between -M to M

  • noise_level – noise level in the measured visibilities

  • max_ini – maximum number of random initialisation used

  • update_G – update the linear mapping that links the uniformly sampled sinusoids to the visibility or not.

  • verbose – whether output intermediate results for debugging or not

  • signal_type – The type of the signal a, possible values are ‘visibility’ for covariance matrix and ‘raw’ for microphone inputs

  • kwargs – possible optional input: G_iter: number of iterations for the G updates

pyroomacoustics.doa.tools_fri_doa_plane.pt_src_recon_rotate(a, p_mic_x, p_mic_y, K, M, noise_level, max_ini=50, stop_cri='mse', update_G=False, num_rotation=1, verbose=False, signal_type='visibility', **kwargs)

reconstruct point sources on the circle from the visibility measurements. Here we apply random rotations to the coordiantes.

Parameters
  • a – the measured visibilities

  • p_mic_x – a vector that contains microphones’ x-coordinates

  • p_mic_y – a vector that contains microphones’ y-coordinates

  • K – number of point sources

  • M – the Fourier series expansion is between -M to M

  • noise_level – noise level in the measured visibilities

  • max_ini – maximum number of random initialisation used

  • stop_cri – either ‘mse’ or ‘max_iter’

  • update_G – update the linear mapping that links the uniformly sampled sinusoids to the visibility or not.

  • num_rotation – number of random rotations

  • verbose – whether output intermediate results for debugging or not

  • signal_type – The type of the signal a, possible values are ‘visibility’ for covariance matrix and ‘raw’ for microphone inputs

  • kwargs – possible optional input: G_iter: number of iterations for the G updates