58 *phA2sh = (
void*)pData;
117 if (pData->
hSTFT != NULL)
126 free(pData->L_diff_fal);
129 free(pData->W_diffEQ_tmp);
156 pData->
fs = sampleRate;
188 const float *
const * inputs,
189 float*
const*
const outputs,
197 int ch, i, band, Q, order, nSH;
198 const float_complex calpha = cmplxf(1.0f,0.0f), cbeta = cmplxf(0.0f, 0.0f);
216 gain_lin = powf(10.0f, pData->
gain_dB/20.0f);
218 order = pData->
order;
219 nSH = (order+1)*(order+1);
226 for(i=0; i < nInputs; i++)
236 cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, nSH,
TIME_SLOTS, Q, &calpha,
262 for(i = 0; i <
SAF_MIN(nSH,nOutputs); i++)
264 for(; i < nOutputs; i++)
268 for (ch=0; ch < nOutputs; ch++)
403 if(arraySpecs->
Q != newQ){
404 arraySpecs->
newQ = newQ;
416 if(arraySpecs->
r!=newr){
417 arraySpecs->
r = newr;
429 if(arraySpecs->
R!=newR){
430 arraySpecs->
R = newR;
475 if(pData->
regPar!=newVal){
596 return arraySpecs->
newQ;
620 return arraySpecs->
r;
627 return arraySpecs->
R;
665 return (
int)pData->
norm;
690 (*nCurves) = pData->
order+1;
698 (*nCurves) = pData->
order+1;
706 (*nCurves) = pData->
order+1;
714 (*nCurves) = pData->
order+1;
#define MAX_SH_ORDER
Maximum supported Ambisonic order.
#define PROGRESSBARTEXT_CHAR_LENGTH
Length of progress bar string.
@ PROC_STATUS_ONGOING
Codec is processing input audio, and should not be reinitialised at this time.
@ PROC_STATUS_NOT_ONGOING
Codec is not processing input audio, and may be reinitialised if needed.
NORM_TYPES
Available Ambisonic normalisation conventions.
@ NORM_SN3D
Schmidt semi-normalisation (SN3D)
@ NORM_FUMA
(Legacy) Furse-Malham scaling
@ NORM_N3D
orthonormalised (N3D)
CH_ORDER
Available Ambisonic channel ordering conventions.
@ CH_ACN
Ambisonic Channel Numbering (ACN)
@ CH_FUMA
(Legacy) Furse-Malham/B-format (WXYZ)
#define MAX_NUM_SH_SIGNALS
Maximum number of spherical harmonic components/signals supported.
@ SH_ORDER_FIRST
First-order (4 channels)
void afSTFT_backward_knownDimensions(void *const hSTFT, float_complex ***dataFD, int framesize, int dataFD_nCH, int dataFD_nHops, float **dataTD)
Performs backward afSTFT transform (dataFD dimensions are known)
void afSTFT_forward_knownDimensions(void *const hSTFT, float **dataTD, int framesize, int dataFD_nCH, int dataFD_nHops, float_complex ***dataFD)
Performs forward afSTFT transform (dataFD dimensions are known)
void afSTFT_getCentreFreqs(void *const hSTFT, float fs, int nBands, float *freqVector)
Returns current frequency vector.
void afSTFT_destroy(void **const phSTFT)
Destroys an instance of afSTFT.
#define TIME_SLOTS
Number of STFT timeslots.
#define HOP_SIZE
STFT hop size.
#define HYBRID_BANDS
Number of frequency bands.
void array2sh_process(void *const hA2sh, const float *const *inputs, float *const *const outputs, int nInputs, int nOutputs, int nSamples)
Spatially encode microphone/hydrophone array signals into spherical harmonic signals.
float array2sh_getR(void *const hA2sh)
Returns the radius of the scatterer, in meters.
void array2sh_setNormType(void *const hA2sh, int newType)
Sets the Ambisonic normalisation convention to encode with, in order to match with the convention emp...
float * array2sh_getSpatialCorrelation_Handle(void *const hA2sh, int *nCurves, int *nFreqPoints)
Returns a pointer to the spatial correlation [1] data.
float array2sh_getSensorElev_deg(void *const hA2sh, int index)
Returns a particular sensor's elevation w.r.t to the origin of the array, in DEGREES.
float array2sh_getr(void *const hA2sh)
Returns the radius of the array, in meters.
void array2sh_setNumSensors(void *const hA2sh, int newQ)
Sets the number of sensors in the array.
float ** array2sh_getbN_inv(void *const hA2sh, int *nCurves, int *nFreqPoints)
Returns the regularised inversion of the modal coefficients per frequency (may be used for optional p...
void array2sh_setSensorElev_rad(void *const hA2sh, int index, float newElev_rad)
Sets a particular sensor's elevation (radians) w.r.t to the origin of the array.
void array2sh_setR(void *const hA2sh, float newR)
Sets the radius (in meters) of the scatterer (only for Rigid arrays).
void array2sh_setGain(void *const hA2sh, float newGain)
Sets the amount of post gain to apply after the encoding, in DECIBELS.
float array2sh_getSensorAzi_deg(void *const hA2sh, int index)
Returns a particular sensor's azimuth w.r.t to the origin of the array, in DEGREES.
float * array2sh_getFreqVector(void *const hA2sh, int *nFreqPoints)
Returns a pointer to the frequency vector.
void array2sh_destroy(void **const phM2sh)
Destroys an instance of array2sh.
void array2sh_create(void **const phA2sh)
Creates an instance of array2sh.
void array2sh_setRegPar(void *const hA2sh, float newVal)
Sets the value of the regularisation parameter (the maximum permitted gain of the filters),...
int array2sh_getRequestEncoderEvalFLAG(void *const hA2sh)
Returns a flag, which is '1' if there has been a recent request to evaluate the current encoding perf...
int array2sh_getMaxNumSensors(void)
Returns the maximum supported number of sensors which can be in the array.
void array2sh_setArrayType(void *const hA2sh, int newType)
Sets the type of array (see ARRAY2SH_ARRAY_TYPES enum)
int array2sh_getEncodingOrder(void *const hA2sh)
Returns the current encoding order (see SH_ORDERS enum)
float array2sh_getProgressBar0_1(void *const hA2sh)
(Optional) Returns current intialisation/processing progress, between 0..1
void array2sh_refreshSettings(void *const hA2sh)
Sets all intialisation flags to 1; re-initialising all settings/variables as array2sh is currently co...
void array2sh_setEncodingOrder(void *const hA2sh, int newOrder)
Sets the encoding order (see SH_ORDERS enum)
void array2sh_setFilterType(void *const hA2sh, int newType)
Sets the type filter design to employ for computing the encoding matrices (see ARRAY2SH_FILTER_TYPES ...
int array2sh_getSamplingRate(void *const hA2sh)
Returns the DAW/Host sample rate.
void array2sh_init(void *const hA2sh, int sampleRate)
Initialises an instance of array2sh with default settings.
void array2sh_setSensorElev_deg(void *const hA2sh, int index, float newElev_deg)
Sets a particular sensor's elevation (degrees) w.r.t to the origin of the array.
float array2sh_getRegPar(void *const hA2sh)
Returns the value of the regurlisation parameter; the maximum permitted gain provided by the filters,...
void array2sh_setEvalStatus(void *const hA2sh, ARRAY2SH_EVAL_STATUS new_evalStatus)
Sets current eval status (see ARRAY2SH_EVAL_STATUS enum)
int array2sh_getProcessingDelay()
Returns the processing delay in samples (may be used for delay compensation features)
float * array2sh_getLevelDifference_Handle(void *const hA2sh, int *nCurves, int *nFreqPoints)
Returns a pointer to the level-difference [1] data.
int array2sh_getArrayType(void *const hA2sh)
Returns the type of array.
void array2sh_setPreset(void *const hA2sh, ARRAY2SH_MICROPHONE_ARRAY_PRESETS preset)
Sets a pre-defined microphone/hydrophone array preset (See ARRAY2SH_MICROPHONE_ARRAY_PRESETS enum)
int array2sh_getNormType(void *const hA2sh)
Returns the Ambisonic normalisation convention currently being usedto decode with,...
int array2sh_getDiffEQpastAliasing(void *const hA2sh)
Flag to enabled/disable diffuse equalisation above the spatial aliasing limit of the array (0: disabl...
float ** array2sh_getbN_modal(void *const hA2sh, int *nCurves, int *nFreqPoints)
Returns the direct inversion of the modal coefficients per frequency (may be used for optional plotti...
int array2sh_getMinNumSensors(void *const hA2sh)
Returns the minimum number of sensors which can be in the array [(current_order+1)^2].
float array2sh_getc(void *const hA2sh)
Returns the speed of sound of the medium (~343m/s air, ~1480m/s water), in m/s.
void array2sh_getProgressBarText(void *const hA2sh, char *text)
(Optional) Returns current intialisation/processing progress text
void array2sh_setc(void *const hA2sh, float newc)
Sets the speed of sound of the medium (~343m/s air, ~1480m/s water), in m/s.
void array2sh_evalEncoder(void *const hA2sh)
Evaluates the encoder, based on current global/user parameters.
void array2sh_setr(void *const hA2sh, float newr)
Sets the radius of the array.
void array2sh_setSensorAzi_rad(void *const hA2sh, int index, float newAzi_rad)
Sets a particular sensor's azimuth (radians) w.r.t to the origin of the array.
void array2sh_setSensorAzi_deg(void *const hA2sh, int index, float newAzi_deg)
Sets a particular sensor's azimuth (degrees) w.r.t to the origin of the array.
int array2sh_getNSHrequired(void *const hA2sh)
Returns the number of spherical harmonic signals required by the current encoding order: (current_ord...
void array2sh_setWeightType(void *const hA2sh, int newType)
Sets the type of weights to use (see ARRAY2SH_WEIGHT_TYPES enum)
void array2sh_setDiffEQpastAliasing(void *const hA2sh, int newState)
Analyses what the theoretical spatial aliasing frequency is, and conducts diffuse-field equalisation ...
float array2sh_getGain(void *const hA2sh)
Returns the amount of post gain to apply after the encoding, in DECIBELS.
void array2sh_setChOrder(void *const hA2sh, int newOrder)
Sets the Ambisonic channel ordering convention to encode with, in order to match the convention emplo...
float array2sh_getSensorAzi_rad(void *const hA2sh, int index)
Returns a particular sensor's azimuth w.r.t to the origin of the array, in RADIANS.
int array2sh_getFrameSize(void)
Returns the processing framesize (i.e., number of samples processed with every _process() call )
float array2sh_getSensorElev_rad(void *const hA2sh, int index)
Returns a particular sensor's elevation w.r.t to the origin of the array, in RADIANS.
int array2sh_getChOrder(void *const hA2sh)
Returns the Ambisonic channel ordering convention currently being used to decode with,...
int array2sh_getFilterType(void *const hA2sh)
Returns the type filter design to employ for computing the encoding matrices (see ARRAY2SH_FILTER_TYP...
int array2sh_getWeightType(void *const hA2sh)
Returns the type of weights to use see ARRAY2SH_WEIGHT_TYPES enum.
int array2sh_getReinitSHTmatrixFLAG(void *const hA2sh)
Returns 0 if SHT is not be reinitialised, 1: if it is.
int array2sh_getNumSensors(void *const hA2sh)
Returns the number of sensors in the array.
void array2sh_setRequestEncoderEvalFLAG(void *const hA2sh, int newState)
Evaluates the performance of the current encoding filters when applied to a theoretical model of the ...
ARRAY2SH_EVAL_STATUS array2sh_getEvalStatus(void *const hA2sh)
Returns current eval status (see ARRAY2SH_EVAL_STATUS enum)
ARRAY2SH_MICROPHONE_ARRAY_PRESETS
Available microphone array presets.
#define ARRAY2SH_POST_GAIN_MIN_VALUE
Minimum post-gain, dB.
#define ARRAY2SH_BAFFLE_RADIUS_MAX_VALUE
Maximum baffle radius supported, mm.
ARRAY2SH_FILTER_TYPES
Available encoding filter approaches.
@ FILTER_TIKHONOV
Encoding filters based on a 'Tikhonov' regularised inversion of the modal responses [2].
#define ARRAY2SH_SPEED_OF_SOUND_MAX_VALUE
Maximum speed of sound value, m/s.
#define ARRAY2SH_ARRAY_RADIUS_MIN_VALUE
Minimum array radius supported, mm.
ARRAY2SH_WEIGHT_TYPES
List of supported sensor directivities and array construction types.
#define ARRAY2SH_BAFFLE_RADIUS_MIN_VALUE
Minimum baffle radius supported, mm.
#define ARRAY2SH_POST_GAIN_MAX_VALUE
Maximum post-gain, dB.
#define ARRAY2SH_MAX_GAIN_MAX_VALUE
Maximum gain value used for regularised inverse of modal coeffs, dB.
ARRAY2SH_ARRAY_TYPES
List of supported array types.
#define ARRAY2SH_ARRAY_RADIUS_MAX_VALUE
Maximum array radius supported, mm.
#define ARRAY2SH_SPEED_OF_SOUND_MIN_VALUE
Minimum speed of sound value, m/s.
#define ARRAY2SH_MAX_GAIN_MIN_VALUE
Minimum gain value used for regularised inverse of modal coeffs, dB.
ARRAY2SH_EVAL_STATUS
Current status of the encoder evaluation output data.
@ EVAL_STATUS_RECENTLY_EVALUATED
Encoder has recently been evaluated.
@ EVAL_STATUS_EVALUATING
Encoder is being evaluated.
@ EVAL_STATUS_NOT_EVALUATED
Encoder has not been evaluated.
void array2sh_evaluateSHTfilters(void *hA2sh)
Evaluates the spherical harmonic transform performance with the currently configured microphone/hydro...
void array2sh_calculate_sht_matrix(void *const hA2sh)
Computes the spherical harmonic transform (SHT) matrix, to spatially encode input microphone/hydropho...
void array2sh_initTFT(void *const hA2sh)
Initialise the filterbank used by array2sh.
void array2sh_calculate_mag_curves(void *const hA2sh)
Computes the magnitude responses of the equalisation filters; the absolute values of the regularised ...
void array2sh_initArray(void *const hPars, ARRAY2SH_MICROPHONE_ARRAY_PRESETS preset, int *arrayOrder, int firstInitFlag)
Intialises an instance of a struct based on a preset, which contains the array configuration data.
void array2sh_destroyArray(void **const hPars)
Destroys an instance of a struct, which contains the array configuration data.
void array2sh_createArray(void **const hPars)
Creates an instance of a struct, which contains the array configuration data.
Spatially encodes spherical microphone array signals into spherical harmonic signals (aka: Ambisonic ...
#define ARRAY2SH_FRAME_SIZE
Framesize, in time-domain samples.
#define MAX_NUM_SENSORS
Maximum permitted number of inputs/sensors.
void convertHOAChannelConvention(float *insig, int order, int signalLength, HOA_CH_ORDER inConvention, HOA_CH_ORDER outConvention)
Converts an Ambisonic signal from one channel ordering convention to another.
void convertHOANormConvention(float *insig, int order, int signalLength, HOA_NORM inConvention, HOA_NORM outConvention)
Converts an Ambisonic signal from one normalisation convention to another.
@ HOA_CH_ORDER_FUMA
Furse-Malham (FuMa) convention, often used by older recordings.
@ HOA_CH_ORDER_ACN
Ambisonic Channel numbering (ACN) convention, which is employed by all spherical harmonic related fun...
@ HOA_NORM_FUMA
Furse-Malham (FuMa) convention.
@ HOA_NORM_SN3D
Schmidt semi-normalisation (SN3D) convention, as used by the AmbiX standard.
@ HOA_NORM_N3D
Orthonormalised (N3D) convention, which is the default convention used by SAF.
#define SAF_CLAMP(a, min, max)
Ensures value "a" is clamped between the "min" and "max" values.
#define SAF_PI
pi constant (single precision)
void utility_svvcopy(const float *a, const int len, float *c)
Single-precision, vector-vector copy, i.e.
#define SAF_MIN(a, b)
Returns the minimum of the two values.
void utility_svsmul(float *a, const float *s, const int len, float *c)
Single-precision, multiplies each element in vector 'a' with a scalar 's', i.e.
void ** malloc2d(size_t dim1, size_t dim2, size_t data_size)
2-D malloc (contiguously allocated, so use free() as usual to deallocate)
void * malloc1d(size_t dim1_data_size)
1-D malloc (same as malloc, but with error checking)
void * calloc1d(size_t dim1, size_t data_size)
1-D calloc (same as calloc, but with error checking)
void *** malloc3d(size_t dim1, size_t dim2, size_t dim3, size_t data_size)
3-D malloc (contiguously allocated, so use free() as usual to deallocate)
void ** calloc2d(size_t dim1, size_t dim2, size_t data_size)
2-D calloc (contiguously allocated, so use free() as usual to deallocate)
#define FLATTEN2D(A)
Use this macro when passing a 2-D dynamic multi-dimensional array to memset, memcpy or any other func...
Contains variables for describing the microphone/hydrophone array.
float sensorCoords_deg[MAX_NUM_SENSORS][2]
Sensor directions in degrees.
int Q
Current number of sensors.
float R
radius of scatterer (only for rigid arrays)
ARRAY2SH_ARRAY_TYPES arrayType
see ARRAY2SH_ARRAY_TYPES
ARRAY2SH_WEIGHT_TYPES weightType
see ARRAY2SH_WEIGHT_TYPES
int newQ
New number of sensors (current value replaced by this after next re-init)
float sensorCoords_rad[MAX_NUM_SENSORS][2]
Sensor directions in radians.
Main structure for array2sh.
float ** SHframeTD
Output SH signals in the time-domain; MAX_NUM_SH_SIGNALS x ARRAY2SH_FRAME_SIZE.
float_complex *** inputframeTF
Input sensor signals in the time-domain; HYBRID_BANDS x MAX_NUM_SENSORS x TIME_SLOTS.
float progressBar0_1
Current (re)initialisation progress, between [0..1].
float freqVector[HYBRID_BANDS]
frequency vector
double_complex * bN
Temp vector for the modal coefficients.
PROC_STATUS procStatus
see PROC_STATUS
char * progressBarText
Current (re)initialisation step, string.
float c
speed of sound, m/s
void * hSTFT
filterbank handle
float ** bN_modal_dB
modal responses / no regulaisation; HYBRID_BANDS x (MAX_SH_ORDER +1)
void * arraySpecs
array configuration
float gain_dB
post gain, dB
float ** inputFrameTD
Input sensor signals in the time-domain; MAX_NUM_SENSORS x ARRAY2SH_FRAME_SIZE.
float_complex *** SHframeTF
Output SH signals in the time-domain; HYBRID_BANDS x MAX_NUM_SH_SIGNALS x TIME_SLOTS.
ARRAY2SH_EVAL_STATUS evalStatus
see ARRAY2SH_EVAL_STATUS
float * cSH
spatial correlation; HYBRID_BANDS x 1
int reinitSHTmatrixFLAG
0: do not reinit; 1: reinit;
int new_order
new encoding order (current value will be replaced by this after next re-init)
float ** bN_inv_dB
modal responses / with regularisation; HYBRID_BANDS x (MAX_SH_ORDER +1)
float regPar
regularisation upper gain limit, dB;
float * lSH
level difference; HYBRID_BANDS x 1
NORM_TYPES norm
Ambisonic normalisation convention (see NORM_TYPES)
ARRAY2SH_FILTER_TYPES filterType
encoding filter approach
int enableDiffEQpastAliasing
0: disabled, 1: enabled
int order
current encoding order
float_complex W[HYBRID_BANDS][MAX_NUM_SH_SIGNALS][MAX_NUM_SENSORS]
Encoding weights.
int evalRequestedFLAG
0: do not reinit; 1: reinit;
CH_ORDER chOrdering
Ambisonic channel order convention (see CH_ORDER)