SAF
Loading...
Searching...
No Matches
ambi_dec_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
45
46#include "ambi_dec_internal.h"
47
49
50/* First 24 loudspeakers are for a 24 point t-design, the rest are for a 128 point sphere covering */
52{ { 26.0011675216559f, 15.4641512961471f},
53 { -26.0011675216559f, -15.4641512961471f},
54 { 17.1086452559122f, -24.9937030546433f},
55 { -17.1086452559122f, 24.9937030546433f},
56 { 153.998832478344f, -15.4641512961471f},
57 { -153.998832478344f, 15.4641512961471f},
58 { 162.891354744088f, 24.9937030546433f},
59 { -162.891354744088f, -24.9937030546433f},
60 { 72.8913547440879f, 24.9937030546433f},
61 { 107.108645255912f, -24.9937030546433f},
62 { 116.001167521656f, 15.4641512961471f},
63 { 63.9988324783441f, -15.4641512961471f},
64 { -107.108645255912f, 24.9937030546433f},
65 { -72.8913547440879f, -24.9937030546433f},
66 { -63.9988324783441f, 15.4641512961471f},
67 { -116.001167521656f, -15.4641512961471f},
68 { 32.2544599366034f, 60.0253819510733f},
69 { -147.745540063397f, 60.0253819510733f},
70 { -57.7455400633966f, 60.0253819510733f},
71 { 122.254459936603f, 60.0253819510733f},
72 { -32.2544599366034f, -60.0253819510733f},
73 { 147.745540063397f, -60.0253819510733f},
74 { 57.7455400633966f, -60.0253819510733f},
75 { -122.254459936603f, -60.0253819510733f},
76 { 56.4638592172755f, 41.2645742763346f},
77 { 46.4626904606488f, 24.5386896277818f},
78 { -123.528839291756f, 41.2565889648213f},
79 { 32.1932295461248f, 38.8027347956192f},
80 { 133.534545076742f, -24.5310453346374f},
81 { -32.1935458377634f, -38.8041545028931f},
82 { -133.533477606995f, 24.5319420428588f},
83 { -147.797881221742f, 38.7980990097138f},
84 { -46.4626630742447f, -24.5400749997299f},
85 { 147.799544204027f, -38.7965984357137f},
86 { -56.4649576930965f, -41.2658215291547f},
87 { 123.530547454259f, -41.2555316199835f},
88 { 84.7385596473317f, 27.3132538556364f},
89 { 27.4072860474693f, 4.67593317316088f},
90 { -95.2612516264878f, 27.3036967398252f},
91 { 10.0607591758466f, 62.2287426217158f},
92 { 152.592710471291f, -4.67007594116539f},
93 { -10.0604693351594f, -62.2317767049329f},
94 { -152.592615409799f, 4.67188744845125f},
95 { -169.918387889403f, 62.2272712110016f},
96 { -27.4047652820400f, -4.67684895484045f},
97 { 169.918493477140f, -62.2246416140826f},
98 { -84.7390238025025f, -27.3120311727342f},
99 { 95.2622793653641f, -27.3027426350066f},
100 { 136.272846725200f, -0.726139068263599f},
101 { -1.05456977390436f, -46.2698051615206f},
102 { -43.7263256019408f, -0.737666959763443f},
103 { -91.0084089447853f, 43.7170295842697f},
104 { -178.936314291048f, 46.2682278552731f},
105 { 91.0100541861312f, -43.7163112498585f},
106 { 178.938490558618f, -46.2666218304286f},
107 { 88.9860902890987f, 43.7285680951606f},
108 { 1.05095788619312f, 46.2682407577363f},
109 { -88.9851906686018f, -43.7278600822776f},
110 { -136.273314433943f, 0.726484363994244f},
111 { 43.7273191822901f, 0.733967099281741f},
112 { 55.2321077221357f, 10.8187456245361f},
113 { 13.0867814081219f, 34.0654299770448f},
114 { -124.767898552651f, 10.8099467408727f},
115 { 71.4751302534919f, 53.7984109774923f},
116 { 166.905549455530f, -34.0625862919868f},
117 { -71.4765158530160f, -53.8002805142714f},
118 { -166.904587570338f, 34.0633858486074f},
119 { -108.515564585463f, 53.7864186881779f},
120 { -13.0869589355977f, -34.0644403811701f},
121 { 108.517274377512f, -53.7853093207457f},
122 { -55.2337689585088f, -10.8200079671294f},
123 { 124.767519417537f, -10.8096092876561f},
124 { -105.493359369733f, -68.1345228940484f},
125 { -111.151973933085f, -5.71277564515985f},
126 { 74.5244447329726f, -68.1205741555505f},
127 { -173.885132403874f, -21.0401043953034f},
128 { -68.8521018079939f, 5.70313885775370f},
129 { 173.885050918764f, 21.0419786777516f},
130 { 68.8513569996117f, -5.70297394874866f},
131 { 6.12041448982713f, -21.0387333986971f},
132 { 111.151515131908f, 5.71357243375474f},
133 { -6.11913621739966f, 21.0397756114589f},
134 { 105.487055344890f, 68.1331981897040f},
135 { -74.5188619841755f, 68.1214716326340f},
136 { 35.2822222163987f, -15.1801841162885f},
137 { -25.1732516880600f, 51.9826514887145f},
138 { -144.722913967824f, -15.1859965048827f},
139 { 108.386507250934f, 33.8824333892584f},
140 { -154.839566662519f, -51.9856067440744f},
141 { -108.385758587361f, -33.8826426573830f},
142 { 154.840828582605f, 51.9884126722963f},
143 { -71.6110721306039f, 33.8714084774643f},
144 { 25.1699762263473f, -51.9843011897216f},
145 { 71.6126173250777f, -33.8705490198003f},
146 { -35.2810594358470f, 15.1763090469469f},
147 { 144.722474074749f, 15.1863112389402f},
148 { -125.277803641269f, -28.5561977838671f},
149 { -146.317489805034f, -30.4888082061806f},
150 { 54.7220842889970f, -28.5463137051834f},
151 { -133.292600372594f, -45.8199818171681f},
152 { -33.6854220654234f, 30.4794807422719f},
153 { 133.295169860873f, 45.8200619710773f},
154 { 33.6830420572493f, -30.4828689919959f},
155 { 46.7098267598019f, -45.8106991831118f},
156 { 146.318736830907f, 30.4889588527258f},
157 { -46.7107531920589f, 45.8077510168776f},
158 { 125.278543193551f, 28.5567151663926f},
159 { -54.7226679373581f, 28.5424675755949f},
160 { -144.402199049652f, 54.7141577397485f},
161 { 112.382216591782f, -28.0100385212576f},
162 { 35.5834085793474f, 54.7193853715013f},
163 { -29.9155874729000f, -19.6471282266303f},
164 { 67.6163420587218f, 28.0211878299760f},
165 { 29.9151078604395f, 19.6461577548916f},
166 { -67.6164804090156f, -28.0221553885221f},
167 { 150.081679085309f, -19.6396879622134f},
168 { -112.381365317985f, 28.0105570315277f},
169 { -150.081127534239f, 19.6412999777121f},
170 { 144.402936805264f, -54.7127597303097f},
171 { -35.5837994140428f, -54.7203576209200f},
172 { 68.5348504928164f, -52.8527273534571f},
173 { -54.8218918027732f, 12.7570858971645f},
174 { -111.464947340552f, -52.8652964226689f},
175 { 164.510735700738f, 34.1892226850382f},
176 { -125.181243085238f, -12.7710900404128f},
177 { -164.510172672569f, -34.1865270720665f},
178 { 125.180742749445f, 12.7714932994183f},
179 { -15.4967238792034f, 34.1855682977571f}};
180
181void ambi_dec_setCodecStatus(void* const hAmbi, CODEC_STATUS newStatus)
182{
183 ambi_dec_data *pData = (ambi_dec_data*)(hAmbi);
184 if(newStatus==CODEC_STATUS_NOT_INITIALISED){
185 /* Pause until current initialisation is complete */
187 SAF_SLEEP(10);
188 }
189 pData->codecStatus = newStatus;
190}
191
193(
194 void* const hAmbi,
195 float azimuth_deg,
196 float elevation_deg,
197 float_complex h_intrp[HYBRID_BANDS][NUM_EARS]
198)
199{
200 ambi_dec_data *pData = (ambi_dec_data*)(hAmbi);
201 ambi_dec_codecPars* pars = pData->pars;
202 int i, band;
203 int aziIndex, elevIndex, N_azi, idx3d;
204 float_complex ipd;
205 float aziRes, elevRes, weights[1][3], itds3[3], itdInterp[1];
206 float magnitudes3[HYBRID_BANDS][3][NUM_EARS], magInterp[HYBRID_BANDS][NUM_EARS];
207
208 /* find closest pre-computed VBAP direction */
209 aziRes = (float)pars->hrtf_vbapTableRes[0];
210 elevRes = (float)pars->hrtf_vbapTableRes[1];
211 N_azi = (int)(360.0f / aziRes + 0.5f) + 1;
212 aziIndex = (int)(matlab_fmodf(azimuth_deg + 180.0f, 360.0f) / aziRes + 0.5f);
213 elevIndex = (int)((elevation_deg + 90.0f) / elevRes + 0.5f);
214 idx3d = elevIndex * N_azi + aziIndex;
215 for (i = 0; i < 3; i++)
216 weights[0][i] = pars->hrtf_vbap_gtableComp[idx3d*3 + i];
217
218 /* retrieve the 3 itds and hrtf magnitudes */
219 for (i = 0; i < 3; i++) {
220 itds3[i] = pars->itds_s[pars->hrtf_vbap_gtableIdx[idx3d*3+i]];
221 for (band = 0; band < HYBRID_BANDS; band++) {
222 magnitudes3[band][i][0] = pars->hrtf_fb_mag[band*NUM_EARS*(pars->N_hrir_dirs) + 0*(pars->N_hrir_dirs) + pars->hrtf_vbap_gtableIdx[idx3d*3+i]];
223 magnitudes3[band][i][1] = pars->hrtf_fb_mag[band*NUM_EARS*(pars->N_hrir_dirs) + 1*(pars->N_hrir_dirs) + pars->hrtf_vbap_gtableIdx[idx3d*3+i]];
224 }
225 }
226
227 /* interpolate hrtf magnitudes and itd seperately */
228 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 1, 1, 3, 1,
229 (float*)weights, 3,
230 (float*)itds3, 1, 0,
231 (float*)itdInterp, 1);
232 for (band = 0; band < HYBRID_BANDS; band++) {
233 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 1, 2, 3, 1,
234 (float*)weights, 3,
235 (float*)magnitudes3[band], 2, 0,
236 (float*)magInterp[band], 2);
237 }
238
239 /* reintroduce the interaural phase difference per band */
240 for (band = 0; band < HYBRID_BANDS; band++) {
241 if(pData->freqVector[band]<1.5e3f)
242 ipd = cmplxf(0.0f, (matlab_fmodf(2.0f*SAF_PI*(pData->freqVector[band]) * itdInterp[0] + SAF_PI, 2.0f*SAF_PI) - SAF_PI)/2.0f);
243 else
244 ipd = cmplxf(0.0f, 0.0f);
245 h_intrp[band][0] = ccmulf(cmplxf(magInterp[band][0], 0.0f), cexpf(ipd));
246 h_intrp[band][1] = ccmulf(cmplxf(magInterp[band][1], 0.0f), conjf(cexpf(ipd)));
247 }
248}
249
251(
253 _Atomic_FLOAT32 dirs_deg[MAX_NUM_LOUDSPEAKERS][2],
254 _Atomic_INT32* newNCH,
255 int* nDims
256)
257{
258 float sum_elev;
259 int ch, i, nCH;
260
261 nCH = ch = 0;
262 switch(preset){
263 default:
264 /* fall through */
265 case LOUDSPEAKER_ARRAY_PRESET_DEFAULT:
266 /* fall through */
267 case LOUDSPEAKER_ARRAY_PRESET_STEREO:
268 nCH = 2;
269 for(ch=0; ch<nCH; ch++)
270 for(i=0; i<2; i++)
271 dirs_deg[ch][i] = __stereo_dirs_deg[ch][i];
272 break;
273 case LOUDSPEAKER_ARRAY_PRESET_5PX:
274 nCH = 5;
275 for(ch=0; ch<nCH; ch++)
276 for(i=0; i<2; i++)
277 dirs_deg[ch][i] = __5pX_dirs_deg[ch][i];
278 break;
279 case LOUDSPEAKER_ARRAY_PRESET_7PX:
280 nCH = 7;
281 for(ch=0; ch<nCH; ch++)
282 for(i=0; i<2; i++)
283 dirs_deg[ch][i] = __7pX_dirs_deg[ch][i];
284 break;
285 case LOUDSPEAKER_ARRAY_PRESET_8PX:
286 nCH = 8;
287 for(ch=0; ch<nCH; ch++)
288 for(i=0; i<2; i++)
289 dirs_deg[ch][i] = __8pX_dirs_deg[ch][i];
290 break;
291 case LOUDSPEAKER_ARRAY_PRESET_9PX:
292 nCH = 9;
293 for(ch=0; ch<nCH; ch++)
294 for(i=0; i<2; i++)
295 dirs_deg[ch][i] = __9pX_dirs_deg[ch][i];
296 break;
297 case LOUDSPEAKER_ARRAY_PRESET_10PX:
298 nCH = 10;
299 for(ch=0; ch<nCH; ch++)
300 for(i=0; i<2; i++)
301 dirs_deg[ch][i] = __10pX_dirs_deg[ch][i];
302 break;
303 case LOUDSPEAKER_ARRAY_PRESET_11PX:
304 nCH = 11;
305 for(ch=0; ch<nCH; ch++)
306 for(i=0; i<2; i++)
307 dirs_deg[ch][i] = __11pX_dirs_deg[ch][i];
308 break;
309 case LOUDSPEAKER_ARRAY_PRESET_11PX_7_4:
310 nCH = 11;
311 for(ch=0; ch<nCH; ch++)
312 for(i=0; i<2; i++)
313 dirs_deg[ch][i] = __11pX_7_4_dirs_deg[ch][i];
314 break;
315 case LOUDSPEAKER_ARRAY_PRESET_13PX:
316 nCH = 13;
317 for(ch=0; ch<nCH; ch++)
318 for(i=0; i<2; i++)
319 dirs_deg[ch][i] = __13pX_dirs_deg[ch][i];
320 break;
321 case LOUDSPEAKER_ARRAY_PRESET_22PX:
322 nCH = 22;
323 for(ch=0; ch<nCH; ch++)
324 for(i=0; i<2; i++)
325 dirs_deg[ch][i] = __22pX_dirs_deg[ch][i];
326 break;
327 case LOUDSPEAKER_ARRAY_PRESET_22P2_9_10_3:
328 saf_print_error("Not suitable, since it contains LFE channels");
329 break;
330 case LOUDSPEAKER_ARRAY_PRESET_PROTOOLS_STEREO:
331 nCH = 2;
332 for(ch=0; ch<nCH; ch++)
333 for(i=0; i<2; i++)
335 break;
336 case LOUDSPEAKER_ARRAY_PRESET_PROTOOLS_LCR:
337 nCH = 3;
338 for(ch=0; ch<nCH; ch++)
339 for(i=0; i<2; i++)
341 break;
342 case LOUDSPEAKER_ARRAY_PRESET_PROTOOLS_QUAD:
343 nCH = 4;
344 for(ch=0; ch<nCH; ch++)
345 for(i=0; i<2; i++)
347 break;
348 case LOUDSPEAKER_ARRAY_PRESET_PROTOOLS_5_0:
349 nCH = 5;
350 for(ch=0; ch<nCH; ch++)
351 for(i=0; i<2; i++)
353 break;
354 case LOUDSPEAKER_ARRAY_PRESET_PROTOOLS_5_0_2:
355 nCH = 7;
356 for(ch=0; ch<nCH; ch++)
357 for(i=0; i<2; i++)
359 break;
360 case LOUDSPEAKER_ARRAY_PRESET_PROTOOLS_5_0_4:
361 nCH = 9;
362 for(ch=0; ch<nCH; ch++)
363 for(i=0; i<2; i++)
365 break;
366 case LOUDSPEAKER_ARRAY_PRESET_PROTOOLS_7_0:
367 nCH = 7;
368 for(ch=0; ch<nCH; ch++)
369 for(i=0; i<2; i++)
371 break;
372 case LOUDSPEAKER_ARRAY_PRESET_PROTOOLS_7_0_2:
373 nCH = 9;
374 for(ch=0; ch<nCH; ch++)
375 for(i=0; i<2; i++)
377 break;
378 case LOUDSPEAKER_ARRAY_PRESET_PROTOOLS_7_0_4:
379 nCH = 11;
380 for(ch=0; ch<nCH; ch++)
381 for(i=0; i<2; i++)
383 break;
384 case LOUDSPEAKER_ARRAY_PRESET_PROTOOLS_7_0_6:
385 nCH = 13;
386 for(ch=0; ch<nCH; ch++)
387 for(i=0; i<2; i++)
389 break;
390 case LOUDSPEAKER_ARRAY_PRESET_PROTOOLS_9_0_4:
391 nCH = 13;
392 for(ch=0; ch<nCH; ch++)
393 for(i=0; i<2; i++)
395 break;
396 case LOUDSPEAKER_ARRAY_PRESET_PROTOOLS_9_0_6:
397 nCH = 15;
398 for(ch=0; ch<nCH; ch++)
399 for(i=0; i<2; i++)
401 break;
402 case LOUDSPEAKER_ARRAY_PRESET_AALTO_MCC:
403 nCH = 45;
404 for(ch=0; ch<nCH; ch++)
405 for(i=0; i<2; i++)
406 dirs_deg[ch][i] = __Aalto_MCC_dirs_deg[ch][i];
407 break;
408 case LOUDSPEAKER_ARRAY_PRESET_AALTO_MCC_SUBSET:
409 nCH = 37;
410 for(ch=0; ch<nCH; ch++)
411 for(i=0; i<2; i++)
412 dirs_deg[ch][i] = __Aalto_MCCsubset_dirs_deg[ch][i];
413 break;
414 case LOUDSPEAKER_ARRAY_PRESET_AALTO_APAJA:
415 nCH = 29;
416 for(ch=0; ch<nCH; ch++)
417 for(i=0; i<2; i++)
418 dirs_deg[ch][i] = __Aalto_Apaja_dirs_deg[ch][i];
419 break;
420 case LOUDSPEAKER_ARRAY_PRESET_AALTO_LR:
421 nCH = 13;
422 for(ch=0; ch<nCH; ch++)
423 for(i=0; i<2; i++)
424 dirs_deg[ch][i] = __Aalto_LR_dirs_deg[ch][i];
425 break;
426 case LOUDSPEAKER_ARRAY_PRESET_DTU_AVIL:
427 nCH = 64;
428 for(ch=0; ch<nCH; ch++)
429 for(i=0; i<2; i++)
430 dirs_deg[ch][i] = __DTU_AVIL_dirs_deg[ch][i];
431 break;
432 case LOUDSPEAKER_ARRAY_PRESET_ZYLIA_LAB:
433 nCH = 22;
434 for(ch=0; ch<nCH; ch++)
435 for(i=0; i<2; i++)
436 dirs_deg[ch][i] = __Zylia_Lab_dirs_deg[ch][i];
437 break;
438 case LOUDSPEAKER_ARRAY_PRESET_T_DESIGN_4:
439 nCH = 4;
440 for(ch=0; ch<nCH; ch++)
441 for(i=0; i<2; i++)
442 dirs_deg[ch][i] = __Tdesign_degree_2_dirs_deg[ch][i];
443 break;
444 case LOUDSPEAKER_ARRAY_PRESET_T_DESIGN_12:
445 nCH = 12;
446 for(ch=0; ch<nCH; ch++)
447 for(i=0; i<2; i++)
448 dirs_deg[ch][i] = __Tdesign_degree_4_dirs_deg[ch][i];
449 break;
450 case LOUDSPEAKER_ARRAY_PRESET_T_DESIGN_24:
451 nCH = 24;
452 for(ch=0; ch<nCH; ch++)
453 for(i=0; i<2; i++)
454 dirs_deg[ch][i] = __Tdesign_degree_6_dirs_deg[ch][i];
455 break;
456 case LOUDSPEAKER_ARRAY_PRESET_T_DESIGN_36:
457 nCH = 36;
458 for(ch=0; ch<nCH; ch++)
459 for(i=0; i<2; i++)
460 dirs_deg[ch][i] = __Tdesign_degree_8_dirs_deg[ch][i];
461 break;
462 case LOUDSPEAKER_ARRAY_PRESET_T_DESIGN_48:
463 nCH = 48;
464 for(ch=0; ch<nCH; ch++)
465 for(i=0; i<2; i++)
466 dirs_deg[ch][i] = __Tdesign_degree_9_dirs_deg[ch][i];
467 break;
468 case LOUDSPEAKER_ARRAY_PRESET_T_DESIGN_60:
469 nCH = 60;
470 for(ch=0; ch<nCH; ch++)
471 for(i=0; i<2; i++)
472 dirs_deg[ch][i] = __Tdesign_degree_10_dirs_deg[ch][i];
473 break;
474 case LOUDSPEAKER_ARRAY_PRESET_SPH_COV_9:
475 nCH = 9;
476 for(ch=0; ch<nCH; ch++)
477 for(i=0; i<2; i++)
478 dirs_deg[ch][i] = __SphCovering_9_dirs_deg[ch][i];
479 break;
480 case LOUDSPEAKER_ARRAY_PRESET_SPH_COV_16:
481 nCH = 16;
482 for(ch=0; ch<nCH; ch++)
483 for(i=0; i<2; i++)
484 dirs_deg[ch][i] = __SphCovering_16_dirs_deg[ch][i];
485 break;
486 case LOUDSPEAKER_ARRAY_PRESET_SPH_COV_25:
487 nCH = 25;
488 for(ch=0; ch<nCH; ch++)
489 for(i=0; i<2; i++)
490 dirs_deg[ch][i] = __SphCovering_25_dirs_deg[ch][i];
491 break;
492 case LOUDSPEAKER_ARRAY_PRESET_SPH_COV_49:
493 nCH = 49;
494 for(ch=0; ch<nCH; ch++)
495 for(i=0; i<2; i++)
496 dirs_deg[ch][i] = __SphCovering_49_dirs_deg[ch][i];
497 break;
498 case LOUDSPEAKER_ARRAY_PRESET_SPH_COV_64:
499 nCH = 64;
500 for(ch=0; ch<nCH; ch++)
501 for(i=0; i<2; i++)
502 dirs_deg[ch][i] = __SphCovering_64_dirs_deg[ch][i];
503 break;
504 }
505 saf_assert(nCH>0, "Number of loudspeakers must be more than 0");
506
507 /* Fill remaining slots with default coords */
508 for(; ch<MAX_NUM_LOUDSPEAKERS; ch++)
509 for(i=0; i<2; i++)
510 dirs_deg[ch][i] = ambi_dec_defaultLoudspeakerDirections[ch][i];
511
512 /* specify new number of channels (for dynamically changing the number of TFT channels) */
513 (*newNCH) = nCH;
514
515 /* Estimate number of dimensions.
516 * (Fails if using 2D setups are not on the horizontal plane ) */
517 sum_elev = 0.0f;
518 for(i=0; i<nCH; i++)
519 sum_elev += fabsf((float)dirs_deg[i][1]);
520 if(sum_elev < 0.01f)
521 (*nDims) = 2;
522 else
523 (*nDims) = 3;
524}
LOUDSPEAKER_ARRAY_PRESETS
Available loudspeaker array presets.
Definition _common.h:103
#define MAX_NUM_OUTPUTS
Maximum number of output channels supported.
Definition _common.h:264
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
#define HYBRID_BANDS
Number of frequency bands.
const int ambi_dec_defaultNumLoudspeakers
Default number of Loudspeakers.
const float ambi_dec_defaultLoudspeakerDirections[MAX_NUM_OUTPUTS][2]
Default Loudspeaker directions.
void ambi_dec_setCodecStatus(void *const hAmbi, CODEC_STATUS newStatus)
Sets codec status (see CODEC_STATUS enum)
void ambi_dec_interpHRTFs(void *const hAmbi, float azimuth_deg, float elevation_deg, float_complex h_intrp[HYBRID_BANDS][NUM_EARS])
Interpolates between the 3 nearest HRTFs using amplitude-preserving VBAP gains.
void loadLoudspeakerArrayPreset(LOUDSPEAKER_ARRAY_PRESETS preset, _Atomic_FLOAT32 dirs_deg[MAX_NUM_LOUDSPEAKERS][2], _Atomic_INT32 *newNCH, int *nDims)
Returns the loudspeaker directions for a specified loudspeaker array preset.
A frequency-dependent Ambisonic decoder for reproducing Ambisonic sound scenes over loudspeakers.
#define MAX_NUM_LOUDSPEAKERS
Maximum permitted output channels.
#define saf_print_error(message)
Macro to print a error message along with the filename and line number.
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.
#define saf_assert(x, message)
Macro to make an assertion, along with a string explaining its purpose.
#define SAF_PI
pi constant (single precision)
const float __9pX_dirs_deg[9][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a 9.x setup.
const int __protools_mapping_discrete_to_7p0p4[11]
Indices to map a discrete bus to a 7p0p4 bus in ProTools.
const float __SphCovering_16_dirs_deg[16][2]
Directions [azimuth, Elevation] in degrees, for sphere covering: 16 dirs.
const int __protools_mapping_discrete_to_9p0p4[13]
Indices to map a discrete bus to a 9p0p4 bus in ProTools.
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.
#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 __5pX_dirs_deg[5][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a 5.x setup.
const int __protools_mapping_discrete_to_7p0[7]
Indices to map a discrete bus to a 7p0 bus in ProTools.
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 int __protools_mapping_discrete_to_LCR[3]
Indices to map a discrete bus to a LCR bus in ProTools.
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 __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 float __Aalto_Apaja_dirs_deg[29][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for the audio-visual listening room (Apaja),...
const int __protools_mapping_discrete_to_7p0p6[13]
Indices to map a discrete bus to a 7p0p6 bus in ProTools.
const int __protools_mapping_discrete_to_Quad[4]
Indices to map a discrete bus to a Quad bus in ProTools.
const float __SphCovering_9_dirs_deg[9][2]
Directions [azimuth, Elevation] in degrees, for sphere covering: 9 dirs.
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 int __protools_mapping_discrete_to_5p0p4[9]
Indices to map a discrete bus to a 5p0p4 bus in ProTools.
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 float __Tdesign_degree_4_dirs_deg[12][2]
Directions [azimuth, Elevation] in degrees, for minimum Tdesign degree: 4.
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 int __protools_mapping_discrete_to_9p0p6[15]
Indices to map a discrete bus to a 9p0p6 bus in ProTools.
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.
const int __protools_mapping_discrete_to_7p0p2[9]
Indices to map a discrete bus to a 7p0p2 bus in ProTools.
const int __protools_mapping_discrete_to_5p0[5]
Indices to map a discrete bus to a 5p0 bus in ProTools.
const float __22pX_dirs_deg[22][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a 22.x setup.
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 int __protools_mapping_discrete_to_5p0p2[7]
Indices to map a discrete bus to a 5p0p2 bus in ProTools.
const float __SphCovering_25_dirs_deg[25][2]
Directions [azimuth, Elevation] in degrees, for sphere covering: 25 dirs.
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 int __protools_mapping_discrete_to_stereo[2]
Indices to map a discrete bus to a stereo bus in ProTools.
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 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.
Contains variables for sofa file loading, HRTF interpolation, and the loudspeaker decoders.
_Atomic_INT32 N_hrir_dirs
number of HRIR directions in the current sofa file
float * itds_s
interaural-time differences for each HRIR (in seconds); N_hrirs x 1
int * hrtf_vbap_gtableIdx
N_hrtf_vbap_gtable x 3.
int hrtf_vbapTableRes[2]
[azi elev] step sizes in degrees
float * hrtf_fb_mag
magnitudes of the HRTF filterbank coefficients; nBands x nCH x N_hrirs
float * hrtf_vbap_gtableComp
N_hrtf_vbap_gtable x 3.
Main structure for ambi_dec.
_Atomic_CODEC_STATUS codecStatus
see CODEC_STATUS
float freqVector[HYBRID_BANDS]
frequency vector for time-frequency transform, in Hz
ambi_dec_codecPars * pars
codec parameters