47 *phBin = (
void*)pData;
117 for(
int ear = 0; ear <
NUM_EARS; ear++) {
118 pData->
a_dvf[ch][ear][0] = 1.f;
153 if(pData->
hSTFT !=NULL)
177 void *
const hBin,
int sampleRate
229 const float *
const * inputs,
230 float*
const*
const outputs,
237 int ch, ear, i, band, nSources, enableRotation;
238 float hypotxy, headRadiusRecip, fs, ffThresh, rho;
240 float alphaLR[2] = { 0.0, 0.0 };
247 fs = (float)pData->
fs;
254 for (i = 0; i <
SAF_MIN(nSources, nInputs); i++)
256 for (; i < nSources; i++)
260 for (ch = 0; ch < nSources; ch++) {
261 if(fabsf(pData->
src_gains[ch] - 1.f) > 1e-6f)
271 for(i = 0; i < nSources; i++){
277 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, nSources, 3, 3, 1.0f,
279 (
float*)Rxyz, 3, 0.0f,
281 for (i = 0; i < nSources; i++) {
293 for (ch = 0; ch < nSources; ch++) {
296 if (enableRotation) {
328 float_complex dvfScale;
330 for (ear = 0; ear <
NUM_EARS; ear++) {
347 for (ear = 0; ear <
NUM_EARS; ear++)
363 for (; ch < nOutputs; ch++)
367 for (ch=0; ch < nOutputs; ch++)
#define MAX_NUM_INPUTS
Maximum number of input channels supported.
#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.
@ 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_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_destroy(void **const phSTFT)
Destroys an instance of afSTFT.
#define TIME_SLOTS
Number of STFT timeslots.
#define HYBRID_BANDS
Number of frequency bands.
void binauraliser_init(void *const hBin, int samplerate)
Initialises an instance of binauraliser with default settings.
@ INTERP_TRI_PS
Triangular interpolation (with phase-simplification)
void binauraliser_initHRTFsAndGainTables(void *const hBin)
Initialise the HRTFs: either loading the default set or loading from a SOFA file; and then generate a...
void binauraliser_setCodecStatus(void *const hBin, CODEC_STATUS newStatus)
Sets codec status (see CODEC_STATUS enum)
void binauraliser_loadPreset(SOURCE_CONFIG_PRESETS preset, float dirs_deg[MAX_NUM_INPUTS][2], int *newNCH, int *nDims)
Returns the source directions for a specified source config preset.
void binauraliser_initTFT(void *const hBin)
Initialise the filterbank used by binauraliser.
void binauraliser_interpHRTFs(void *const hBin, INTERP_MODES mode, float azimuth_deg, float elevation_deg, float_complex h_intrp[HYBRID_BANDS][NUM_EARS])
Interpolates between (up to) 3 HRTFs via amplitude-normalised VBAP gains.
#define BINAURALISER_FRAME_SIZE
Framesize, in time-domain samples.
void binauraliserNF_init(void *const hBin, int sampleRate)
Initialises an instance of binauraliser with default settings.
void binauraliserNF_process(void *const hBin, const float *const *inputs, float *const *const outputs, int nInputs, int nOutputs, int nSamples)
Binauralises the input signals at the user specified directions.
float binauraliserNF_getNearfieldLimit_m(void *const hBin)
Returns the minimum distance possible for near field filter, in METERS.
float binauraliserNF_getSourceDist_m(void *const hBin, int index)
Returns the source elevation for a given index, in METERS.
void binauraliserNF_create(void **const phBin)
Creates an instance of the binauraliser.
void binauraliserNF_destroy(void **const phBin)
Destroys an instance of the binauraliser.
void binauraliserNF_setInputConfigPreset(void *const hBin, int newPresetID)
Loads an input preset (see SOURCE_CONFIG_PRESETS enum)
float binauraliserNF_getFarfieldThresh_m(void *const hBin)
Returns the distance considered to be the far field (beyond which no near field filtering is applied)...
void binauraliserNF_setSourceDist_m(void *const hBin, int index, float newDist_m)
Sets the panning distance for a specific channel index, in METERS.
float binauraliserNF_getFarfieldHeadroom(void *const hBin)
Returns the scaling factor to give the far field threshold headroom (useful for UI range limits)
void binauraliserNF_initCodec(void *const hBin)
Intialises the codec variables, based on current global/user parameters.
void binauraliserNF_resetSourceDistances(void *const hBin)
Resets the source distances to the default far field distance.
Convolves input audio (up to 64 channels) with interpolated HRTFs in the time-frequency domain,...
void doaToIpsiInteraural(float azimuth, float elevation, float *alphaLR, float *betaLR)
Convert a frontal azimuth/elevation to a modified Interaural-Polar coordinate.
#define DEG2RAD(x)
Converts degrees to radians.
#define SAF_MAX(a, b)
Returns the maximum of the two values.
#define NUM_EARS
2 (true for most humans)
void utility_svvcopy(const float *a, const int len, float *c)
Single-precision, vector-vector copy, i.e.
void evalIIRTransferFunctionf(float *b_coeff, float *a_coeff, int nCoeffs, float *freqs, int nFreqs, float fs, int mag2dB, float *magnitude, float *phase_rad)
Computes magnitude and phase response of an IIR filter from its coefficients (floats) at user-specifi...
#define SAF_MIN(a, b)
Returns the minimum of the two values.
void yawPitchRoll2Rzyx(float yaw, float pitch, float roll, int rollPitchYawFLAG, float R[3][3])
Constructs a 3x3 rotation matrix from the Euler angles, using the yaw-pitch-roll (zyx) convention.
void calcDVFCoeffs(float alpha, float rho, float fs, float *b, float *a)
Calculate the Distance Variation Function (DVF) filter coefficients, as described in [1].
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.
#define RAD2DEG(x)
Converts radians to degrees
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 FLATTEN3D(A)
Use this macro when passing a 3-D dynamic multi-dimensional array to memset, memcpy or any other func...
Main structure for binauraliser.
PROC_STATUS procStatus
see PROC_STATUS
float progressBar0_1
Current (re)initialisation progress, between [0..1].
int reInitHRTFsAndGainTables
1: reinitialise the HRTFs and interpolation tables, 0: do not
CODEC_STATUS codecStatus
see CODEC_STATUS
char * progressBarText
Current (re)initialisation step, string.
Main structure for binauraliserNF.
float * itds_s
interaural-time differences for each HRIR (in seconds); nBands x 1
char * sofa_filepath
absolute/relevative file path for a sofa file
float * hrir_dirs_deg
directions of the HRIRs in degrees [azi elev]; FLAT: N_hrir_dirs x 2
float_complex *** outputframeTF
time-frequency domain input frame; HYBRID_BANDS x NUM_EARS x TIME_SLOTS
float_complex * hrtf_fb
hrtf filterbank coefficients; nBands x nCH x N_hrirs
int N_hrtf_vbap_gtable
Number of interpolation weights/directions.
int bFlipRoll
flag to flip the sign of the roll rotation angle
float pitch
pitch (Euler) rotation angle, in degrees
void * hSTFT
afSTFT handle
int useDefaultHRIRsFLAG
1: use default HRIRs in database, 0: use those from SOFA file
float src_dirs_rot_deg[MAX_NUM_INPUTS][2]
Intermediate rotated source directions, in degrees.
float * hrirs
time domain HRIRs; FLAT: N_hrir_dirs x NUM_EARS x hrir_len
int nTriangles
Number of triangles in the convex hull of the spherical arrangement of HRIR directions/points.
float(* src_dirs_cur)[2]
Pointer to assign to the current HRTF directions being operated on (non/rotated directions switch).
int enableRotation
1: enable rotation, 0: disable
CODEC_STATUS codecStatus
see CODEC_STATUS
float ** inputFrameTD
time-domain input frame; MAX_NUM_INPUTS x BINAURALISER_FRAME_SIZE
PROC_STATUS procStatus
see PROC_STATUS
char * progressBarText
Current (re)initialisation step, string.
float head_radius_recip
Reciprocal of head radius.
float src_dirs_deg[MAX_NUM_INPUTS][2]
Current source/panning directions, in degrees.
float dvfphases[MAX_NUM_INPUTS][NUM_EARS][HYBRID_BANDS]
DVF filter frequency band phases.
float a_dvf[MAX_NUM_INPUTS][NUM_EARS][2]
shelf IIR denominator coefficients for each input, left and right.
float * hrtf_fb_mag
magnitudes of the hrtf filterbank coefficients; nBands x nCH x N_hrirs
int hrir_loaded_len
length of the loaded HRIRs, in samples
float * weights
Integration weights for the HRIR measurement grid.
float farfield_thresh_m
Distance considered to be far field (no near field filtering), meters.
float freqVector[HYBRID_BANDS]
Frequency vector (filterbank centre frequencies)
INTERP_MODES interpMode
see INTERP_MODES
float_complex *** inputframeTF
time-frequency domain input frame; HYBRID_BANDS x MAX_NUM_INPUTS x TIME_SLOTS
int useRollPitchYawFlag
rotation order flag, 1: r-p-y, 0: y-p-r
int fs
Host sampling rate, in Hz.
int recalc_M_rotFLAG
1: re-calculate the rotation matrix, 0: do not
int * hrtf_vbap_gtableIdx
N_hrtf_vbap_gtable x 3.
int hrir_runtime_len
length of the HRIRs being used for processing (after any resampling), in samples
int enableHRIRsDiffuseEQ
flag to diffuse-field equalisation to the currently loaded HRTFs
float src_dirs_rot_xyz[MAX_NUM_INPUTS][3]
Intermediate rotated source directions, as unit-length Cartesian coordinates.
float roll
roll (Euler) rotation angle, in degrees
float dvfmags[MAX_NUM_INPUTS][NUM_EARS][HYBRID_BANDS]
DVF filter frequency band magnitudes.
float yaw
yaw (Euler) rotation angle, in degrees
int hrir_loaded_fs
sampling rate of the loaded HRIRs
float_complex hrtf_interp[MAX_NUM_INPUTS][HYBRID_BANDS][NUM_EARS]
Interpolated HRTFs.
float farfield_headroom
Scale factor applied to farfield_thresh_m when resetting to the far field, and for UI range,...
int nSources
Current number of input/source signals.
int N_hrir_dirs
number of HRIR directions in the current sofa file
float head_radius
Head radius, used calculate normalized source distance meters, def.
int hrir_runtime_fs
sampling rate of the HRIRs being used for processing (after any resampling)
int bFlipPitch
flag to flip the sign of the pitch rotation angle
int new_nSources
New number of input/source signals (current value will be replaced by this after next re-init)
float b_dvf[MAX_NUM_INPUTS][NUM_EARS][2]
shelf IIR numerator coefficients for each input, left and right.
float progressBar0_1
Current (re)initialisation progress, between [0..1].
int bFlipYaw
flag to flip the sign of the yaw rotation angle
float src_dists_m[MAX_NUM_INPUTS]
Source distance, meters.
int recalc_hrtf_interpFLAG[MAX_NUM_INPUTS]
1: re-calculate/interpolate the HRTF, 0: do not
float ** outframeTD
time-domain output frame; NUM_EARS x BINAURALISER_FRAME_SIZE
float nearfield_limit_m
Minimum distance allowed for near-field filtering, from head center, meters, def.
float src_dirs_xyz[MAX_NUM_INPUTS][3]
Intermediate source directions, as unit-length Cartesian coordinates
int reInitHRTFsAndGainTables
1: reinitialise the HRTFs and interpolation tables, 0: do not
float * hrtf_vbap_gtableComp
N_hrtf_vbap_gtable x 3.
float src_gains[MAX_NUM_INPUTS]
Gains applied per source.
int recalc_dvfCoeffFLAG[MAX_NUM_INPUTS]
1: re-calculate the DVF coefficients on change in distance, 0: do not.