55 *phSld = (
void*)pData;
104 pData->
fs = 48000.0f;
159 pData->
fs = sampleRate;
208 const float *
const * inputs,
215 int s, i, j, t, ch, band, nSectors, min_band, numAnalysisBands, current_disp_idx;
221 int nSH, masterOrder;
224 float minFreq, maxFreq, avg_ms;
238 for(s=0; s<nSamples; s++){
240 for(ch=0; ch<
SAF_MIN(nInputs,nSH); ch++)
255 for(ch=0; ch<nSH; ch++)
275 numAnalysisBands = 0;
281 nSectors = nSectorsPerBand[band];
282 avgCoeff = avg_ms < 10.0f ? 1.0f : 1.0f / ((avg_ms/1e3f) / (1.0f/(
float)
HOP_SIZE) + 2.23e-9f);
285 analysisOrderPerBand[band],
286 pData->
secCoeffs[analysisOrderPerBand[band]-2],
291 for(i=0; i<nSectors; i++){
294 unitSph2cart((
float*)new_doa[i][t], 1, 0, (
float*)new_doa_xyz);
297 avg_xyz[j] = new_doa_xyz[j]*avgCoeff + doa_xyz[j] * (1.0f-avgCoeff);
301 pData->
energy[band][i] = new_energy[i][t]*avgCoeff + pData->
energy[band][i] * (1.0f-avgCoeff);
311 nSectors = nSectorsPerBand[band];
312 max_en[band] = 2.3e-13f; min_en[band] = 2.3e13f;
313 for(i=0; i<nSectors; i++){
314 max_en[band] = pData->
energy[band][i] > max_en[band] ? pData->
energy[band][i] : max_en[band];
315 min_en[band] = pData->
energy[band][i] < min_en[band] ? pData->
energy[band][i] : min_en[band];
323 nSectors = nSectorsPerBand[band];
325 for(i=0; i<nSectors; i++){
333 if( analysisOrderPerBand[band]==1 )
381 if(newFreq < pData->minFreq )
404 int band, rangeIdx, curOrder, reverse;
410 case MIC_PRESET_IDEAL:
415 case MIC_PRESET_ZYLIA:
432 case MIC_PRESET_EIGENMIKE32:
449 case MIC_PRESET_DTU_MIC:
537 return (
int)(pData->
fs+0.5f);
566 int** pNsectorsPerBand,
641 return (
int)pData->
norm;
#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)
CODEC_STATUS
Current status of the codec.
@ CODEC_STATUS_NOT_INITIALISED
Codec has not yet been initialised, or the codec configuration has changed.
@ CODEC_STATUS_INITIALISED
Codec is initialised and ready to process input audio.
@ CODEC_STATUS_INITIALISING
Codec is currently being initialised, input audio should not be processed.
void afSTFT_create(void **const phSTFT, int nCHin, int nCHout, int hopsize, int lowDelayMode, int hybridmode, AFSTFT_FDDATA_FORMAT format)
Creates an instance of afSTFT.
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.
@ AFSTFT_BANDS_CH_TIME
nBands x nChannels x nTimeHops
#define TIME_SLOTS
Number of STFT timeslots.
#define HOP_SIZE
STFT hop size.
#define HYBRID_BANDS
Number of frequency bands.
#define NUM_DISP_SLOTS
Number of display slots.
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 getRSH(int N, float *dirs_deg, int nDirs, float *Y)
Computes real-valued spherical harmonics [1] for each given direction on the unit sphere.
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 ORDER2NSH(order)
Converts spherical harmonic order to number of spherical harmonic components i.e: (order+1)^2.
#define SAF_PI
pi constant (single precision)
#define SAF_MAX(a, b)
Returns the maximum of the two values.
const float __Tdesign_degree_70_dirs_deg[2520][2]
Directions [azimuth, Elevation] in degrees, for minimum Tdesign degree: 70.
#define SAF_MIN(a, b)
Returns the minimum of the two values.
const float __Eigenmike32_freqRange[6]
Sensor array frequency ranges for each SH order, for the Eigenmike32 (should only be used as a rough ...
void unitSph2cart(float *dirs, int nDirs, int anglesInDegreesFLAG, float *dirs_xyz)
Converts spherical coordinates to Cartesian coordinates of unit length.
void unitCart2sph(float *dirs_xyz, int nDirs, int anglesInDegreesFLAG, float *dirs)
Converts Cartesian coordinates of unit length to spherical coordinates.
const int __Eigenmike32_maxOrder
Max spherical harmonic order for the Eigenmike32.
const float __Zylia_freqRange[4]
Sensor array frequency ranges for each SH order, for the Zylia array (should only be used as a rough ...
const int __DTU_mic_maxOrder
Max spherical harmonic order for the custom 52-sensor array built at the Technical University of Denm...
const float __DTU_mic_freqRange[10]
Sensor array frequency ranges for each SH order, for the DTU mic (should only be used as a rough esti...
const int __Tdesign_degree_70_nPoints
Number of directions in a minimum Tdesign of degree: 70.
const int __Zylia_maxOrder
Max spherical harmonic order for the Zylia mic.
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 *** 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...
int sldoa_getNumberOfBands(void)
Returns the number frequency bands employed by sldoa.
void sldoa_destroy(void **const phSld)
Destroys an instance of the sldoa.
int sldoa_getMasterOrder(void *const hSld)
Returns the current maximum analysis/input order (see SH_ORDERS enum)
int sldoa_getAnaOrder(void *const hSld, int bandIdx)
Returns the input/analysis order for one specific frequency band.
int sldoa_getChOrder(void *const hSld)
Returns the Ambisonic channel ordering convention currently being used to decode with,...
void sldoa_refreshSettings(void *const hSld)
Sets all intialisation flags to 1; re-initialising all settings/variables as sldoa is currently confi...
void sldoa_initCodec(void *const hSld)
Intialises the codec variables, based on current global/user parameters.
int sldoa_getAnaOrderAllBands(void *const hSld)
Returns the input/analysis order for the first frequency band.
void sldoa_setChOrder(void *const hSld, int newOrder)
Sets the Ambisonic channel ordering convention to decode with, in order to match the convention emplo...
void sldoa_setSourcePreset(void *const hSld, int newPresetID)
Sets an input preset, the microphone/hyrophone array used to capture the input signals (see MIC_PRESE...
void sldoa_setMaxFreq(void *const hSld, float newFreq)
Sets the maximum analysis frequency, in Hz.
int sldoa_getFrameSize(void)
Returns the processing framesize (i.e., number of samples processed with every _process() call )
void sldoa_setAnaOrder(void *const hSld, int newValue, int bandIdx)
Sets the input/analysis order for one specific frequency band.
void sldoa_getDisplayData(void *const hSld, float **azi_deg, float **elev_deg, float **colourScale, float **alphaScale, int **pNsectorsPerBand, int *maxNumSectors, int *startBand, int *endBand)
Returns the analysis output data.
float sldoa_getMaxFreq(void *const hSld)
Returns the maximum analysis frequency, in Hz.
void sldoa_setNormType(void *const hSld, int newType)
Sets the Ambisonic normalisation convention to decode with, in order to match with the convention emp...
void sldoa_setAnaOrderAllBands(void *const hSld, int newValue)
Sets the input/analysis order for all frequency bands.
int sldoa_getNormType(void *const hSld)
Returns the Ambisonic normalisation convention currently being usedto decode with,...
void sldoa_getAnaOrderHandle(void *const hSld, float **pX_vector, int **pY_values, int *pNpoints)
Returns the input/analysis order for all frequency bands.
void sldoa_init(void *const hSld, float sampleRate)
Initialises an instance of sldoa with default settings.
void sldoa_analysis(void *const hSld, const float *const *inputs, int nInputs, int nSamples, int isPlaying)
Applies the spatially-localised active-intensity based direction-of-arrival estimator (SLDoA) onto th...
float sldoa_getProgressBar0_1(void *const hSld)
(Optional) Returns current intialisation/processing progress, between 0..1
float sldoa_getAvg(void *const hSld)
Returns the current DoA averaging coefficient value, 0..1.
float sldoa_getMinFreq(void *const hSld)
Returns the minimum analysis frequency, in Hz.
int sldoa_getProcessingDelay()
Returns the processing delay in samples (may be used for delay compensation features)
CODEC_STATUS sldoa_getCodecStatus(void *const hSld)
Returns current codec status (see CODEC_STATUS enum)
void sldoa_setAvg(void *const hSld, float newAvg)
Sets the DoA averaging coefficient, 0..1.
int sldoa_getNSHrequired(void *const hSld)
Returns the number of spherical harmonic signals required by the current analysis order: (current_ord...
void sldoa_setMasterOrder(void *const hSld, int newValue)
Sets the maximum input/analysis order (see SH_ORDERS enum)
void sldoa_getProgressBarText(void *const hSld, char *text)
(Optional) Returns current intialisation/processing progress text
void sldoa_create(void **const phSld)
Creates an instance of the sldoa.
int sldoa_getSamplingRate(void *const hSld)
Returns the current sampling rate, in Hz.
void sldoa_setMinFreq(void *const hSld, float newFreq)
Sets the minimum analysis frequency, in Hz.
A spatially-localised active-intensity (SLAI) based direction-of- arrival estimator (SLDoA)
void sldoa_setCodecStatus(void *const hSld, CODEC_STATUS newStatus)
Sets codec status (see CODEC_STATUS enum)
void sldoa_initAna(void *const hSld)
Intialises the codec variables, based on current global/user parameters.
void sldoa_initTFT(void *const hSld)
Initialise the filterbank used by sldoa.
void sldoa_estimateDoA(float_complex **SHframeTF, int anaOrder, float_complex *secCoeffs, float doa[MAX_NUM_SECTORS][TIME_SLOTS][2], float energy[MAX_NUM_SECTORS][TIME_SLOTS])
Estimates the DoA using the active intensity vectors derived from spatially localised sectors,...
A spatially-localised active-intensity (SLAI) based direction-of- arrival estimator (SLDoA)
#define MAX_NUM_SECTORS
maximum number of sectors, TODO: expand beyond 64 (which is the max possible in the spherecovering gr...
#define SLDOA_FRAME_SIZE
Framesize, in time-domain samples.
#define ORDER2NUMSECTORS(L)
Macro to convert SH order to number of sectors.
int FIFO_idx
FIFO buffer index.
float maxFreq
Maximum display frequency, in Hz.
float energy[HYBRID_BANDS][MAX_NUM_SECTORS]
Current Sector energies.
int new_masterOrder
New master/maximum analysis order (current value will be replaced by this after next re-init)
float fs
Host sampling rate, in Hz.
float progressBar0_1
Current (re)initialisation progress, between [0..1].
PROC_STATUS procStatus
see PROC_STATUS
float ** inFIFO
FIFO buffer.
void * hSTFT
afSTFT handle
float * colourScale[NUM_DISP_SLOTS]
Values dictating each DoA marker colour.
float * alphaScale[NUM_DISP_SLOTS]
Values dictating each DoA marker transparency.
int analysisOrderPerBand[HYBRID_BANDS]
Analysis order MIN(anaPerBand, masterOrder) for each frequency band.
float * elev_deg[NUM_DISP_SLOTS]
DoA elevations, in degrees.
float_complex * secCoeffs[MAX_SH_ORDER-1]
Sector beamforming weights/coefficients.
CODEC_STATUS codecStatus
see CODEC_STATUS
float minFreq
Minimum display frequency, in Hz.
float doa_rad[HYBRID_BANDS][MAX_NUM_SECTORS][2]
Current DoA estimates per band and sector, in radians.
float ** grid_Y_dipoles_norm
SH basis.
char * progressBarText
Current (re)initialisation step, string.
NORM_TYPES norm
Ambisonic normalisation convention (see NORM_TYPES)
float_complex *** SHframeTF
time-frequency domain SH input frame; HYBRID_BANDS x MAX_NUM_SH_SIGNALS x TIME_SLOTS
float ** grid_dirs_deg
Grid directions, in degrees.
float ** SHframeTD
time-domain SH input frame; MAX_NUM_SH_SIGNALS x SLDOA_FRAME_SIZE
float avg_ms
Temporal averaging, in ms.
CH_ORDER chOrdering
Ambisonic channel order convention (see CH_ORDER)
int masterOrder
Current master/maximum analysis order.
int nSectorsPerBand[HYBRID_BANDS]
Number of sectors per band.
int nGrid
Number of grid directions.
int current_disp_idx
Current display slot.
float freqVector[HYBRID_BANDS]
Frequency vector (filterbank centre frequencies)
float * azi_deg[NUM_DISP_SLOTS]
DoA azimuths, in degrees.