41 *phBin = (
void*)pData;
114 if(pData->
hSTFT !=NULL)
146 pData->
fs = sampleRate;
196 const float *
const * inputs,
197 float*
const*
const outputs,
204 int ch, ear, i, band, nSources;
205 float Rxyz[3][3], hypotxy;
217 for(i=0; i <
SAF_MIN(nSources,nInputs); i++)
219 for(; i<nSources; i++)
223 for (ch = 0; ch < nSources; ch++) {
224 if(fabsf(pData->
src_gains[ch] - 1.f) > 1e-6f)
234 for(i=0; i<nSources; i++){
240 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, nSources, 3, 3, 1.0f,
242 (
float*)Rxyz, 3, 0.0f,
244 for(i=0; i<nSources; i++){
254 for (ch = 0; ch < nSources; ch++) {
265 for (ear = 0; ear <
NUM_EARS; ear++)
278 for (; ch < nOutputs; ch++)
282 for (ch=0; ch < nOutputs; ch++)
304 if(newAzi_deg>180.0f)
305 newAzi_deg = -360.0f + newAzi_deg;
306 newAzi_deg =
SAF_MAX(newAzi_deg, -180.0f);
307 newAzi_deg =
SAF_MIN(newAzi_deg, 180.0f);
318 newElev_deg =
SAF_MAX(newElev_deg, -90.0f);
319 newElev_deg =
SAF_MIN(newElev_deg, 90.0f);
473 for(
int i=0; i<pData->
nSources; i++)
#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
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_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.
int binauraliser_getMaxNumSources()
Returns the maximum number of input sources supported by binauraliser.
int binauraliser_getNTriangles(void *const hBin)
Returns the number of triangular groupings (faces) returned by the Convex Hull.
void binauraliser_setSofaFilePath(void *const hBin, const char *path)
Sets the file path for a .sofa file, in order to employ a custom HRIR set for the decoding.
void binauraliser_refreshSettings(void *const hBin)
Sets all intialisation flags to 1; re-initialising all settings/variables as binauraliser is currentl...
char * binauraliser_getSofaFilePath(void *const hBin)
Returns the file path for a .sofa file.
void binauraliser_setEnableHRIRsDiffuseEQ(void *const hBin, int newState)
Enable (1) or disable (0) the diffuse-field EQ applied to the HRTFs.
int binauraliser_getFlipPitch(void *const hBin)
Returns a flag as to whether to "flip" the sign of the current 'pitch' angle (0: do not flip sign,...
int binauraliser_getNDirs(void *const hBin)
Returns the number of directions in the currently used HRIR set.
void binauraliser_init(void *const hBin, int sampleRate)
Initialises an instance of binauraliser with default settings.
void binauraliser_destroy(void **const phBin)
Destroys an instance of the binauraliser.
int binauraliser_getUseDefaultHRIRsflag(void *const hBin)
Returns the value of a flag used to dictate whether the default HRIRs in the Spatial_Audio_Framework ...
void binauraliser_setRoll(void *const hBin, float newRoll)
Sets the 'roll' rotation angle, in DEGREES.
void binauraliser_initCodec(void *const hBin)
Intialises the codec variables, based on current global/user parameters.
int binauraliser_getFlipRoll(void *const hBin)
Returns a flag as to whether to "flip" the sign of the current 'roll' angle (0: do not flip sign,...
void binauraliser_setSourceAzi_deg(void *const hBin, int index, float newAzi_deg)
Sets the panning azimuth for a specific channel index, in DEGREES.
void binauraliser_setPitch(void *const hBin, float newPitch)
Sets the 'pitch' rotation angle, in DEGREES.
void binauraliser_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.
void binauraliser_setSourceSolo(void *const hAmbi, int srcIdx)
Set a source to solo.
int binauraliser_getEnableHRIRsDiffuseEQ(void *const hBin)
Returns the flag indicating whether the diffuse-field EQ applied to the HRTFs is enabled (1) or disab...
void binauraliser_setSourceElev_deg(void *const hBin, int index, float newElev_deg)
Sets the panning elevation for a specific channel index, in DEGREES.
float binauraliser_getProgressBar0_1(void *const hBin)
(Optional) Returns current intialisation/processing progress, between 0..1
CODEC_STATUS binauraliser_getCodecStatus(void *const hBin)
Returns current codec status codec status (see CODEC_STATUS enum)
void binauraliser_create(void **const phBin)
Creates an instance of the binauraliser.
int binauraliser_getRPYflag(void *const hBin)
Returns a flag as to whether to use "yaw-pitch-roll" (0) or "roll-pitch-yaw" (1) rotation order.
float binauraliser_getPitch(void *const hBin)
Returns the 'pitch' rotation angle, in DEGREES.
int binauraliser_getFrameSize(void)
Returns the processing framesize (i.e., number of samples processed with every _process() call )
int binauraliser_getEnableRotation(void *const hBin)
Returns the flag value which dictates whether to enable/disable sound-field rotation (0: disabled,...
void binauraliser_setRPYflag(void *const hBin, int newState)
Sets a flag as to whether to use "yaw-pitch-roll" (0) or "roll-pitch-yaw" (1) rotation order.
int binauraliser_getNumEars(void)
Returns the number of ears possessed by the average homo sapien.
void binauraliser_getProgressBarText(void *const hBin, char *text)
(Optional) Returns current intialisation/processing progress text
int binauraliser_getDAWsamplerate(void *const hBin)
Returns the DAW/Host sample rate.
int binauraliser_getHRIRsamplerate(void *const hBin)
Returns the HRIR sample rate.
float binauraliser_getYaw(void *const hBin)
Returns the 'yaw' rotation angle, in DEGREES.
float binauraliser_getSourceElev_deg(void *const hBin, int index)
Returns the source elevation for a given index, in DEGREES.
void binauraliser_setFlipPitch(void *const hBin, int newState)
Sets a flag as to whether to "flip" the sign of the current 'pitch' angle (0: do not flip sign,...
void binauraliser_setEnableRotation(void *const hBin, int newState)
Sets the flag to enable/disable (1 or 0) rotation.
void binauraliser_setFlipYaw(void *const hBin, int newState)
Sets a flag as to whether to "flip" the sign of the current 'yaw' angle (0: do not flip sign,...
int binauraliser_getProcessingDelay()
Returns the processing delay in samples (may be used for delay compensation purposes)
void binauraliser_setYaw(void *const hBin, float newYaw)
Sets the 'yaw' rotation angle, in DEGREES.
void binauraliser_setInputConfigPreset(void *const hBin, int newPresetID)
Loads an input preset (see SOURCE_CONFIG_PRESETS enum)
void binauraliser_setInterpMode(void *const hBin, int newMode)
NOT IMPLEMENTED YET.
void binauraliser_setUseDefaultHRIRsflag(void *const hBin, int newState)
Sets flag to dictate whether the default HRIRs in the Spatial_Audio_Framework should be used (1),...
void binauraliser_setUnSolo(void *const hAmbi)
Unsolo / unmute all sources.
float binauraliser_getHRIRElev_deg(void *const hBin, int index)
Returns the HRIR/HRTF elevation for a given index, in DEGREES.
float binauraliser_getSourceAzi_deg(void *const hBin, int index)
Returns the source azimuth for a given index, in DEGREES.
float binauraliser_getRoll(void *const hBin)
Returns the 'roll' rotation angle, in DEGREES.
void binauraliser_setFlipRoll(void *const hBin, int newState)
Sets a flag as to whether to "flip" the sign of the current 'roll' angle (0: do not flip sign,...
int binauraliser_getFlipYaw(void *const hBin)
Returns a flag as to whether to "flip" the sign of the current 'yaw' angle (0: do not flip sign,...
int binauraliser_getInterpMode(void *const hBin)
NOT IMPLEMENTED YET.
int binauraliser_getHRIRlength(void *const hBin)
Returns the length of HRIRs in time-domain samples.
float binauraliser_getHRIRAzi_deg(void *const hBin, int index)
Returns the HRIR/HRTF azimuth for a given index, in DEGREES.
void binauraliser_setSourceGain(void *const hAmbi, int srcIdx, float newGain)
Sets gain factor for an input source.
void binauraliser_setNumSources(void *const hBin, int new_nSources)
Sets the number of input channels/sources to binauralise.
int binauraliser_getNumSources(void *const hBin)
Returns the number of inputs/sources in the current layout.
@ 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.
Convolves input audio (up to 64 channels) with interpolated HRTFs in the time-frequency domain.
#define BINAURALISER_FRAME_SIZE
Framesize, in time-domain samples.
#define SAF_CLAMP(a, min, max)
Ensures value "a" is clamped between the "min" and "max" values.
#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.
#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 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 * realloc1d(void *ptr, size_t dim1_data_size)
1-D realloc (same as realloc, 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.
float ** inputFrameTD
time-domain input frame; MAX_NUM_INPUTS x BINAURALISER_FRAME_SIZE
int hrir_runtime_len
length of the HRIRs being used for processing (after any resampling), in samples
int enableRotation
1: enable rotation, 0: disable
int fs
Host sampling rate, in Hz.
float roll
roll (Euler) rotation angle, in degrees
PROC_STATUS procStatus
see PROC_STATUS
int bFlipYaw
flag to flip the sign of the yaw rotation angle
int recalc_M_rotFLAG
1: re-calculate the rotation matrix, 0: do not
float_complex *** outputframeTF
time-frequency domain input frame; HYBRID_BANDS x NUM_EARS x TIME_SLOTS
int nSources
Current number of input/source signals.
float * hrtf_vbap_gtableComp
N_hrtf_vbap_gtable x 3.
int N_hrir_dirs
number of HRIR directions in the current sofa file
float src_dirs_rot_xyz[MAX_NUM_INPUTS][3]
Intermediate rotated source directions, as unit-length Cartesian coordinates.
float * hrirs
time domain HRIRs; FLAT: N_hrir_dirs x NUM_EARS x hrir_len
float src_dirs_rot_deg[MAX_NUM_INPUTS][2]
Intermediate rotated source directions, in degrees.
float_complex * hrtf_fb
hrtf filterbank coefficients; nBands x nCH x N_hrirs
int N_hrtf_vbap_gtable
Number of interpolation weights/directions.
float progressBar0_1
Current (re)initialisation progress, between [0..1].
float_complex hrtf_interp[MAX_NUM_INPUTS][HYBRID_BANDS][NUM_EARS]
Interpolated HRTFs.
int hrir_runtime_fs
sampling rate of the HRIRs being used for processing (after any resampling)
float * hrir_dirs_deg
directions of the HRIRs in degrees [azi elev]; FLAT: N_hrir_dirs x 2
int reInitHRTFsAndGainTables
1: reinitialise the HRTFs and interpolation tables, 0: do not
float pitch
pitch (Euler) rotation angle, in degrees
float * weights
Integration weights for the HRIR measurement grid.
int useRollPitchYawFlag
rotation order flag, 1: r-p-y, 0: y-p-r
float src_gains[MAX_NUM_INPUTS]
Gains applied per source.
float src_dirs_xyz[MAX_NUM_INPUTS][3]
Intermediate source directions, as unit-length Cartesian coordinates
float_complex *** inputframeTF
time-frequency domain input frame; HYBRID_BANDS x MAX_NUM_INPUTS x TIME_SLOTS
float * itds_s
interaural-time differences for each HRIR (in seconds); nBands x 1
int * hrtf_vbap_gtableIdx
N_hrtf_vbap_gtable x 3.
int hrir_loaded_len
length of the loaded HRIRs, in samples
CODEC_STATUS codecStatus
see CODEC_STATUS
char * progressBarText
Current (re)initialisation step, string.
void * hSTFT
afSTFT handle
float src_dirs_deg[MAX_NUM_INPUTS][2]
Current source/panning directions, in degrees.
float * hrtf_fb_mag
magnitudes of the hrtf filterbank coefficients; nBands x nCH x N_hrirs
int new_nSources
New number of input/source signals (current value will be replaced by this after next re-init)
int enableHRIRsDiffuseEQ
flag to diffuse-field equalisation to the currently loaded HRTFs
float yaw
yaw (Euler) rotation angle, in degrees
int recalc_hrtf_interpFLAG[MAX_NUM_INPUTS]
1: re-calculate/interpolate the HRTF, 0: do not
int hrir_loaded_fs
sampling rate of the loaded HRIRs
int useDefaultHRIRsFLAG
1: use default HRIRs in database, 0: use those from SOFA file
int bFlipRoll
flag to flip the sign of the roll rotation angle
char * sofa_filepath
absolute/relevative file path for a sofa file
int nTriangles
Number of triangles in the convex hull of the spherical arrangement of HRIR directions/points.
int bFlipPitch
flag to flip the sign of the pitch rotation angle
INTERP_MODES interpMode
see INTERP_MODES
float ** outframeTD
time-domain output frame; NUM_EARS x BINAURALISER_FRAME_SIZE
float freqVector[HYBRID_BANDS]
Frequency vector (filterbank centre frequencies)