SAF
Loading...
Searching...
No Matches
binauraliser_internal.c
Go to the documentation of this file.
1/*
2 * Copyright 2017-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
32
34
36
37/* First 1 source(s) are for mono [0 0], the rest are for a 128 point sphere covering */
39{ { 0.0f, 0.0f},
40 { -120.415474946769f, 69.7642225220975f},
41 { 169.426697678052f, -17.3466306179260f},
42 { 107.629281568279f, -10.0793856720614f},
43 { -59.5674172539630f, -69.7763953095265f},
44 { -107.629493132161f, 10.0801907586439f},
45 { 59.5651193014662f, 69.7750019669784f},
46 { -72.3715136529922f, -10.0909592824967f},
47 { 120.418832045969f, -69.7630732527928f},
48 { 72.3705387467529f, 10.0908849630425f},
49 { 10.5699823270029f, 17.3489915451677f},
50 { -169.426851150349f, 17.3476277272366f},
51 { -30.7728814706980f, 68.2546206344998f},
52 { 101.529181734204f, 18.5653877408229f},
53 { 149.250234431564f, 68.2619792676765f},
54 { 18.9183978612362f, -10.9197242075287f},
55 { 78.4729799557400f, -18.5558892226653f},
56 { -18.9161109968480f, 10.9195275229078f},
57 { -78.4723066816396f, 18.5565169424192f},
58 { -161.085243560336f, -10.9220975953767f},
59 { -101.530063994217f, -18.5648176173994f},
60 { 161.085855454581f, 10.9237834974412f},
61 { 30.7790837424989f, -68.2562996173874f},
62 { -149.255648697558f, -68.2594892022576f},
63 { 56.4638592172755f, 41.2645742763346f},
64 { 46.4626904606488f, 24.5386896277818f},
65 { -123.528839291756f, 41.2565889648213f},
66 { 32.1932295461248f, 38.8027347956192f},
67 { 133.534545076742f, -24.5310453346374f},
68 { -32.1935458377634f, -38.8041545028931f},
69 { -133.533477606995f, 24.5319420428588f},
70 { -147.797881221742f, 38.7980990097138f},
71 { -46.4626630742447f, -24.5400749997299f},
72 { 147.799544204027f, -38.7965984357137f},
73 { -56.4649576930965f, -41.2658215291547f},
74 { 123.530547454259f, -41.2555316199835f},
75 { 84.7385596473317f, 27.3132538556364f},
76 { 27.4072860474693f, 4.67593317316088f},
77 { -95.2612516264878f, 27.3036967398252f},
78 { 10.0607591758466f, 62.2287426217158f},
79 { 152.592710471291f, -4.67007594116539f},
80 { -10.0604693351594f, -62.2317767049329f},
81 { -152.592615409799f, 4.67188744845125f},
82 { -169.918387889403f, 62.2272712110016f},
83 { -27.4047652820400f, -4.67684895484045f},
84 { 169.918493477140f, -62.2246416140826f},
85 { -84.7390238025025f, -27.3120311727342f},
86 { 95.2622793653641f, -27.3027426350066f},
87 { 136.272846725200f, -0.726139068263599f},
88 { -1.05456977390436f, -46.2698051615206f},
89 { -43.7263256019408f, -0.737666959763443f},
90 { -91.0084089447853f, 43.7170295842697f},
91 { -178.936314291048f, 46.2682278552731f},
92 { 91.0100541861312f, -43.7163112498585f},
93 { 178.938490558618f, -46.2666218304286f},
94 { 88.9860902890987f, 43.7285680951606f},
95 { 1.05095788619312f, 46.2682407577363f},
96 { -88.9851906686018f, -43.7278600822776f},
97 { -136.273314433943f, 0.726484363994244f},
98 { 43.7273191822901f, 0.733967099281741f},
99 { 55.2321077221357f, 10.8187456245361f},
100 { 13.0867814081219f, 34.0654299770448f},
101 { -124.767898552651f, 10.8099467408727f},
102 { 71.4751302534919f, 53.7984109774923f},
103 { 166.905549455530f, -34.0625862919868f},
104 { -71.4765158530160f, -53.8002805142714f},
105 { -166.904587570338f, 34.0633858486074f},
106 { -108.515564585463f, 53.7864186881779f},
107 { -13.0869589355977f, -34.0644403811701f},
108 { 108.517274377512f, -53.7853093207457f},
109 { -55.2337689585088f, -10.8200079671294f},
110 { 124.767519417537f, -10.8096092876561f},
111 { -105.493359369733f, -68.1345228940484f},
112 { -111.151973933085f, -5.71277564515985f},
113 { 74.5244447329726f, -68.1205741555505f},
114 { -173.885132403874f, -21.0401043953034f},
115 { -68.8521018079939f, 5.70313885775370f},
116 { 173.885050918764f, 21.0419786777516f},
117 { 68.8513569996117f, -5.70297394874866f},
118 { 6.12041448982713f, -21.0387333986971f},
119 { 111.151515131908f, 5.71357243375474f},
120 { -6.11913621739966f, 21.0397756114589f},
121 { 105.487055344890f, 68.1331981897040f},
122 { -74.5188619841755f, 68.1214716326340f},
123 { 35.2822222163987f, -15.1801841162885f},
124 { -25.1732516880600f, 51.9826514887145f},
125 { -144.722913967824f, -15.1859965048827f},
126 { 108.386507250934f, 33.8824333892584f},
127 { -154.839566662519f, -51.9856067440744f},
128 { -108.385758587361f, -33.8826426573830f},
129 { 154.840828582605f, 51.9884126722963f},
130 { -71.6110721306039f, 33.8714084774643f},
131 { 25.1699762263473f, -51.9843011897216f},
132 { 71.6126173250777f, -33.8705490198003f},
133 { -35.2810594358470f, 15.1763090469469f},
134 { 144.722474074749f, 15.1863112389402f},
135 { -125.277803641269f, -28.5561977838671f},
136 { -146.317489805034f, -30.4888082061806f},
137 { 54.7220842889970f, -28.5463137051834f},
138 { -133.292600372594f, -45.8199818171681f},
139 { -33.6854220654234f, 30.4794807422719f},
140 { 133.295169860873f, 45.8200619710773f},
141 { 33.6830420572493f, -30.4828689919959f},
142 { 46.7098267598019f, -45.8106991831118f},
143 { 146.318736830907f, 30.4889588527258f},
144 { -46.7107531920589f, 45.8077510168776f},
145 { 125.278543193551f, 28.5567151663926f},
146 { -54.7226679373581f, 28.5424675755949f},
147 { -144.402199049652f, 54.7141577397485f},
148 { 112.382216591782f, -28.0100385212576f},
149 { 35.5834085793474f, 54.7193853715013f},
150 { -29.9155874729000f, -19.6471282266303f},
151 { 67.6163420587218f, 28.0211878299760f},
152 { 29.9151078604395f, 19.6461577548916f},
153 { -67.6164804090156f, -28.0221553885221f},
154 { 150.081679085309f, -19.6396879622134f},
155 { -112.381365317985f, 28.0105570315277f},
156 { -150.081127534239f, 19.6412999777121f},
157 { 144.402936805264f, -54.7127597303097f},
158 { -35.5837994140428f, -54.7203576209200f},
159 { 68.5348504928164f, -52.8527273534571f},
160 { -54.8218918027732f, 12.7570858971645f},
161 { -111.464947340552f, -52.8652964226689f},
162 { 164.510735700738f, 34.1892226850382f},
163 { -125.181243085238f, -12.7710900404128f},
164 { -164.510172672569f, -34.1865270720665f},
165 { 125.180742749445f, 12.7714932994183f},
166 { -15.4967238792034f, 34.1855682977571f}};
167
168void binauraliser_setCodecStatus(void* const hBin, CODEC_STATUS newStatus)
169{
170 binauraliser_data *pData = (binauraliser_data*)(hBin);
171 if(newStatus==CODEC_STATUS_NOT_INITIALISED){
172 /* Pause until current initialisation is complete */
174 SAF_SLEEP(10);
175 }
176 pData->codecStatus = newStatus;
177}
178
180(
181 void* const hBin,
182 INTERP_MODES mode,
183 float azimuth_deg,
184 float elevation_deg,
185 float_complex h_intrp[HYBRID_BANDS][NUM_EARS]
186)
187{
188 binauraliser_data *pData = (binauraliser_data*)(hBin);
189 int i, band;
190 int aziIndex, elevIndex, N_azi, idx3d;
191 float_complex ipd;
192 float_complex weights_cmplx[3], hrtf_fb3[NUM_EARS][3];
193 float aziRes, elevRes, weights[3], itds3[3], itdInterp;
194 float magnitudes3[HYBRID_BANDS][3][NUM_EARS], magInterp[HYBRID_BANDS][NUM_EARS];
195 const float_complex calpha = cmplxf(1.0f, 0.0f), cbeta = cmplxf(0.0f, 0.0f);
196
197 /* find closest pre-computed VBAP direction */
198 aziRes = (float)pData->hrtf_vbapTableRes[0];
199 elevRes = (float)pData->hrtf_vbapTableRes[1];
200 N_azi = (int)(360.0f / aziRes + 0.5f) + 1;
201 aziIndex = (int)(matlab_fmodf(azimuth_deg + 180.0f, 360.0f) / aziRes + 0.5f);
202 elevIndex = (int)((elevation_deg + 90.0f) / elevRes + 0.5f);
203 idx3d = elevIndex * N_azi + aziIndex;
204 for (i = 0; i < 3; i++)
205 weights[i] = pData->hrtf_vbap_gtableComp[idx3d*3 + i];
206
207 switch(mode){
208 case INTERP_TRI:
209 for (i = 0; i < 3; i++)
210 weights_cmplx[i] = cmplxf(weights[i], 0.0f);
211 for (band = 0; band < HYBRID_BANDS; band++) {
212 for (i = 0; i < 3; i++){
213 hrtf_fb3[0][i] = pData->hrtf_fb[band*NUM_EARS*(pData->N_hrir_dirs) + 0*(pData->N_hrir_dirs) + pData->hrtf_vbap_gtableIdx[idx3d*3+i]];
214 hrtf_fb3[1][i] = pData->hrtf_fb[band*NUM_EARS*(pData->N_hrir_dirs) + 1*(pData->N_hrir_dirs) + pData->hrtf_vbap_gtableIdx[idx3d*3+i]];
215 }
216 cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, NUM_EARS, 1, 3, &calpha,
217 (float_complex*)hrtf_fb3, 3,
218 (float_complex*)weights_cmplx, 1, &cbeta,
219 (float_complex*)h_intrp[band], 1);
220 }
221 break;
222
223 case INTERP_TRI_PS:
224 /* retrieve the 3 itds and hrtf magnitudes */
225 for (i = 0; i < 3; i++) {
226 itds3[i] = pData->itds_s[pData->hrtf_vbap_gtableIdx[idx3d*3+i]];
227 for (band = 0; band < HYBRID_BANDS; band++) {
228 magnitudes3[band][i][0] = pData->hrtf_fb_mag[band*NUM_EARS*(pData->N_hrir_dirs) + 0*(pData->N_hrir_dirs) + pData->hrtf_vbap_gtableIdx[idx3d*3+i]];
229 magnitudes3[band][i][1] = pData->hrtf_fb_mag[band*NUM_EARS*(pData->N_hrir_dirs) + 1*(pData->N_hrir_dirs) + pData->hrtf_vbap_gtableIdx[idx3d*3+i]];
230 }
231 }
232
233 /* interpolate hrtf magnitudes and itd */
234 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 1, 1, 3, 1.0f,
235 (float*)weights, 3,
236 (float*)itds3, 1, 0.0f,
237 &itdInterp, 1);
238 for (band = 0; band < HYBRID_BANDS; band++) {
239 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 1, 2, 3, 1.0f,
240 (float*)weights, 3,
241 (float*)magnitudes3[band], 2, 0.0f,
242 (float*)magInterp[band], 2);
243 }
244
245 /* introduce interaural phase difference */
246 for (band = 0; band < HYBRID_BANDS; band++) {
247 if(pData->freqVector[band]<1.5e3f)
248 ipd = cmplxf(0.0f, (matlab_fmodf(2.0f*SAF_PI*(pData->freqVector[band]) * itdInterp + SAF_PI, 2.0f*SAF_PI) - SAF_PI)/2.0f);
249 else
250 ipd = cmplxf(0.0f, 0.0f);
251 h_intrp[band][0] = crmulf(cexpf(ipd), magInterp[band][0]);
252 h_intrp[band][1] = crmulf(conjf(cexpf(ipd)), magInterp[band][1]);
253 }
254 break;
255 }
256}
257
259{
260 binauraliser_data *pData = (binauraliser_data*)(hBin);
261 int i;
262 float* hrtf_vbap_gtable;//, *hrir_dirs_rad;
263#ifdef SAF_ENABLE_SOFA_READER_MODULE
266#endif
267
268 strcpy(pData->progressBarText,"Loading HRIRs");
269 pData->progressBar0_1 = 0.2f;
270
271 /* load sofa file or load default hrir data */
272#ifdef SAF_ENABLE_SOFA_READER_MODULE
273 if(!pData->useDefaultHRIRsFLAG && pData->sofa_filepath!=NULL){
274 /* Load SOFA file */
276
277 /* Load defaults instead */
278 if(error!=SAF_SOFA_OK || sofa.nReceivers!=NUM_EARS){
279 pData->useDefaultHRIRsFLAG = 1;
280 saf_print_warning("Unable to load the specified SOFA file, or it contained something other than 2 channels. Using default HRIR data instead.");
281 }
282 else{
283 /* Copy SOFA data */
284 pData->hrir_fs = (int)sofa.DataSamplingRate;
285 pData->hrir_len = sofa.DataLengthIR;
286 pData->N_hrir_dirs = sofa.nSources;
287 pData->hrirs = realloc1d(pData->hrirs, pData->N_hrir_dirs*NUM_EARS*(pData->hrir_len)*sizeof(float));
288 memcpy(pData->hrirs, sofa.DataIR, pData->N_hrir_dirs*NUM_EARS*(pData->hrir_len)*sizeof(float));
289 pData->hrir_dirs_deg = realloc1d(pData->hrir_dirs_deg, pData->N_hrir_dirs*2*sizeof(float));
290 cblas_scopy(pData->N_hrir_dirs, sofa.SourcePosition, 3, pData->hrir_dirs_deg, 2); /* azi */
291 cblas_scopy(pData->N_hrir_dirs, &sofa.SourcePosition[1], 3, &pData->hrir_dirs_deg[1], 2); /* elev */
292 }
293
294 /* Clean-up */
295 saf_sofa_close(&sofa);
296 }
297#else
298 pData->useDefaultHRIRsFLAG = 1; /* Can only load the default HRIR data */
299#endif
300 if(pData->useDefaultHRIRsFLAG){
301 /* Copy default HRIR data */
302 pData->hrir_fs = __default_hrir_fs;
305 pData->hrirs = realloc1d(pData->hrirs, pData->N_hrir_dirs*NUM_EARS*(pData->hrir_len)*sizeof(float));
306 memcpy(pData->hrirs, (float*)__default_hrirs, pData->N_hrir_dirs*NUM_EARS*(pData->hrir_len)*sizeof(float));
307 pData->hrir_dirs_deg = realloc1d(pData->hrir_dirs_deg, pData->N_hrir_dirs*2*sizeof(float));
308 memcpy(pData->hrir_dirs_deg, (float*)__default_hrir_dirs_deg, pData->N_hrir_dirs*2*sizeof(float));
309 }
310
311 /* Resample HRIRs if needed */
312 pData->hrir_orig_fs = pData->hrir_fs;
313 if(pData->hrir_fs!=pData->fs){
314 strcpy(pData->progressBarText, "Resampling HRIRs");
315 pData->progressBar0_1 = 0.3f;
316 float* hrirs_resampled;
317 int hrir_length_resample;
318 resampleHRIRs(pData->hrirs, pData->N_hrir_dirs, pData->hrir_len, pData->hrir_fs, pData->fs, 1, &hrirs_resampled, &hrir_length_resample);
319
320 /* Replace with resampled HRIRs */
321 pData->hrir_fs = pData->fs;
322 pData->hrir_len = hrir_length_resample;
323 pData->hrirs = realloc1d(pData->hrirs, pData->N_hrir_dirs*NUM_EARS*(pData->hrir_len)*sizeof(float));
324 memcpy(pData->hrirs, hrirs_resampled, pData->N_hrir_dirs*NUM_EARS*(pData->hrir_len)*sizeof(float));
325
326 /* Clean-up */
327 free(hrirs_resampled);
328 }
329
330 /* Convert from the 0..360 convention, to -180..180 */
332
333 /* estimate the ITDs for each HRIR */
334 strcpy(pData->progressBarText,"Estimating ITDs");
335 pData->progressBar0_1 = 0.4f;
336 pData->itds_s = realloc1d(pData->itds_s, pData->N_hrir_dirs*sizeof(float));
337 estimateITDs(pData->hrirs, pData->N_hrir_dirs, pData->hrir_len, pData->hrir_fs, pData->itds_s);
338
339 /* generate VBAP gain table */
340 strcpy(pData->progressBarText,"Generating interpolation table");
341 pData->progressBar0_1 = 0.6f;
342 hrtf_vbap_gtable = NULL;
343 pData->hrtf_vbapTableRes[0] = 2;
344 pData->hrtf_vbapTableRes[1] = 5;
345 generateVBAPgainTable3D(pData->hrir_dirs_deg, pData->N_hrir_dirs, pData->hrtf_vbapTableRes[0], pData->hrtf_vbapTableRes[1], 1, 0, 0.0f,
346 &hrtf_vbap_gtable, &(pData->N_hrtf_vbap_gtable), &(pData->nTriangles));
347 if(hrtf_vbap_gtable==NULL){
348 /* if generating vbap gain tabled failed, re-calculate with default HRIR set */
349 pData->useDefaultHRIRsFLAG = 1;
351 }
352
353 /* compress VBAP table (i.e. remove the zero elements) */
354 pData->hrtf_vbap_gtableComp = realloc1d(pData->hrtf_vbap_gtableComp, pData->N_hrtf_vbap_gtable * 3 * sizeof(float));
355 pData->hrtf_vbap_gtableIdx = realloc1d(pData->hrtf_vbap_gtableIdx, pData->N_hrtf_vbap_gtable * 3 * sizeof(int));
357
358 /* convert hrirs to filterbank coefficients */
359 pData->progressBar0_1 = 0.6f;
360 pData->hrtf_fb = realloc1d(pData->hrtf_fb, HYBRID_BANDS * NUM_EARS * (pData->N_hrir_dirs)*sizeof(float_complex));
361 HRIRs2HRTFs_afSTFT(pData->hrirs, pData->N_hrir_dirs, pData->hrir_len, HOP_SIZE, 0, 1, pData->hrtf_fb);
362
363 /* HRIR pre-processing */
364 if(pData->enableHRIRsDiffuseEQ){
365 /* get integration weights */
366 strcpy(pData->progressBarText,"Applying HRIR diffuse-field EQ");
367 pData->progressBar0_1 = 0.9f;
368 if(pData->N_hrir_dirs<=3600){
369 pData->weights = realloc1d(pData->weights, pData->N_hrir_dirs*sizeof(float));
370 float * hrir_dirs_rad = (float*) malloc1d(pData->N_hrir_dirs*2*sizeof(float));
371 memcpy(hrir_dirs_rad, pData->hrir_dirs_deg, pData->N_hrir_dirs*2*sizeof(float));
372 cblas_sscal(pData->N_hrir_dirs*2, SAF_PI/180.f, hrir_dirs_rad, 1);
373 sphElev2incl(hrir_dirs_rad, pData->N_hrir_dirs, 0, hrir_dirs_rad);
374 int supOrder = calculateGridWeights(hrir_dirs_rad, pData->N_hrir_dirs, -1, pData->weights);
375 if(supOrder < 1){
376 saf_print_warning("Could not calculate grid weights");
377 free(pData->weights);
378 pData->weights = NULL;
379 }
380 }
381 else{
382 saf_print_warning("Too many grid points to calculate grid weights. Assuming that the HRTF measurement grid was uniform.");
383 free(pData->weights);
384 pData->weights = NULL;
385 }
386 diffuseFieldEqualiseHRTFs(pData->N_hrir_dirs, pData->itds_s, pData->freqVector, HYBRID_BANDS, pData->weights, 1, 0, pData->hrtf_fb);
387 }
388
389 /* calculate magnitude responses */
390 pData->hrtf_fb_mag = realloc1d(pData->hrtf_fb_mag, HYBRID_BANDS*NUM_EARS*(pData->N_hrir_dirs)*sizeof(float));
391 for(i=0; i<HYBRID_BANDS*NUM_EARS* (pData->N_hrir_dirs); i++)
392 pData->hrtf_fb_mag[i] = cabsf(pData->hrtf_fb[i]);
393
394 /* The HRTFs should be re-interpolated */
395 for(i=0; i<MAX_NUM_INPUTS; i++)
396 pData->recalc_hrtf_interpFLAG[i] = 1;
397
398 /* clean-up */
399 free(hrtf_vbap_gtable);
400}
401
403(
404 void* const hBin
405)
406{
407 binauraliser_data *pData = (binauraliser_data*)(hBin);
408
409 if(pData->hSTFT==NULL)
411 else if(pData->new_nSources!=pData->nSources){
414 }
415 pData->nSources = pData->new_nSources;
416}
417
419(
421 _Atomic_FLOAT32 dirs_deg[MAX_NUM_INPUTS][2],
422 _Atomic_INT32* newNCH,
423 int* nDims
424)
425{
426 float sum_elev;
427 int ch, i, nCH;
428
429 switch(preset){
430 default:
431 case SOURCE_CONFIG_PRESET_DEFAULT:
432 nCH = 1;
433 for(ch=0; ch<nCH; ch++)
434 for(i=0; i<2; i++)
435 dirs_deg[ch][i] = 0.0f;
436 break;
437 case SOURCE_CONFIG_PRESET_MONO:
438 nCH = 1;
439 for(ch=0; ch<nCH; ch++)
440 for(i=0; i<2; i++)
441 dirs_deg[ch][i] = __mono_dirs_deg[ch][i];
442 break;
443 case SOURCE_CONFIG_PRESET_STEREO:
444 nCH = 2;
445 for(ch=0; ch<nCH; ch++)
446 for(i=0; i<2; i++)
447 dirs_deg[ch][i] = __stereo_dirs_deg[ch][i];
448 break;
449 case SOURCE_CONFIG_PRESET_5PX:
450 nCH = 5;
451 for(ch=0; ch<nCH; ch++)
452 for(i=0; i<2; i++)
453 dirs_deg[ch][i] = __5pX_dirs_deg[ch][i];
454 break;
455 case SOURCE_CONFIG_PRESET_7PX:
456 nCH = 7;
457 for(ch=0; ch<nCH; ch++)
458 for(i=0; i<2; i++)
459 dirs_deg[ch][i] = __7pX_dirs_deg[ch][i];
460 break;
461 case SOURCE_CONFIG_PRESET_8PX:
462 nCH = 8;
463 for(ch=0; ch<nCH; ch++)
464 for(i=0; i<2; i++)
465 dirs_deg[ch][i] = __8pX_dirs_deg[ch][i];
466 break;
467 case SOURCE_CONFIG_PRESET_9PX:
468 nCH = 9;
469 for(ch=0; ch<nCH; ch++)
470 for(i=0; i<2; i++)
471 dirs_deg[ch][i] = __9pX_dirs_deg[ch][i];
472 break;
473 case SOURCE_CONFIG_PRESET_10PX:
474 nCH = 10;
475 for(ch=0; ch<nCH; ch++)
476 for(i=0; i<2; i++)
477 dirs_deg[ch][i] = __10pX_dirs_deg[ch][i];
478 break;
479 case SOURCE_CONFIG_PRESET_11PX:
480 nCH = 11;
481 for(ch=0; ch<nCH; ch++)
482 for(i=0; i<2; i++)
483 dirs_deg[ch][i] = __11pX_dirs_deg[ch][i];
484 break;
485 case SOURCE_CONFIG_PRESET_11PX_7_4:
486 nCH = 11;
487 for(ch=0; ch<nCH; ch++)
488 for(i=0; i<2; i++)
489 dirs_deg[ch][i] = __11pX_7_4_dirs_deg[ch][i];
490 break;
491 case SOURCE_CONFIG_PRESET_13PX:
492 nCH = 13;
493 for(ch=0; ch<nCH; ch++)
494 for(i=0; i<2; i++)
495 dirs_deg[ch][i] = __13pX_dirs_deg[ch][i];
496 break;
497 case SOURCE_CONFIG_PRESET_22PX:
498 nCH = 22;
499 for(ch=0; ch<nCH; ch++)
500 for(i=0; i<2; i++)
501 dirs_deg[ch][i] = __22pX_dirs_deg[ch][i];
502 break;
503 case SOURCE_CONFIG_PRESET_22P2_9_10_3:
504 nCH = 24;
505 for(ch=0; ch<nCH; ch++)
506 for(i=0; i<2; i++)
507 dirs_deg[ch][i] = __9_10_3p2_dirs_deg[ch][i];
508 break;
509 case SOURCE_CONFIG_PRESET_PROTOOLS_STEREO:
510 nCH = 2;
511 for(ch=0; ch<nCH; ch++)
512 for(i=0; i<2; i++)
514 break;
515 case SOURCE_CONFIG_PRESET_PROTOOLS_LCR:
516 nCH = 3;
517 for(ch=0; ch<nCH; ch++)
518 for(i=0; i<2; i++)
520 break;
521 case SOURCE_CONFIG_PRESET_PROTOOLS_QUAD:
522 nCH = 4;
523 for(ch=0; ch<nCH; ch++)
524 for(i=0; i<2; i++)
526 break;
527 case SOURCE_CONFIG_PRESET_PROTOOLS_5_0:
528 nCH = 5;
529 for(ch=0; ch<nCH; ch++)
530 for(i=0; i<2; i++)
532 break;
533 case SOURCE_CONFIG_PRESET_PROTOOLS_5_0_2:
534 nCH = 7;
535 for(ch=0; ch<nCH; ch++)
536 for(i=0; i<2; i++)
538 break;
539 case SOURCE_CONFIG_PRESET_PROTOOLS_5_0_4:
540 nCH = 9;
541 for(ch=0; ch<nCH; ch++)
542 for(i=0; i<2; i++)
544 break;
545 case SOURCE_CONFIG_PRESET_PROTOOLS_7_0:
546 nCH = 7;
547 for(ch=0; ch<nCH; ch++)
548 for(i=0; i<2; i++)
550 break;
551 case SOURCE_CONFIG_PRESET_PROTOOLS_7_0_2:
552 nCH = 9;
553 for(ch=0; ch<nCH; ch++)
554 for(i=0; i<2; i++)
556 break;
557 case SOURCE_CONFIG_PRESET_PROTOOLS_7_0_4:
558 nCH = 11;
559 for(ch=0; ch<nCH; ch++)
560 for(i=0; i<2; i++)
562 break;
563 case SOURCE_CONFIG_PRESET_PROTOOLS_7_0_6:
564 nCH = 13;
565 for(ch=0; ch<nCH; ch++)
566 for(i=0; i<2; i++)
568 break;
569 case SOURCE_CONFIG_PRESET_PROTOOLS_9_0_4:
570 nCH = 13;
571 for(ch=0; ch<nCH; ch++)
572 for(i=0; i<2; i++)
574 break;
575 case SOURCE_CONFIG_PRESET_PROTOOLS_9_0_6:
576 nCH = 15;
577 for(ch=0; ch<nCH; ch++)
578 for(i=0; i<2; i++)
580 break;
581 case SOURCE_CONFIG_PRESET_AALTO_MCC:
582 nCH = 45;
583 for(ch=0; ch<nCH; ch++)
584 for(i=0; i<2; i++)
585 dirs_deg[ch][i] = __Aalto_MCC_dirs_deg[ch][i];
586 break;
587 case SOURCE_CONFIG_PRESET_AALTO_MCC_SUBSET:
588 nCH = 37;
589 for(ch=0; ch<nCH; ch++)
590 for(i=0; i<2; i++)
591 dirs_deg[ch][i] = __Aalto_MCCsubset_dirs_deg[ch][i];
592 break;
593 case SOURCE_CONFIG_PRESET_AALTO_APAJA:
594 nCH = 29;
595 for(ch=0; ch<nCH; ch++)
596 for(i=0; i<2; i++)
597 dirs_deg[ch][i] = __Aalto_Apaja_dirs_deg[ch][i];
598 break;
599 case SOURCE_CONFIG_PRESET_AALTO_LR:
600 nCH = 13;
601 for(ch=0; ch<nCH; ch++)
602 for(i=0; i<2; i++)
603 dirs_deg[ch][i] = __Aalto_LR_dirs_deg[ch][i];
604 break;
605 case SOURCE_CONFIG_PRESET_DTU_AVIL:
606 nCH = 64;
607 for(ch=0; ch<nCH; ch++)
608 for(i=0; i<2; i++)
609 dirs_deg[ch][i] = __DTU_AVIL_dirs_deg[ch][i];
610 break;
611 case SOURCE_CONFIG_PRESET_ZYLIA_LAB:
612 nCH = 22;
613 for(ch=0; ch<nCH; ch++)
614 for(i=0; i<2; i++)
615 dirs_deg[ch][i] = __Zylia_Lab_dirs_deg[ch][i];
616 break;
617 case SOURCE_CONFIG_PRESET_T_DESIGN_4:
618 nCH = 4;
619 for(ch=0; ch<nCH; ch++)
620 for(i=0; i<2; i++)
621 dirs_deg[ch][i] = __Tdesign_degree_2_dirs_deg[ch][i];
622 break;
623 case SOURCE_CONFIG_PRESET_T_DESIGN_12:
624 nCH = 12;
625 for(ch=0; ch<nCH; ch++)
626 for(i=0; i<2; i++)
627 dirs_deg[ch][i] = __Tdesign_degree_4_dirs_deg[ch][i];
628 break;
629 case SOURCE_CONFIG_PRESET_T_DESIGN_24:
630 nCH = 24;
631 for(ch=0; ch<nCH; ch++)
632 for(i=0; i<2; i++)
633 dirs_deg[ch][i] = __Tdesign_degree_6_dirs_deg[ch][i];
634 break;
635 case SOURCE_CONFIG_PRESET_T_DESIGN_36:
636 nCH = 36;
637 for(ch=0; ch<nCH; ch++)
638 for(i=0; i<2; i++)
639 dirs_deg[ch][i] = __Tdesign_degree_8_dirs_deg[ch][i];
640 break;
641 case SOURCE_CONFIG_PRESET_T_DESIGN_48:
642 nCH = 48;
643 for(ch=0; ch<nCH; ch++)
644 for(i=0; i<2; i++)
645 dirs_deg[ch][i] = __Tdesign_degree_9_dirs_deg[ch][i];
646 break;
647 case SOURCE_CONFIG_PRESET_T_DESIGN_60:
648 nCH = 60;
649 for(ch=0; ch<nCH; ch++)
650 for(i=0; i<2; i++)
651 dirs_deg[ch][i] = __Tdesign_degree_10_dirs_deg[ch][i];
652 break;
653 case SOURCE_CONFIG_PRESET_SPH_COV_9:
654 nCH = 9;
655 for(ch=0; ch<nCH; ch++)
656 for(i=0; i<2; i++)
657 dirs_deg[ch][i] = __SphCovering_9_dirs_deg[ch][i];
658 break;
659 case SOURCE_CONFIG_PRESET_SPH_COV_16:
660 nCH = 16;
661 for(ch=0; ch<nCH; ch++)
662 for(i=0; i<2; i++)
663 dirs_deg[ch][i] = __SphCovering_16_dirs_deg[ch][i];
664 break;
665 case SOURCE_CONFIG_PRESET_SPH_COV_25:
666 nCH = 25;
667 for(ch=0; ch<nCH; ch++)
668 for(i=0; i<2; i++)
669 dirs_deg[ch][i] = __SphCovering_25_dirs_deg[ch][i];
670 break;
671 case SOURCE_CONFIG_PRESET_SPH_COV_49:
672 nCH = 49;
673 for(ch=0; ch<nCH; ch++)
674 for(i=0; i<2; i++)
675 dirs_deg[ch][i] = __SphCovering_49_dirs_deg[ch][i];
676 break;
677 case SOURCE_CONFIG_PRESET_SPH_COV_64:
678 nCH = 64;
679 for(ch=0; ch<nCH; ch++)
680 for(i=0; i<2; i++)
681 dirs_deg[ch][i] = __SphCovering_64_dirs_deg[ch][i];
682 break;
683 }
684
685 /* Fill remaining slots with default coords */
686 for(; ch<MAX_NUM_INPUTS; ch++){
687 for(i=0; i<2; i++){
688 dirs_deg[ch][i] = __default_LScoords128_deg[ch][i];
689 }
690 }
691
692 /* For dynamically changing the number of TFT channels */
693 (*newNCH) = nCH;
694
695 /* estimate number of dimensions. (Obviously fails if using 2D setups thare are on an angle.
696 However, in these cases, triangulation should fail and revert to 2D anyway) */
697 sum_elev = 0.0f;
698 for(i=0; i<nCH; i++){
699 sum_elev += dirs_deg[i][1];
700 }
701 if(sum_elev < 0.01f)
702 (*nDims) = 2;
703 else
704 (*nDims) = 3;
705}
706
707
708
709
710
711
712
713
714
715
716
717
#define MAX_NUM_INPUTS
Maximum number of input channels supported.
Definition _common.h:261
SOURCE_CONFIG_PRESETS
Available source configurations presets to use for encoding/panning.
Definition _common.h:149
CODEC_STATUS
Current status of the codec.
Definition _common.h:229
@ CODEC_STATUS_NOT_INITIALISED
Codec has not yet been initialised, or the codec configuration has changed.
Definition _common.h:232
@ CODEC_STATUS_INITIALISING
Codec is currently being initialised, input audio should not be processed.
Definition _common.h:235
void afSTFT_clearBuffers(void *const hSTFT)
Flushes time-domain buffers with zeros.
Definition afSTFTlib.c:519
void afSTFT_create(void **const phSTFT, int nCHin, int nCHout, int hopsize, int lowDelayMode, int hybridmode, AFSTFT_FDDATA_FORMAT format)
Creates an instance of afSTFT.
Definition afSTFTlib.c:143
void afSTFT_channelChange(void *const hSTFT, int new_nCHin, int new_nCHout)
Re-allocates memory to support a change in the number of input/output channels.
Definition afSTFTlib.c:477
@ AFSTFT_BANDS_CH_TIME
nBands x nChannels x nTimeHops
Definition afSTFTlib.h:80
#define HOP_SIZE
STFT hop size.
#define HYBRID_BANDS
Number of frequency bands.
INTERP_MODES
Available interpolation modes.
@ INTERP_TRI
Triangular interpolation.
@ INTERP_TRI_PS
Triangular interpolation (with phase-simplification)
const float binauraliser_defaultSourceDirections[MAX_NUM_INPUTS][2]
Default source directions.
const int binauraliser_defaultNumSources
Default number of Sources.
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_loadPreset(SOURCE_CONFIG_PRESETS preset, _Atomic_FLOAT32 dirs_deg[MAX_NUM_INPUTS][2], _Atomic_INT32 *newNCH, int *nDims)
Returns the source directions for a specified source config preset.
void binauraliser_setCodecStatus(void *const hBin, CODEC_STATUS newStatus)
Sets codec status (see CODEC_STATUS enum)
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.
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.
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 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
int calculateGridWeights(float *dirs_rad, int nDirs, int order, float *w)
Computes approximation of quadrature/integration weights for a given grid.
Definition saf_sh.c:1066
void saf_sofa_close(saf_sofa_container *c)
Frees all SOFA data in a sofa_container.
SAF_SOFA_ERROR_CODES saf_sofa_open(saf_sofa_container *h, char *sofa_filepath, SAF_SOFA_READER_OPTIONS option)
Fills a 'sofa_container' with data found in a SOFA file (GeneralFIR or SimpleFreeFieldHRIR),...
SAF_SOFA_ERROR_CODES
SOFA loader error codes.
@ SAF_SOFA_READER_OPTION_DEFAULT
The default option is SAF_SOFA_READER_OPTION_LIBMYSOFA.
@ SAF_SOFA_OK
None of the error checks failed.
const float __Zylia_Lab_dirs_deg[22][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for the 22.x setup, at Zylia Labs.
const float __protools_Quad_dirs_deg[4][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for ProTools Quadraphonic.
const int __protools_mapping_5p0_to_discrete[5]
Indices to map a 5p0 bus to a discrete bus in ProTools.
#define SAF_PI
pi constant (single precision)
const int __protools_mapping_7p0p4_to_discrete[11]
Indices to map a 7p0p4 bus to a discrete bus in ProTools.
const float __9pX_dirs_deg[9][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a 9.x setup.
const float __SphCovering_16_dirs_deg[16][2]
Directions [azimuth, Elevation] in degrees, for sphere covering: 16 dirs.
const float __Aalto_MCC_dirs_deg[45][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for the multi-channel anechoic chamber (MCC),...
const float __SphCovering_49_dirs_deg[49][2]
Directions [azimuth, Elevation] in degrees, for sphere covering: 49 dirs.
void convert_0_360To_m180_180(float *dirs_deg, int nDirs)
Wraps around any angles exeeding 180 degrees (e.g., 200-> -160)
#define NUM_EARS
2 (true for most humans)
float matlab_fmodf(float x, float y)
C fmodf function, except it behaves like 'mod' in Matlab (i.e.
const float __mono_dirs_deg[1][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a mono setup.
const float __5pX_dirs_deg[5][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a 5.x setup.
const float __11pX_dirs_deg[11][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a 11.x setup.
const float __Tdesign_degree_9_dirs_deg[48][2]
Directions [azimuth, Elevation] in degrees, for minimum Tdesign degree: 9.
const float __Tdesign_degree_2_dirs_deg[4][2]
Directions [azimuth, Elevation] in degrees, for minimum Tdesign degree: 2.
const float __11pX_7_4_dirs_deg[11][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a 7.4.x setup.
const float __Tdesign_degree_8_dirs_deg[36][2]
Directions [azimuth, Elevation] in degrees, for minimum Tdesign degree: 8.
const float __9_10_3p2_dirs_deg[24][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a 9+10+3.2 setup BS 2051 recommedation: h...
const float __default_LScoords128_deg[128][2]
Default Loudspeaker directions [azimuth, Elevation] - to replace above!
const float __protools_7p0_dirs_deg[7][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for ProTools 7.0 surround L C R Lss Rss Lsr R...
const float __protools_7p0p2_dirs_deg[9][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for ProTools 7.0.2 surround L C R Lss Rss Lsr...
const float __Aalto_MCCsubset_dirs_deg[37][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for the multi-channel anechoic chamber (MCC) ...
const int __protools_mapping_stereo_to_discrete[2]
Indices to map a stereo bus to a discrete bus in ProTools.
const float __Aalto_Apaja_dirs_deg[29][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for the audio-visual listening room (Apaja),...
const int __protools_mapping_7p0p2_to_discrete[9]
Indices to map a 7p0p2 bus to a discrete bus in ProTools.
const int __protools_mapping_5p0p2_to_discrete[7]
Indices to map a 5p0p2 bus to a discrete bus in ProTools.
const float __SphCovering_9_dirs_deg[9][2]
Directions [azimuth, Elevation] in degrees, for sphere covering: 9 dirs.
const int __protools_mapping_LCR_to_discrete[3]
Indices to map a LCR bus to a discrete bus in ProTools.
const float __protools_7p0p6_dirs_deg[13][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for ProTools 7.0.6 surround L R C Lss Rss Lsr...
const float __protools_5p0_dirs_deg[5][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for ProTools 5.0 surround (Film) L C R Ls Rs.
const float __stereo_dirs_deg[2][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a stereo setup.
const float __SphCovering_64_dirs_deg[64][2]
Directions [azimuth, Elevation] in degrees, for sphere covering: 64 dirs.
const int __protools_mapping_7p0p6_to_discrete[13]
Indices to map a 7p0p6 bus to a discrete bus in ProTools.
const float __Tdesign_degree_4_dirs_deg[12][2]
Directions [azimuth, Elevation] in degrees, for minimum Tdesign degree: 4.
void sphElev2incl(float *dirsElev, int nDirs, int degreesFlag, float *dirsIncl)
Converts spherical coordinates of unit length from elevation to inclination.
const float __Aalto_LR_dirs_deg[13][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for the ITU standard listening room (LR),...
const float __DTU_AVIL_dirs_deg[64][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for the Audio Visual Immersion Lab (AVIL),...
const float __8pX_dirs_deg[8][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a 8.x setup.
const float __protools_LCR_dirs_deg[3][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for ProTools Left-centre-right.
const float __Tdesign_degree_6_dirs_deg[24][2]
Directions [azimuth, Elevation] in degrees, for minimum Tdesign degree: 6.
const float __protools_stereo_dirs_deg[2][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for ProTools stereo pair.
const float __protools_9p0p6_dirs_deg[15][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for ProTools 9.0.6 surround L R C Lss Rss Lsr...
const float __13pX_dirs_deg[13][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a 13.x setup.
const float __7pX_dirs_deg[7][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a 7.x setup.
#define saf_print_warning(message)
Macro to print a warning message along with the filename and line number.
const int __protools_mapping_9p0p4_to_discrete[13]
Indices to map a 9p0p4 bus to a discrete bus in ProTools.
const float __22pX_dirs_deg[22][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a 22.x setup.
const int __protools_mapping_5p0p4_to_discrete[9]
Indices to map a 5p0p4 bus to a discrete bus in ProTools.
const float __protools_5p0p4_dirs_deg[9][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for ProTools 5.0.4 surround L R C Ls Rs Ltf R...
const float __SphCovering_25_dirs_deg[25][2]
Directions [azimuth, Elevation] in degrees, for sphere covering: 25 dirs.
const int __protools_mapping_Quad_to_discrete[4]
Indices to map a Quad bus to a discrete bus in ProTools.
const int __protools_mapping_7p0_to_discrete[7]
Indices to map a 7p0 bus to a discrete bus in ProTools.
const float __protools_5p0p2_dirs_deg[7][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for ProTools 5.0.2 surround L R C Ls Rs Ltm R...
const float __protools_7p0p4_dirs_deg[11][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for ProTools 7.0.4 surround L R C Lss Rss Lsr...
const float __protools_9p0p4_dirs_deg[13][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for ProTools 9.0.4 surround L R C Lss Rss Lsr...
const int __protools_mapping_9p0p6_to_discrete[15]
Indices to map a 9p0p9 bus to a discrete bus in ProTools.
const float __Tdesign_degree_10_dirs_deg[60][2]
Directions [azimuth, Elevation] in degrees, for minimum Tdesign degree: 10.
const float __10pX_dirs_deg[10][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a 10.x setup.
void generateVBAPgainTable3D(float *ls_dirs_deg, int L, int az_res_deg, int el_res_deg, int omitLargeTriangles, int enableDummies, float spread, float **gtable, int *N_gtable, int *nTriangles)
Generates a 3-D VBAP gain table based on specified loudspeaker directions, with optional spreading [2...
Definition saf_vbap.c:172
void compressVBAPgainTable3D(float *vbap_gtable, int nTable, int nDirs, float *vbap_gtableComp, int *vbap_gtableIdx)
Compresses a VBAP gain table to use less memory and CPU (by removing the elements which are just zero...
Definition saf_vbap.c:313
void * malloc1d(size_t dim1_data_size)
1-D malloc (same as malloc, but with error checking)
Definition md_malloc.c:59
void * realloc1d(void *ptr, size_t dim1_data_size)
1-D realloc (same as realloc, but with error checking)
Definition md_malloc.c:79
Main structure for binauraliser.
_Atomic_INT32 hrir_len
length of the loaded HRIRs, in samples
float * hrtf_vbap_gtableComp
N_hrtf_vbap_gtable x 3.
_Atomic_INT32 enableHRIRsDiffuseEQ
flag to diffuse-field equalisation to the currently loaded HRTFs
float * hrirs
time domain HRIRs; FLAT: N_hrir_dirs x NUM_EARS x hrir_len
float_complex * hrtf_fb
hrtf filterbank coefficients; nBands x nCH x N_hrirs
int N_hrtf_vbap_gtable
Number of interpolation weights/directions.
float * hrir_dirs_deg
directions of the HRIRs in degrees [azi elev]; FLAT: N_hrir_dirs x 2
_Atomic_FLOAT32 fs
Host sampling rate, in Hz.
float * weights
Integration weights for the HRIR measurement grid; N_hrir_dirs x 1.
float * itds_s
interaural-time differences for each HRIR (in seconds); nBands x 1
int * hrtf_vbap_gtableIdx
N_hrtf_vbap_gtable x 3.
_Atomic_INT32 hrir_fs
sampling rate of the HRIRs being used for processing (after any resampling)
int hrtf_vbapTableRes[2]
[0] azimuth, and [1] elevation grid resolution, in degrees
_Atomic_INT32 hrir_orig_fs
Can be different from hrir_fs if HRIRs were resampled.
char * progressBarText
Current (re)initialisation step, string.
void * hSTFT
afSTFT handle
_Atomic_INT32 recalc_hrtf_interpFLAG[MAX_NUM_INPUTS]
1: re-calculate/interpolate the HRTF, 0: do not
float * hrtf_fb_mag
magnitudes of the hrtf filterbank coefficients; nBands x nCH x N_hrirs
_Atomic_FLOAT32 progressBar0_1
Current (re)initialisation progress, between [0..1].
_Atomic_INT32 N_hrir_dirs
number of HRIR directions in the current sofa file
_Atomic_INT32 useDefaultHRIRsFLAG
1: use default HRIRs in database, 0: use those from SOFA file
char * sofa_filepath
absolute/relevative file path for a sofa file
_Atomic_CODEC_STATUS codecStatus
see CODEC_STATUS
int nTriangles
Number of triangles in the convex hull of the spherical arrangement of HRIR directions/points.
float freqVector[HYBRID_BANDS]
Frequency vector (filterbank centre frequencies)
_Atomic_INT32 new_nSources
New number of input/source signals (current value will be replaced by this after next re-init)
_Atomic_INT32 nSources
Current number of input/source signals.
SOFA container struct comprising all possible data that can be extracted from SOFA 1....
int DataLengthIR
Length of the IRs, in samples.
int nSources
Number of source/measurement positions.
float * SourcePosition
Source positions (refer to SourcePositionType & SourcePositionUnits for the convention and units); FL...
float DataSamplingRate
Sampling rate used to measure the IRs.
int nReceivers
Number of ears/number of mics etc.
float * DataIR
The impulse response (IR) Data; FLAT:nSources x nReceivers x DataLengthIR.