48 pData->
pmapEQ[band] = 1.0f;
145 pData->
fs = sampleRate;
190 const float *
const * inputs,
198 int s, i, j, ch, band, nSH_order, order_band, nSH_maxOrder, maxOrder;
199 float C_grp_trace, pmapEQ_band;
200 const float_complex calpha = cmplxf(1.0f, 0.0f), cbeta = cmplxf(0.0f, 0.0f);
206 int nSources, masterOrder, nSH;
207 float covAvgCoeff, pmapAvgCoeff;
221 nSH = (masterOrder+1)*(masterOrder+1);
224 for(s=0; s<nSamples; s++){
226 for(ch=0; ch<
SAF_MIN(nInputs,nSH); ch++)
240 for(ch=0; ch<nSH; ch++)
261 cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasConjTrans, nSH, nSH,
TIME_SLOTS, &calpha,
267 cblas_sscal(nSH*nSH*2, covAvgCoeff, (
float*)pData->
Cx[band], 1);
268 cblas_saxpy(nSH*nSH*2, 1.0f-covAvgCoeff, (
float*)new_Cx, 1, (
float*)pData->
Cx[band], 1);
279 maxOrder =
SAF_MAX(maxOrder,
SAF_MIN(analysisOrderPerBand[i], masterOrder));
280 nSH_maxOrder = (maxOrder+1)*(maxOrder+1);
283 memset(C_grp, 0, nSH_maxOrder*nSH_maxOrder*
sizeof(float_complex));
286 nSH_order = (order_band+1)*(order_band+1);
288 for(i=0; i<nSH_order; i++)
289 for(j=0; j<nSH_order; j++)
290 C_grp[i*nSH_maxOrder+j] = ccaddf(C_grp[i*nSH_maxOrder+j], crmulf(pData->
Cx[band][i*nSH+j], 1e3f*pmapEQ_band));
295 for(i=0; i<nSH_maxOrder; i++)
296 C_grp_trace+=crealf(C_grp[i*nSH_maxOrder+ i]);
304 if(C_grp_trace>1e-8f)
311 if(C_grp_trace>1e-8f)
318 if(C_grp_trace>1e-8f)
325 if(C_grp_trace>1e-8f)
332 if(C_grp_trace>1e-8f)
339 if(C_grp_trace>1e-8f)
348 pData->
pmap[i] = (1.0f-pmapAvgCoeff) * (pData->
pmap[i] )+ pmapAvgCoeff * (pData->
prev_pmap[i]);
354 pData->
pmap, 1, 0.0f,
429 int band, rangeIdx, curOrder, reverse;
435 case MIC_PRESET_IDEAL:
443 case MIC_PRESET_ZYLIA:
457 pData->
pmapEQ[band] = 0.0f;
461 case MIC_PRESET_EIGENMIKE32:
475 pData->
pmapEQ[band] = 0.0f;
479 case MIC_PRESET_DTU_MIC:
493 pData->
pmapEQ[band] = 0.0f;
517 pData->
pmapEQ[bandIdx] = newValue;
526 pData->
pmapEQ[band] = newValue;
613 return (
int)(pData->
fs+0.5f);
625 return pData->
pmapEQ[bandIdx];
644 (*pY_values) = &(pData->
pmapEQ[0]);
694 return (
int)pData->
norm;
721int powermap_getPmap(
void*
const hPm,
float** grid_dirs,
float** pmap,
int* nDirs,
int* pmapWidth,
int* hfov,
int* aspectRatio)
#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.
HFOV_OPTIONS
Available horizontal field-of-view (FOV) options.
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.
ASPECT_RATIO_OPTIONS
Available aspect ratios.
@ ASPECT_RATIO_2_1
ASPECT_RATIO_2_1 - 2:1.
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 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.
void generateMinNormMap(int order, float_complex *Cx, float_complex *Y_grid, int nSources, int nGrid_dirs, int logScaleFlag, float *pmap)
Generates an activity-map based on the sub-space minimum-norm (MinNorm) method.
void generateMVDRmap(int order, float_complex *Cx, float_complex *Y_grid, int nGrid_dirs, float regPar, float *pmap, float_complex *w_MVDR_out)
Generates a powermap based on the energy of adaptive Minimum-Variance Distortion-less Response (MVDR)...
void generateMUSICmap(int order, float_complex *Cx, float_complex *Y_grid, int nSources, int nGrid_dirs, int logScaleFlag, float *pmap)
Generates an activity-map based on the sub-space multiple-signal classification (MUSIC) method.
void generatePWDmap(int order, float_complex *Cx, float_complex *Y_grid, int nGrid_dirs, float *pmap)
Generates a powermap based on the energy of a plane-wave decomposition (PWD) (i.e.
void generateCroPaCLCMVmap(int order, float_complex *Cx, float_complex *Y_grid, int nGrid_dirs, float regPar, float lambda, float *pmap)
(EXPERIMENTAL) Generates a powermap utilising the CroPaC LCMV post-filter described in [1]
#define SAF_MAX(a, b)
Returns the maximum of the two values.
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.
const float __Eigenmike32_freqRange[6]
Sensor array frequency ranges for each SH order, for the Eigenmike32 (should only be used as a rough ...
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 __Zylia_maxOrder
Max spherical harmonic order for the Zylia mic.
void utility_siminv(const float *a, const int len, int *index)
Single-precision, index of minimum absolute value in a vector, i.e.
void utility_simaxv(const float *a, const int len, int *index)
Single-precision, index of maximum absolute value in a vector, 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 *** 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)
#define FLATTEN2D(A)
Use this macro when passing a 2-D dynamic multi-dimensional array to memset, memcpy or any other func...
int powermap_getNormType(void *const hPm)
Returns the Ambisonic normalisation convention currently being usedto decode with,...
int powermap_getProcessingDelay()
Returns the processing delay in samples (may be used for delay compensation features)
void powermap_refreshSettings(void *const hPm)
Sets all intialisation flags to 1; re-initialising all settings/variables as powermap is currently co...
void powermap_setChOrder(void *const hPm, int newOrder)
Sets the Ambisonic channel ordering convention to decode with, in order to match the convention emplo...
int powermap_getAnaOrder(void *const hPm, int bandIdx)
Returns the input/analysis order for one specific frequency band.
int powermap_getNumberOfBands(void)
Returns the number of frequency bands used for the analysis.
int powermap_getPowermapMode(void *const hPm)
Returns the powermap/activity-map mode to employed for the analysis see POWERMAP_MODES enum.
float powermap_getPowermapAvgCoeff(void *const hPm)
Returns the current activity-map averaging coefficient, 0..1.
int powermap_getAnaOrderAllBands(void *const hPm)
Returns the input/analysis order for the first frequency band.
void powermap_setNormType(void *const hPm, int newType)
Sets the Ambisonic normalisation convention to decode with, in order to match with the convention emp...
float powermap_getProgressBar0_1(void *const hPm)
(Optional) Returns current intialisation/processing progress, between 0..1
void powermap_setAspectRatio(void *const hPm, int newOption)
Sets the visualisation display window aspect-ratio (see ASPECT_RATIO_OPTIONS enum)
void powermap_setNumSources(void *const hPm, int newValue)
Sets the number of sources present in the input sound scene.
void powermap_setPowermapAvgCoeff(void *const hPm, float newValue)
Sets the activity-map averaging coefficient, 0..1.
int powermap_getFrameSize(void)
Returns the processing framesize (i.e., number of samples processed with every _process() call )
void powermap_setCovAvgCoeff(void *const hPm, float newAvg)
Sets the covariance matrix averaging coefficient, 0..1.
int powermap_getChOrder(void *const hPm)
Returns the Ambisonic channel ordering convention currently being used to decode with,...
float powermap_getPowermapEQAllBands(void *const hPm)
Returns the weighting coefficient for the first frequency band.
int powermap_getNumSources(void *const hPm)
Returns the number of sources present in the input sound scene.
void powermap_setSourcePreset(void *const hPm, int newPresetID)
Sets an input preset; the microphone/hyrophone array used to capture the input signals,...
void powermap_initCodec(void *const hPm)
Intialises the codec variables, based on current global/user parameters.
int powermap_getPmap(void *const hPm, float **grid_dirs, float **pmap, int *nDirs, int *pmapWidth, int *hfov, int *aspectRatio)
Returns the latest computed activity-map if it is ready.
void powermap_destroy(void **const phPm)
Destroys an instance of the powermap.
void powermap_setMasterOrder(void *const hPm, int newValue)
Sets the maximum input/analysis order (see SH_ORDERS enum)
void powermap_init(void *const hPm, float sampleRate)
Initialises an instance of powermap with default settings.
void powermap_setAnaOrder(void *const hPm, int newValue, int bandIdx)
Sets the input/analysis order for one specific frequency band index.
int powermap_getAspectRatio(void *const hPm)
Returns the current visualisation display window aspect-ratio (see ASPECT_RATIO_OPTIONS enum)
void powermap_requestPmapUpdate(void *const hPm)
Informs powermap that it should compute a new activity-map at its own convenience,...
void powermap_setPowermapMode(void *const hPm, int newMode)
Sets the powermap/activity-map approach, (see POWERMAP_MODES enum)
void powermap_setPowermapEQAllBands(void *const hPm, float newValue)
Sets the weighting coefficient for all frequency bands.
void powermap_getProgressBarText(void *const hPm, char *text)
(Optional) Returns current intialisation/processing progress text
void powermap_analysis(void *const hPm, const float *const *inputs, int nInputs, int nSamples, int isPlaying)
Analyses the input spherical harmonic signals to generate an activity-map.
void powermap_create(void **const phPm)
Creates an instance of the powermap.
int powermap_getMasterOrder(void *const hPm)
Returns the current maximum analysis/input order (see SH_ORDERS enum)
float powermap_getPowermapEQ(void *const hPm, int bandIdx)
Returns the weighting coefficient for a particular frequency band index, allowing one to "equalise" t...
void powermap_setDispFOV(void *const hPm, int newOption)
Sets the visualisation display window horizontal field-of-view (FOV) (see HFOV_OPTIONS enum)
int powermap_getDispFOV(void *const hPm)
Returns the current visualisation display window horizontal field-of-view (FOV) (see HFOV_OPTIONS enu...
void powermap_getPowermapEQHandle(void *const hPm, float **pX_vector, float **pY_values, int *pNpoints)
Returns the weighting coefficient for all frequency bands.
void powermap_setAnaOrderAllBands(void *const hPm, int newValue)
Sets the input/analysis order for all frequency bands.
int powermap_getSamplingRate(void *const hPm)
Returns the current sampling rate, in Hz.
void powermap_getAnaOrderHandle(void *const hPm, float **pX_vector, int **pY_values, int *pNpoints)
Returns the input/analysis order for all frequency bands.
int powermap_getNSHrequired(void *const hPm)
Returns the number of spherical harmonic signals required by the current analysis order: (current_ord...
void powermap_setPowermapEQ(void *const hPm, float newValue, int bandIdx)
Sets the weighting coefficient for a particular frequency band, allowing one to "equalise" the activi...
CODEC_STATUS powermap_getCodecStatus(void *const hPm)
Returns current codec status (see CODEC_STATUS enum)
float powermap_getCovAvgCoeff(void *const hPm)
Returns the current covariance averaging coefficient value, in Hz.
A sound-field visualiser, which utilises spherical harmonic signals as input; note this code is a rem...
POWERMAP_MODES
Available power-map/activity-map options.
@ PM_MODE_PWD
Activity-map based on the energy of hyper-cardioid [plane-wave decomposition (PWD)] beamformers.
@ PM_MODE_MVDR
Activity-map based on the energy of minimum- variance distortionless response (MVDR) beamformers.
@ PM_MODE_MINNORM
Activity-map based on the sub-space method: minimum-norm (Min-Norm)
@ PM_MODE_MINNORM_LOG
Same as PM_MODE_MINNORM, but log(out_values)
@ PM_MODE_MUSIC_LOG
Same as PM_MODE_MUSIC, but log(out_values)
@ PM_MODE_CROPAC_LCMV
Experimental! activity-map based on a linearly- contrained minimum-variance (LCMV) formulation of the...
@ PM_MODE_MUSIC
Activity-map based on the sub-space method: multiple signal classification (MUSIC)
void powermap_setCodecStatus(void *const hPm, CODEC_STATUS newStatus)
Sets codec status (see CODEC_STATUS enum)
void powermap_initTFT(void *const hPm)
Initialise the filterbank used by powermap.
void powermap_initAna(void *const hPm)
Intialises the codec variables, based on current global/user parameters.
A sound-field visualiser, which utilises spherical harmonic signals as input; note this code is a rem...
#define MAX_COV_AVG_COEFF
Maximum supported covariance averaging coefficient
#define POWERMAP_FRAME_SIZE
Framesize, in time-domain samples.
Contains variables for scanning grids, and beamforming.
float_complex * Y_grid_cmplx[MAX_SH_ORDER]
real SH basis (complex datatype); MAX_NUM_SH_SIGNALS x grid_nDirs
float * interp_dirs_deg
2D rectangular window interpolation directions, in degrees; FLAT: interp_nDirs x 2
float * interp_table
Spherical->2D interpolation table; FLAT: interp_nDirs x grid_nDirs.
int grid_nDirs
Number of scanning directions.
float * Y_grid[MAX_SH_ORDER]
real SH basis (real datatype); MAX_NUM_SH_SIGNALS x grid_nDirs
int interp_nDirs
Number of interpolation directions.
Main structure for powermap.
float pmapAvgCoeff
Powermap averaging coefficient, [0..1].
powermap_codecPars * pars
codec parameters
float fs
Host sample rate, in Hz.
CH_ORDER chOrdering
Ambisonic channel order convention (see CH_ORDER)
int dispWidth
Number of pixels on the horizontal in the 2D interpolated powermap image.
float_complex *** SHframeTF
time-frequency domain SH input frame; HYBRID_BANDS x MAX_NUM_SH_SIGNALS x TIME_SLOTS
float freqVector[HYBRID_BANDS]
Frequency vector (filterbank centre frequencies)
float inFIFO[MAX_NUM_SH_SIGNALS][POWERMAP_FRAME_SIZE]
Input FIFO buffer.
POWERMAP_MODES pmap_mode
see POWERMAP_MODES
PROC_STATUS procStatus
see PROC_STATUS
int pmapReady
0: powermap not started yet, 1: powermap is ready for plotting
float progressBar0_1
Current (re)initialisation progress, between [0..1].
float covAvgCoeff
Covariance matrix averaging coefficient, [0..1].
float * prev_pmap
grid_nDirs x 1
float pmapEQ[HYBRID_BANDS]
Equalisation/weights per band.
int new_masterOrder
New maximum/master SH analysis order (current value will be replaced by this after next re-init)
float pmap_grid_minVal
Current minimum value in pmap (used to normalise [0..1])
int recalcPmap
set this to 1 to generate a new powermap
HFOV_OPTIONS HFOVoption
see HFOV_OPTIONS
CODEC_STATUS codecStatus
see CODEC_STATUS
int FIFO_idx
FIFO buffer index.
int masterOrder
Current maximum/master SH analysis order.
float * pmap
grid_nDirs x 1
float ** SHframeTD
time-domain SH input frame; MAX_NUM_SH_SIGNALS x POWERMAP_FRAME_SIZE
ASPECT_RATIO_OPTIONS aspectRatioOption
see ASPECT_RATIO_OPTIONS
int dispSlotIdx
Current display slot.
float_complex Cx[HYBRID_BANDS][MAX_NUM_SH_SIGNALS *MAX_NUM_SH_SIGNALS]
covariance matrices per band
NORM_TYPES norm
Ambisonic normalisation convention (see NORM_TYPES)
float pmap_grid_maxVal
Current maximum value in pmap (used to normalise [0..1])
int nSources
Current number of sources (used for MUSIC)
float * pmap_grid[NUM_DISP_SLOTS]
powermap interpolated to grid; interp_nDirs x 1
int analysisOrderPerBand[HYBRID_BANDS]
SH analysis order per frequency band.
char * progressBarText
Current (re)initialisation step, string.
void * hSTFT
afSTFT handle