SAF
Loading...
Searching...
No Matches
saf_hrir

Files

file  saf_default_hrirs.c
 Default HRIR data.
 
file  saf_hrir.c
 Public source for the HRIR/HRTF processing module (SAF_HRIR_MODULE)
 
file  saf_hrir.h
 Main header for the HRIR/HRTF processing module (SAF_HRIR_MODULE)
 

Functions

void estimateITDs (float *hrirs, int N_dirs, int hrir_len, int fs, float *itds_s)
 Estimates the interaural time-differences (ITDs) for each HRIR based on the cross-correlation between the left and right channels, which are first low-pass filtered at 750Hz.
 
void HRIRs2HRTFs_afSTFT (float *hrirs, int N_dirs, int hrir_len, int hopsize, int LDmode, int hybridmode, float_complex *hrtf_fb)
 Passes zero padded HRIRs through the afSTFT filterbank.
 
void HRIRs2HRTFs_qmf (float *hrirs, int N_dirs, int hrir_len, int hopsize, int hybridmode, float_complex *hrtf_fb)
 Passes zero padded HRIRs through the qmf filterbank.
 
void HRIRs2HRTFs (float *hrirs, int N_dirs, int hrir_len, int fftSize, float_complex *hrtfs)
 Converts HRIRs to HRTFs for a given FFT size.
 
void diffuseFieldEqualiseHRTFs (int N_dirs, float *itds_s, float *centreFreq, int N_bands, float *weights, int applyEQ, int applyPhase, float_complex *hrtfs)
 Applies pre-processing to a set of HRTFs, which can either be diffuse-field EQ of an (optionally weighted) average of all HRTFs (CTF), phase simplification based on ITDs, or both.
 
void interpHRTFs (float_complex *hrtfs, float *itds, float *freqVector, float *interp_table, int N_hrtf_dirs, int N_bands, int N_interp_dirs, float_complex *hrtf_interp)
 Interpolates a set of HRTFs based on a specified interpolation table.
 
void binauralDiffuseCoherence (float_complex *hrtfs, float *itds, float *freqVector, int N_hrtf_dirs, int N_bands, float *HRTFcoh)
 Computes the binaural diffuse coherence per frequency for a given HRTF set, as described in [1].
 
void resampleHRIRs (float *hrirs_in, int hrirs_N_dirs, int hrirs_in_len, int hrirs_in_fs, int hrirs_out_fs, int padToNextPow2, float **hrirs_out, int *hrirs_out_len)
 Resamples a set of HRIRs from its original samplerate to a new samplerate.
 

Variables

const float __default_hrirs [836][2][256]
 The default HRIR data for SAF.
 
const float __default_hrir_dirs_deg [836][2]
 The measurement directions used for the default HRIR dataset.
 
const int __default_N_hrir_dirs
 The number of directions/measurements in the default HRIR dataset.
 
const int __default_hrir_len
 The length of the filters, in samples, for the default HRIR dataset.
 
const int __default_hrir_fs
 The samplerate used to measure the default HRIR filters

 

Detailed Description

HRIR/HRTF processing module

Function Documentation

◆ binauralDiffuseCoherence()

void binauralDiffuseCoherence ( float_complex * hrtfs,
float * itds,
float * freqVector,
int N_hrtf_dirs,
int N_bands,
float * HRTFcoh )

Computes the binaural diffuse coherence per frequency for a given HRTF set, as described in [1].

Parameters
[in]hrtfsHRTFs as filterbank coeffs FLAT: N_bands x NUM_EARS x N_hrtf_dirs
[in]itdsThe inter-aural time difference (ITD) for each HRIR; N_hrtf_dirs x 1
[in]freqVectorFrequency vector; N_bands x 1
[in]N_hrtf_dirsNumber of HRTF directions
[in]N_bandsNumber of frequency bands
[out]HRTFcohBinaural coherence per frequency; N_bands x 1
See also
[1] A. Politis, "Diffuse-field coherence of sensors with arbitrary directional responses," arXiv preprint arXiv:1608.07713,2016.

Definition at line 322 of file saf_hrir.c.

◆ diffuseFieldEqualiseHRTFs()

void diffuseFieldEqualiseHRTFs ( int N_dirs,
float * itds_s,
float * centreFreq,
int N_bands,
float * weights,
int applyEQ,
int applyPhase,
float_complex * hrtfs )

