Modules

Generators

Module containing various generator functions:

whiteNoise

Adds White Gaussian Noise of approx. 16dB crest to a FFT block.

gauss_grid

Compute Gauss-Legendre quadrature nodes and weights in the SOFiA / VariSphear data format.

lebedev

Compute Lebedev quadrature nodes and weights given a maximum stable order. Alternatively, a degree may be supplied.

radial_filter

Generate modal radial filter of specified orders and frequencies.

radial_filter_fullspec

Generate NFFT/2 + 1 modal radial filter of orders 0:max_order for frequencies 0:fs/2, wraps radial_filter().

spherical_head_filter

Generate coloration compensation filter of specified maximum SH order.

spherical_head_filter_spec

Generate NFFT/2 + 1 coloration compensation filter of specified maximum SH order for frequencies 0:fs/2, wraps spherical_head_filter().

tapering_window

Design tapering window with cosine slope for orders greater than 3.

sampled_wave

Returns the frequency domain data of an ideal wave as recorded by a provided array.

ideal_wave

Ideal wave generator, returns spatial Fourier coefficients Pnm of an ideal wave front hitting a specified array.

spherical_noise

Returns order-limited random weights on a spherical surface.

delay_fd

Generate delay in frequency domain that resembles a circular shift in time domain.

I/O

Module containing various input and output functions:

TimeSignal

Named tuple to store time domain data and related metadata.

SphericalGrid

Named tuple to store spherical sampling grid geometry.

ArrayConfiguration

Named tuple to store microphone array characteristics.

ArraySignal

Named tuple to store microphone array data in terms of TimeSignal, SphericalGrid and ArrayConfiguration

HrirSignal

Named tuple to store Head Related Impulse Response grid data in terms of TimeSignal for either ear and SphericalGrid

read_miro_struct

Read Head Related Impulse Responses (HRIRs) or Array / Directional Impulse Responses (DRIRs) stored as MIRO Matlab files and convert them to ArraySignal.

read_SOFA_file

Read Head Related Impulse Responses (HRIRs) or Array / Directional Impulse Responses (DRIRs) stored as Spatially Oriented Format for Acoustics (SOFA) files and convert them to ArraySignal or HrirSignal.

empty_time_signal

Returns an empty np rec array that has the proper data structure.

load_array_signal

Convenience function to load ArraySignal saved into np data structures.

read_wavefile

Reads in WAV files and returns data [Nsig x Nsamples] and fs.

write_SSR_IRs

Takes two time signals and writes out the horizontal plane as HRIRs for the SoundScapeRenderer. Ideally, both hold 360 IRs but smaller sets are tried to be scaled up using repeat.

Lebedev

Module to generate Lebedev grids and quadrature weights for degrees 6, 14, 26, 38, 50, 74, 86, 110, 146, 170, 194:

genGrid(n)

Generate Lebedev grid geometry of degree n.

Adapted from Richard P. Mullers Python version, https://github.com/gabrielelanaro/pyquante/blob/master/Data/lebedev_write.py C version: Dmitri Laikov F77 version: Christoph van Wuellen, http://www.ccl.net

Users of this code are asked to include reference 3 in their publications, and in the user- and programmers-manuals describing their codes.

References

3

V.I. Lebedev, and D.N. Laikov ‘A quadrature formula for the sphere of the 131st algebraic order of accuracy’ Doklady Mathematics, Vol. 59, No. 3, 1999, pp. 477-481.

Plotting

Module containing various plotting functions:

makeMTX

Returns a plane wave decomposition over a full sphere.

makeFullMTX

Generates visualization matrix for a set of spatial fourier coefficients over all kr.

plot2D

Visualize 2D data using plotly.

plot3D

Visualize matrix data, such as from makeMTX(Pnm, dn).

plot3Dgrid

Visualize matrix data in a grid, such as from makeMTX(Pnm, dn).

Processing

Module containing functions to act on the Spatial Fourier Coefficients.

BEMA

Perform Bandwidth Extension for Microphone Arrays (BEMA) spatial anti-aliasing.

FFT

Perform real-valued Fast Fourier Transform (FFT).

iFFT

Perform inverse real-valued (Fast) Fourier Transform (iFFT).

spatFT

Perform spatial Fourier transform.

spatFT_RT

Perform spatial Fourier transform for real-time applications (otherwise use spatFT() for more more convenience and flexibility).

spatFT_LSF

Perform spatial Fourier transform by least square fit to provided data.

iSpatFT

Perform inverse spatial Fourier transform.

plane_wave_decomp

Perform plane wave decomposition.

rfi

Perform radial filter improvement (RFI)

sfe

Perform sound field extrapolation (SFE) - WORK IN PROGRESS.

wdr

Perform Wigner-D rotation (WDR) - NOT YET IMPLEMENTED.

convolve

Convolve two arrays A & B row-wise where one or both can be one-dimensional for SIMO/SISO convolution.

Spherical

Module containing various spherical harmonics helper functions:

besselj / neumann

Bessel function of first and second kind of order n at kr.

hankel1 / hankel2

Hankel function of first and second kind of order n at kr.

spbessel / spneumann

Spherical Bessel function of first and second kind of order n at kr.

sphankel1 / sphankel2

Spherical Hankel of first and second kind of order n at kr.

dspbessel / dspneumann

Derivative of spherical Bessel of first and second kind of order n at kr.

dsphankel1 / dsphankel2

Derivative spherical Hankel of first and second kind of order n at kr.

spherical_extrapolation

Factor that relate signals recorded on a sphere to it’s center.

array_extrapolation

Factor that relate signals recorded on a sphere to it’s center. In the rigid configuration, a scatter_radius that is different to the array radius may be set.

sph_harm

Compute spherical harmonics.

sph_harm_large

Compute spherical harmonics for large orders > 84.

sph_harm_all

Compute all spherical harmonic coefficients up to degree nMax.

mnArrays

Generate degrees n and orders m up to nMax.

reverseMnIds

Generate reverse indexes according to stacked coefficients of orders m up to nMax.

cart2sph / sph2cart

Convert cartesian to spherical coordinates and vice versa.

kr

Generate kr vector for given f and array radius.

kr_full_spec

Generate full spectrum kr.

Utilities

Module containing various utility functions:

env_info

Guess environment based on sys.modules.

progress_bar

Display a spinner or a progress bar.

db

Convenience function to calculate the 20*log10(abs(x)).

cart2sph / sph2cart

Transform cartesian into spherical coordinates and vice versa.

SOFA_grid2acr

Transform coordinate grid with specified coordinate system definition from a SOFA file into spherical coordinates in radians.

nearest_to_value / nearest_to_value_IDX / nearest_to_value_logical_IDX

Returns nearest value inside an array.

interleave_channels

Interleave left and right channels. Style == ‘SSR’ checks if we total 360 channels.

simple_resample

Wrap scipy.signal.resample with a simpler API.

scalar_broadcast_match

Returns arguments as np.array, if one is a scalar it will broadcast the other one’s shape.

frq2kr

Returns the kr bin closest to the target frequency.

stack

Stacks two 2D vectors along the same-sized dimension or the smaller one.

zero_pad_fd

Apply zero padding to frequency domain data by transformation into time domain and back.

current_time

Return current system time based on datetime.now().

time_it

Measure execution of a specified statement which is useful for the performance analysis. In this way, the execution time and respective results can be directly compared.