46 *phDir = (
void*)pData;
118 if(pData->
pmap!=NULL)
156 pData->
fs = sampleRate;
200 const float *
const * inputs,
208 int s, i, j, k, ch, sec_nSH, secOrder, nSH, up_nSH;
212 int inputOrder, DirAssMode, upscaleOrder;
213 float pmapAvgCoeff, minFreq_hz, maxFreq_hz;
224 secOrder = inputOrder-1;
225 nSH = (inputOrder+1)*(inputOrder+1);
226 sec_nSH = (secOrder+1)*(secOrder+1);
227 up_nSH = (upscaleOrder+1)*(upscaleOrder+1);
230 for(s=0; s<nSamples; s++){
232 for(ch=0; ch<
SAF_MIN(nInputs,nSH); ch++)
246 for(ch=0; ch<nSH; ch++)
286 cblas_sgemm(CblasRowMajor, CblasTrans, CblasNoTrans, 3,
DIRASS_FRAME_SIZE, nSH, 1.0f,
287 &(pars->
Cxyz[i*nSH*3]), 3,
292 memset(intensity, 0, 3*
sizeof(
float));
299 intensity[k] = pmapAvgCoeff * (pars->
prev_intensity[i*3+k]) + (1.0f-pmapAvgCoeff) * intensity[k];
304 pars->
est_dirs[i*2] = atan2f(intensity[1], intensity[0]);
305 pars->
est_dirs[i*2+1] = atan2f(intensity[2], sqrtf(powf(intensity[0], 2.0f) + powf(intensity[1], 2.0f)));
330 pData->
pmap[i] = pmapAvgCoeff * (pars->
prev_energy[i]) + (1.0f-pmapAvgCoeff) * (pData->
pmap[i]);
337 pData->
pmap, 1, 0.0f,
363 pData->
pmap[i] = pmapAvgCoeff * (pars->
prev_energy[i]) + (1.0f-pmapAvgCoeff) * (pData->
pmap[i]);
370 pData->
pmap, 1, 0.0f,
384 pData->
pmap[i] = pmapAvgCoeff * (pars->
prev_energy[i]) + (1.0f-pmapAvgCoeff) * (pData->
pmap[i]);
620 return (
int)(pData->
fs+0.5f);
638 return (
int)pData->
norm;
659int dirass_getPmap(
void*
const hDir,
float** grid_dirs,
float** pmap,
int* nDirs,
int* pmapWidth,
int* hfov,
float* aspectRatio)
670 case HFOV_360: (*hfov) = 360;
break;
671 case HFOV_180: (*hfov) = 180;
break;
672 case HFOV_90: (*hfov) = 90;
break;
673 case HFOV_60: (*hfov) = 60;
break;
STATIC_BEAM_TYPES
Available static beamforming approaches.
@ STATIC_BEAM_TYPE_HYPERCARDIOID
hyper-cardioid
#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)
@ 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_4_3
ASPECT_RATIO_4_3 - 4:3.
@ ASPECT_RATIO_16_9
ASPECT_RATIO_16_9 - 16:9.
@ ASPECT_RATIO_2_1
ASPECT_RATIO_2_1 - 2:1.
int dirass_getInputOrder(void *const hDir)
Returns the current analysis/input order (see SH_ORDERS enum)
int dirass_getDiRAssMode(void *const hDir)
Returns the current analysis directional re-assignment mode (see DIRASS_REASS_MODES enum)
void dirass_setInputOrder(void *const hDir, int newValue)
Sets the input/analysis order (see SH_ORDERS enum)
void dirass_requestPmapUpdate(void *const hDir)
Informs dirass that it should compute a new activity-map.
void dirass_setMinFreq(void *const hDir, float newValue)
Sets the minimum analysis frequency, in Hz.
void dirass_create(void **const phDir)
Creates an instance of the dirass.
void dirass_init(void *const hDir, float sampleRate)
Initialises an instance of dirass with default settings.
void dirass_analysis(void *const hDir, const float *const *inputs, int nInputs, int nSamples, int isPlaying)
Analyses the input spherical harmonic signals to generate an activity-map as in [1,...
void dirass_initCodec(void *const hDir)
Intialises the codec variables, based on current global/user parameters.
void dirass_destroy(void **const phDir)
Destroys an instance of the dirass.
void dirass_setDispWidth(void *const hDir, int newValue)
Sets the output display width in pixels.
void dirass_setMaxFreq(void *const hDir, float newValue)
Sets the maximum analysis frequency, in Hz.
void dirass_setDiRAssMode(void *const hDir, int newMode)
Sets the analysis directional re-assignment mode (see DIRASS_REASS_MODES enum)
void dirass_setAspectRatio(void *const hDir, int newOption)
Sets the visualisation display window aspect-ratio (see ASPECT_RATIO_OPTIONS enum)
float dirass_getMinFreq(void *const hDir)
Returns the current minimum analysis frequency, in Hz.
int dirass_getNormType(void *const hDir)
Returns the Ambisonic normalisation convention currently being usedto decode with,...
void dirass_setUpscaleOrder(void *const hDir, int newValue)
Sets the upscale order, only if DIRASS_REASS_MODES is set to REASS_UPSCALE, (see DIRASS_UPSCALE_ORDER...
int dirass_getDisplayGridOption(void *const hDir)
Returns the current display grid option (see DIRASS_GRID_OPTIONS enum)
int dirass_getDispWidth(void *const hDir)
Returns the current output display width in pixels.
void dirass_setDispFOV(void *const hDir, int newOption)
Sets the visualisation display window horizontal field-of-view (FOV) (see HFOV_OPTIONS enum)
int dirass_getDispFOV(void *const hDir)
Returns the current visualisation display window horizontal field-of-view (FOV) (see HFOV_OPTIONS enu...
int dirass_getPmap(void *const hDir, float **grid_dirs, float **pmap, int *nDirs, int *pmapWidth, int *hfov, float *aspectRatio)
Returns the latest computed activity-map if it is ready; otherwise it returns 0, and you'll just have...
float dirass_getMaxFreq(void *const hDir)
Returns the current maximum analysis frequency, in Hz.
int dirass_getSamplingRate(void *const hDir)
Returns the current sampling rate, in Hz.
void dirass_setDisplayGridOption(void *const hDir, int newState)
Sets a new display grid option (see DIRASS_GRID_OPTIONS enum)
CODEC_STATUS dirass_getCodecStatus(void *const hDir)
Returns current codec status (see CODEC_STATUS enum)
int dirass_getUpscaleOrder(void *const hDir)
Returns the current upscale order (see DIRASS_UPSCALE_ORDERS enum)
int dirass_getFrameSize(void)
Returns the processing framesize (i.e., number of samples processed with every _process() call )
void dirass_setNormType(void *const hDir, int newType)
Sets the Ambisonic normalisation convention to decode with, in order to match with the convention emp...
int dirass_getProcessingDelay()
Returns the processing delay in samples (may be used for delay compensation features)
int dirass_getChOrder(void *const hDir)
Returns the Ambisonic channel ordering convention currently being used to decode with,...
void dirass_setBeamType(void *const hDir, int newType)
Sets the sector beamforming pattern to employ for the analysis (see STATIC_BEAM_TYPES enum).
void dirass_getProgressBarText(void *const hDir, char *text)
(Optional) Returns current intialisation/processing progress text
int dirass_getAspectRatio(void *const hDir)
Returns the current visualisation display window aspect-ratio (see ASPECT_RATIO_OPTIONS enum)
float dirass_getProgressBar0_1(void *const hDir)
(Optional) Returns current intialisation/processing progress, between 0..1
void dirass_setMapAvgCoeff(void *const hDir, float newValue)
Sets the activity-map averaging coefficient, 0..1.
void dirass_refreshSettings(void *const hDir)
Sets all intialisation flags to 1; re-initialising all settings/variables as dirass is currently conf...
void dirass_setChOrder(void *const hDir, int newOrder)
Sets the Ambisonic channel ordering convention to decode with, in order to match the convention emplo...
float dirass_getMapAvgCoeff(void *const hDir)
Returns the current activity-map averaging coefficient, 0..1.
int dirass_getNSHrequired(void *const hDir)
Returns the number of spherical harmonic signals required by the current analysis order: (current_ord...
int dirass_getBeamType(void *const hDir)
Returns the sector beamforming pattern to employed for the analysis (see STATIC_BEAM_TYPES enum)
A sound-field visualiser based on the directional re-assignment of beamformer energy based on local D...
DIRASS_REASS_MODES
Available processing modes.
@ REASS_NEAREST
Each sector beamformer energy is re-assigned to the nearest interpolation grid point,...
@ REASS_MODE_OFF
Re-assignment is disabled.
@ REASS_UPSCALE
Each sector beamformer is re-encoded into spherical harmonics of a higher order.
DIRASS_GRID_OPTIONS
Available scanning grid options.
@ GRID_GEOSPHERE_8
GRID_GEOSPHERE_8 - 642 points.
@ UPSCALE_ORDER_TENTH
Tenth-order upscaling.
void dirass_setCodecStatus(void *const hDir, CODEC_STATUS newStatus)
Sets codec status (see CODEC_STATUS enum)
void dirass_initAna(void *const hDir)
Intialises the codec variables, based on current global/user parameters.
A sound-field visualiser based on the directional re-assignment of beamformer energy based on local D...
#define MAX_NUM_INPUT_SH_SIGNALS
Maximum number of SH signals for the input.
#define DIRASS_FRAME_SIZE
Framesize, in time-domain samples.
#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 getSHreal_recur(int N, float *dirs_rad, int nDirs, float *Y)
Computes real-valued spherical harmonics [1] for each given direction on the unit sphere.
#define SAF_PI
pi constant (single precision)
#define SAF_MAX(a, b)
Returns the maximum of the two values.
#define SAF_MIN(a, b)
Returns the minimum of the two values.
void applyBiQuadFilter(float b[3], float a[3], float w_z_12[2], float *signal, int nSamples)
Applies biQuad filter to an input signal using the direct form II difference equation: https://en....
void biQuadCoeffs(BIQUAD_FILTER_TYPES filterType, float fc, float fs, float Q, float gain_dB, float b[3], float a[3])
Calculates 2nd order IIR filter coefficients [1].
void findClosestGridPoints(float *grid_dirs, int nGrid, float *target_dirs, int nTarget, int degFLAG, int *idx_closest, float *dirs_closest, float *angle_diff)
Finds indicies into "grid_dirs" that are the closest to "target dirs".
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.
@ BIQUAD_FILTER_LPF
low-pass filter (DAFx-Zolzer)
@ BIQUAD_FILTER_HPF
high-pass filter (DAFx-Zolzer)
void * malloc1d(size_t dim1_data_size)
1-D malloc (same as malloc, but with error checking)
Contains variables for scanning grids, and sector beamforming.
float * ss
beamformer sector signals; FLAT: grid_nDirs x DIRASS_FRAME_SIZE
float * interp_table
interpolation table (spherical->rectangular grid); FLAT: interp_nDirs x grid_nDirs
float * interp_dirs_deg
interpolation directions, in degrees; FLAT: interp_nDirs x 2
float * est_dirs
estimated DoA per grid direction; grid_nDirs x 2
float * Cxyz
beamforming weights for velocity patterns; FLAT: nDirs x (order+1)^2 x 3
float * prev_energy
previous energy (for averaging); FLAT: grid_nDirs x 1
int * est_dirs_idx
DoA indices, into the interpolation directions; grid_nDirs x 1.
float * prev_intensity
previous intensity vectors (for averaging); FLAT: grid_nDirs x 3
float * w
beamforming weights; FLAT: nDirs x (order+1)^2
float * Cw
beamforming weights; FLAT: nDirs x (order)^2
int grid_nDirs
number of grid directions
float * Uw
beamforming weights; FLAT: nDirs x (upscaleOrder+1)^2
int interp_nDirs
number of interpolation directions
float * interp_dirs_rad
interpolation directions, in radians; FLAT: interp_nDirs x 2
float * ssxyz
beamformer velocity signals; FLAT: 3 x DIRASS_FRAME_SIZE
float * Y_up
real SH weights for upscaling; FLAT: (upscaleOrder+1)^2 x grid_nDirs
Main structure for dirass.
float pmapAvgCoeff
averaging coefficient for the intensity vector per grid direction
DIRASS_REASS_MODES DirAssMode
see DIRASS_REASS_MODES enum
int inputOrder
Current input/analysis order.
float * pmap
grid_nDirs x 1
float fs
host sampling rate
float Wz12_hpf[MAX_NUM_INPUT_SH_SIGNALS][2]
delayed elements used in the HPF
int upscaleOrder
Current target upscale order.
STATIC_BEAM_TYPES beamType
beamformer type mode
float SHframe_upTD[MAX_NUM_DISPLAY_SH_SIGNALS][DIRASS_FRAME_SIZE]
Upscaled SH signals.
float progressBar0_1
Current (re)initialisation progress, between [0..1].
float pmap_grid_maxVal
maximum value in pmap
float * pmap_grid[NUM_DISP_SLOTS]
dirass interpolated to grid; interp_nDirs x 1
float Wz12_lpf[MAX_NUM_INPUT_SH_SIGNALS][2]
delayed elements used in the LPF
int dispSlotIdx
current display slot index
int new_upscaleOrder
New target upscale order.
float pmap_grid_minVal
minimum value in pmap
int pmapReady
0: image generation not started yet, 1: image is ready for plotting
float SHframeTD[MAX_NUM_INPUT_SH_SIGNALS][DIRASS_FRAME_SIZE]
Input SH signals.
ASPECT_RATIO_OPTIONS aspectRatioOption
aspect ratio option
int new_inputOrder
New input/analysis order.
CODEC_STATUS codecStatus
see CODEC_STATUS
DIRASS_GRID_OPTIONS gridOption
grid option
float minFreq_hz
minimum frequency to include in pmap generation, Hz
int FIFO_idx
FIFO buffer index.
int dispWidth
number of interpolation points on the horizontal
PROC_STATUS procStatus
see PROC_STATUS
float maxFreq_hz
maximum frequency to include in pmap generation, Hz
int recalcPmap
set this to 1 to generate a new image
dirass_codecPars * pars
codec parameters
NORM_TYPES norm
Ambisonic normalisation convention (see NORM_TYPES)
char * progressBarText
Current (re)initialisation step, string.
CH_ORDER chOrdering
Ambisonic channel order convention (see CH_ORDER)
HFOV_OPTIONS HFOVoption
horizontal field-of-view option
float inFIFO[MAX_NUM_INPUT_SH_SIGNALS][DIRASS_FRAME_SIZE]
FIFO buffer.