Applies pre-processing to a set of HRTFs, which can either be diffuse-field EQ of an (optionally weighted) average of all HRTFs (CTF), phase simplification based on ITDs, or both.

Note
'weights' (if used) should sum to 4pi. 'itds_s' and 'centreFreq' are only required if applyPhase==1, so can be set to NULL otherwise.
Warning
This function is NOT suitable for binaural room impulse responses (BRIRs)!
Parameters
[in]N_dirsNumber of HRTFs
[in]itds_sHRIR ITDs (set to NULL if not needed); N_dirs x 1
[in]centreFreqFrequency vector (set to NULL if not needed); N_bands x 1
[in]N_bandsNumber of frequency bands/bins
[in]weightsGrid weights (set to NULL if not available); N_dirs x 1
[in]applyEQDiffuse-field EQ / CTF; 0:disabled, 1:enabled
[in]applyPhasePhase simplification; 0:disabled, 1:enabled
[in,out]hrtfsThe HRTFs; FLAT: N_bands x NUM_EARS x N_dirs

Definition at line 173 of file saf_hrir.c.

◆ estimateITDs()

void estimateITDs ( float * hrirs,
int N_dirs,
int hrir_len,
int fs,
float * itds_s )

Estimates the interaural time-differences (ITDs) for each HRIR based on the cross-correlation between the left and right channels, which are first low-pass filtered at 750Hz.

Parameters
[in]hrirsHRIRs; FLAT: N_dirs x NUM_EARS x hrir_len
[in]N_dirsNumber of HRIRs
[in]hrir_lenLength of the HRIRs in samples
[in]fsSampling rate of the HRIRs
[out]itds_sITDs in seconds; N_dirs x 1

Definition at line 40 of file saf_hrir.c.

◆ HRIRs2HRTFs()

void HRIRs2HRTFs ( float * hrirs,
int N_dirs,
int hrir_len,
int fftSize,
float_complex * hrtfs )

Converts HRIRs to HRTFs for a given FFT size.

Note
If the HRIRs are shorter than the FFT size (hrir_len<fftSize), then the HRIRs are zero-padded. If they are longer, then they are truncated.
Parameters
[in]hrirsHRIRs; FLAT: N_dirs x NUM_EARS x hrir_len
[in]N_dirsNumber of HRIRs
[in]hrir_lenLength of the HRIRs in samples
[in]fftSizeFFT size
[out]hrtfsHRTFs; FLAT: (fftSize/2+1) x NUM_EARS x N_dirs

Definition at line 139 of file saf_hrir.c.

◆ HRIRs2HRTFs_afSTFT()

void HRIRs2HRTFs_afSTFT ( float * hrirs,
int N_dirs,
int hrir_len,
int hopsize,
int LDmode,
int hybridmode,
float_complex * hrtf_fb )

Passes zero padded HRIRs through the afSTFT filterbank.

The filterbank coefficients are then normalised with the energy of an impulse, which is centered at approximately the beginning of the median HRIR peak.

Warning
This function is NOT suitable for binaural room impulse responses (BRIRs)!
Parameters
[in]hrirsHRIRs; FLAT: N_dirs x NUM_EARS x hrir_len
[in]N_dirsNumber of HRIRs
[in]hrir_lenLength of the HRIRs in samples
[in]hopsizeHop size in samples
[in]LDmodeLow-Delay mode, 0:disabled, 1:enabled
[in]hybridmodeHybrid-filtering, 0:disabled, 1:enabled
[out]hrtf_fbHRTFs as filterbank coeffs; FLAT: (hybrid ? hopsize+5 : hopsize+1) x NUM_EARS x N_dirs

Definition at line 110 of file saf_hrir.c.

◆ HRIRs2HRTFs_qmf()

void HRIRs2HRTFs_qmf ( float * hrirs,
int N_dirs,
int hrir_len,
int hopsize,
int hybridmode,
float_complex * hrtf_fb )

Passes zero padded HRIRs through the qmf filterbank.

The filterbank coefficients are then normalised with the energy of an impulse, which is centered at approximately the beginning of the median HRIR peak.

Warning
This function is NOT suitable for binaural room impulse responses (BRIRs)!
Parameters
[in]hrirsHRIRs; FLAT: N_dirs x NUM_EARS x hrir_len
[in]N_dirsNumber of HRIRs
[in]hrir_lenLength of the HRIRs in samples
[in]hopsizeHop size in samples
[in]hybridmode0:disabled, 1:enabled
[out]hrtf_fbHRTFs as filterbank coeffs; FLAT: (hybrid ? hopsize+7 : hopsize+1) x NUM_EARS x N_dirs

