SAF
saf_hrir.h
Go to the documentation of this file.
1 /*
2  * Copyright 2016-2018 Leo McCormack
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10  * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14  * PERFORMANCE OF THIS SOFTWARE.
15  */
16 
33 #ifndef __SAF_HRIR_H_INCLUDED__
34 #define __SAF_HRIR_H_INCLUDED__
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif /* __cplusplus */
39 
40 #include "../saf_utilities/saf_utility_complex.h"
41 
42 /* ========================================================================== */
43 /* Default HRIRs */
44 /* ========================================================================== */
45 /* The default HRIR dataset is a Genelec Aural ID of a KEMAR Dummy Head (@48kHz)
46  * Kindly provided by Aki Mäkivirta and Jaan Johansson */
47 
49 extern const float __default_hrirs[836][2][256];
50 
52 extern const float __default_hrir_dirs_deg[836][2];
53 
55 extern const int __default_N_hrir_dirs;
56 
58 extern const int __default_hrir_len;
59 
61 extern const int __default_hrir_fs;
62 
63 
64 /* ========================================================================== */
65 /* Main Functions */
66 /* ========================================================================== */
67 
79 void estimateITDs(/* Input Arguments */
80  float* hrirs,
81  int N_dirs,
82  int hrir_len,
83  int fs,
84  /* Output Arguments */
85  float* itds_s);
86 
106 void HRIRs2HRTFs_afSTFT(/* Input Arguments */
107  float* hrirs,
108  int N_dirs,
109  int hrir_len,
110  int hopsize,
111  int LDmode,
112  int hybridmode,
113  /* Output Arguments */
114  float_complex* hrtf_fb);
115 
135 void HRIRs2HRTFs_qmf(/* Input Arguments */
136  float* hrirs,
137  int N_dirs,
138  int hrir_len,
139  int hopsize,
140  int hybridmode,
141  /* Output Arguments */
142  float_complex* hrtf_fb);
143 
156 void HRIRs2HRTFs(/* Input Arguments */
157  float* hrirs,
158  int N_dirs,
159  int hrir_len,
160  int fftSize,
161  /* Output Arguments */
162  float_complex* hrtfs);
163 
185 void diffuseFieldEqualiseHRTFs(/* Input Arguments */
186  int N_dirs,
187  float* itds_s,
188  float* centreFreq,
189  int N_bands,
190  float* weights,
191  int applyEQ,
192  int applyPhase,
193  /* Input/Output Arguments */
194  float_complex* hrtfs);
195 
227 void interpHRTFs(/* Input Arguments */
228  float_complex* hrtfs,
229  float* itds,
230  float* freqVector,
231  float* interp_table,
232  int N_hrtf_dirs,
233  int N_bands,
234  int N_interp_dirs,
235  /* Output Arguments */
236  float_complex* hrtf_interp);
237 
254 void binauralDiffuseCoherence(/* Input Arguments */
255  float_complex* hrtfs,
256  float* itds,
257  float* freqVector,
258  int N_hrtf_dirs,
259  int N_bands,
260  /* Output Arguments */
261  float* HRTFcoh);
262 
280 void resampleHRIRs(/* Input Arguments */
281  float* hrirs_in,
282  int hrirs_N_dirs,
283  int hrirs_in_len,
284  int hrirs_in_fs,
285  int hrirs_out_fs,
286  int padToNextPow2,
287  /* Output Arguments */
288  float** hrirs_out,
289  int* hrirs_out_len);
290 
291 
292 #ifdef __cplusplus
293 } /* extern "C" */
294 #endif /* __cplusplus */
295 
296 #endif /* __SAF_HRIR_H_INCLUDED__ */
297  /* doxygen addtogroup HRIR */
const int __default_N_hrir_dirs
The number of directions/measurements in the default HRIR dataset.
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_hrir_len
The length of the filters, in samples, for the default HRIR dataset.
void HRIRs2HRTFs(float *hrirs, int N_dirs, int hrir_len, int fftSize, float_complex *hrtfs)
Converts HRIRs to HRTFs for a given FFT size.
Definition: saf_hrir.c:140
const int __default_hrir_fs
The samplerate used to measure the default HRIR filters
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 weig...
Definition: saf_hrir.c:174
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.
Definition: saf_hrir.c:366
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.
Definition: saf_hrir.c:242
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].
Definition: saf_hrir.c:323
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.
Definition: saf_hrir.c:126
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...
Definition: saf_hrir.c:41
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.
Definition: saf_hrir.c:111