Definition at line 125 of file saf_hrir.c.

◆ interpHRTFs()

void interpHRTFs ( float_complex * hrtfs,
float * itds,
float * freqVector,
float * interp_table,
int N_hrtf_dirs,
int N_bands,
int N_interp_dirs,
float_complex * hrtf_interp )

Interpolates a set of HRTFs based on a specified interpolation table.

Note
For 'interp_table' you can use e.g. VBAPgainTable2InterpTable() to take a conventional energy-normalised VBAP gain table, and convert it to an amplitude-normalised interpolation table. Note: amplitude-normalised VBAP gains are the same as triangular interpolation weights.
If itds!=NULL && freqVector!=NULL, then the interpolation is performed by applying interpolation gains to the HRTF magnitudes and HRIR inter- aural time differences (ITDs) separately. The inter-aural phase differences (IPDs) are then reintroduced for each frequency band. If itds==NULL || freqVector==NULL then the interpolatation is applied directly on the complex spectra.
Warning
This function is NOT suitable for binaural room impulse responses (BRIRs)!
Parameters
[in]hrtfsHRTFs as filterbank coeffs; FLAT: N_bands x NUM_EARS x N_hrtf_dirs
[in]itdsThe inter-aural time difference (ITD) for each HRIR (set to NULL if you do not want phase simplication to be applied); N_hrtf_dirs x 1
[in]freqVectorFrequency vector (set to NULL if you do not want phase simplication to be applied); N_bands x 1
[in]interp_tableAmplitude-Normalised VBAP gain table; FLAT: N_interp_dirs x N_hrtf_dirs
[in]N_hrtf_dirsNumber of HRTF directions
[in]N_bandsNumber of frequency bands
[in]N_interp_dirsNumber of interpolated hrtf positions
[out]hrtf_interpinterpolated HRTFs; FLAT: N_bands x NUM_EARS x N_interp_dirs

Definition at line 241 of file saf_hrir.c.

◆ resampleHRIRs()

void resampleHRIRs ( float * hrirs_in,
int hrirs_N_dirs,
int hrirs_in_len,
int hrirs_in_fs,
int hrirs_out_fs,
int padToNextPow2,
float ** hrirs_out,
int * hrirs_out_len )

Resamples a set of HRIRs from its original samplerate to a new samplerate.

Note
The included speex_resampler.h is used by default. If SAF_USE_INTEL_IPP is defined, then the IPP resampler is employed instead.
Parameters
[in]hrirs_inInput HRIRs; FLAT: hrirs_N_dirs x NUM_EARS x hrirs_in_len
[in]hrirs_N_dirsNumber of HRIRs
[in]hrirs_in_lenLength of input HRIRs, in samples
[in]hrirs_in_fsOriginal sampling rate, in Hz
[in]hrirs_out_fsNew sampling rate, in Hz
[in]padToNextPow21: length of output HRIRs padded to next 2^x, 0: no
[out]hrirs_outResampled HRIRs; FLAT: hrirs_N_dirs x NUM_EARS x hrirs_out_len
[out]hrirs_out_len(&) New HRIR length

Definition at line 365 of file saf_hrir.c.

Variable Documentation

◆ __default_hrir_dirs_deg

const float __default_hrir_dirs_deg[836][2]
extern

The measurement directions used for the default HRIR dataset.

Definition at line 871 of file saf_default_hrirs.c.

◆ __default_hrir_fs

const int __default_hrir_fs
extern

The samplerate used to measure the default HRIR filters

Definition at line 1714 of file saf_default_hrirs.c.

◆ __default_hrir_len

const int __default_hrir_len
extern

The length of the filters, in samples, for the default HRIR dataset.

Definition at line 1712 of file saf_default_hrirs.c.

◆ __default_hrirs

const float __default_hrirs[836][2][256]
extern

The default HRIR data for SAF.

Definition at line 32 of file saf_default_hrirs.c.

◆ __default_N_hrir_dirs

const int __default_N_hrir_dirs
extern

The number of directions/measurements in the default HRIR dataset.

Definition at line 1710 of file saf_default_hrirs.c.