SAF
Loading...
Searching...
No Matches
saf_vbap.h
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
33#ifndef __SAF_VBAP_H_INCLUDED__
34#define __SAF_VBAP_H_INCLUDED__
35
36#ifdef __cplusplus
37extern "C" {
38#endif /* __cplusplus */
39
40/* ========================================================================== */
41/* Misc. Functions */
42/* ========================================================================== */
43
73void generateVBAPgainTable3D_srcs(/* Input arguments */
74 float* src_dirs_deg,
75 int S,
76 float* ls_dirs_deg,
77 int L,
78 int omitLargeTriangles,
79 int enableDummies,
80 float spread,
81 /* Output arguments */
82 float** gtable,
83 int* N_gtable,
84 int* nTriangles);
85
129void generateVBAPgainTable3D(/* Input arguments */
130 float* ls_dirs_deg,
131 int L,
132 int az_res_deg,
133 int el_res_deg,
134 int omitLargeTriangles,
135 int enableDummies,
136 float spread,
137 /* Output arguments */
138 float** gtable,
139 int* N_gtable,
140 int* nTriangles);
141
174void compressVBAPgainTable3D(/* Input arguments */
175 float* vbap_gtable,
176 int nTable,
177 int nDirs,
178 /* Output arguments */
179 float* vbap_gtableComp,
180 int* vbap_gtableIdx);
181
192void VBAPgainTable2InterpTable(float* vbap_gtable,
193 int nTable,
194 int nDirs);
195
215void generateVBAPgainTable2D_srcs(/* Input arguments */
216 float* src_dirs_deg,
217 int S,
218 float* ls_dirs_deg,
219 int L,
220 /* Output arguments */
221 float** gtable,
222 int* N_gtable,
223 int* nPairs);
224
251void generateVBAPgainTable2D(/* Input arguments */
252 float* ls_dirs_deg,
253 int L,
254 int az_res_deg,
255 /* Output arguments */
256 float** gtable,
257 int* N_gtable,
258 int* nPairs);
259
292void getPvalues(/* Input arguments */
293 float DTT,
294 float* freq,
295 int nFreq,
296 /* Output arguments */
297 float* pValues);
298
299
300/* ========================================================================== */
301/* Main Functions */
302/* ========================================================================== */
303/*
304 * Note that the main functions are largely based on the VBAP Matlab library
305 * (BSD-3-Clause License) found here:
306 * https://github.com/polarch/Vector-Base-Amplitude-Panning
307 */
308
328void findLsTriplets(/* Input Arguments */
329 float* ls_dirs_deg,
330 int L,
331 int omitLargeTriangles,
332 /* Output Arguments */
333 float** out_vertices,
334 int* numOutVertices,
335 int** out_faces,
336 int* numOutFaces);
337
348void invertLsMtx3D(/* Input Arguments */
349 float* U_spkr,
350 int* ls_groups,
351 int N_group,
352 /* Output Arguments */
353 float** layoutInvMtx);
354
368void getSpreadSrcDirs3D(/* Input Arguments */
369 float src_azi_rad,
370 float src_elev_rad,
371 float spread,
372 int num_src,
373 int num_rings_3d,
374 /* Output Arguments */
375 float* U_spread);
376
393void vbap3D(/* Input Arguments */
394 float* src_dirs,
395 int src_num,
396 int ls_num,
397 int* ls_groups,
398 int nFaces,
399 float spread,
400 float* layoutInvMtx,
401 /* Output Arguments */
402 float** GainMtx);
403
412void findLsPairs(/* Input Arguments */
413 float* ls_dirs_deg,
414 int L,
415 /* Output Arguments */
416 int** out_pairs,
417 int* numOutPairs);
418
429void invertLsMtx2D(/* Input Arguments */
430 float* U_spkr,
431 int* ls_pairs,
432 int N_pairs,
433 /* Output Arguments */
434 float** layoutInvMtx);
435
450void vbap2D(/* Input Arguments */
451 float* src_dirs,
452 int src_num,
453 int ls_num,
454 int* ls_pairs,
455 int N_pairs,
456 float* layoutInvMtx,
457 /* Output Arguments */
458 float** GainMtx);
459
460
461#ifdef __cplusplus
462} /* extern "C" */
463#endif /* __cplusplus */
464
465#endif /* __SAF_VBAP_H_INCLUDED__ */
466
467 /* doxygen addtogroup VBAP */
void findLsTriplets(float *ls_dirs_deg, int L, int omitLargeTriangles, float **out_vertices, int *numOutVertices, int **out_faces, int *numOutFaces)
Computes the 3D convex-hull of a spherical grid of loudspeaker directions.
Definition saf_vbap.c:500
void vbap2D(float *src_dirs, int src_num, int ls_num, int *ls_pairs, int N_pairs, float *layoutInvMtx, float **GainMtx)
Calculates 2D VBAP gains for pre-calculated loudspeaker pairs and predefined source positions.
Definition saf_vbap.c:963
void invertLsMtx3D(float *U_spkr, int *ls_groups, int N_group, float **layoutInvMtx)
Inverts a 3x3 loudspeaker matrix.
Definition saf_vbap.c:677
void getSpreadSrcDirs3D(float src_azi_rad, float src_elev_rad, float spread, int num_src, int num_rings_3d, float *U_spread)
Computes a set of points which surround the source direction given a specific degree of spread.
Definition saf_vbap.c:708
void findLsPairs(float *ls_dirs_deg, int L, int **out_pairs, int *numOutPairs)
Calculates loudspeaker pairs for a circular grid of loudspeaker directions.
Definition saf_vbap.c:899
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 generateVBAPgainTable3D_srcs(float *src_dirs_deg, int S, float *ls_dirs_deg, int L, int omitLargeTriangles, int enableDummies, float spread, float **gtable, int *N_gtable, int *nTriangles)
Generates a 3-D VBAP [1] gain table based on specified source and loudspeaker directions,...
Definition saf_vbap.c:53
void VBAPgainTable2InterpTable(float *vbap_gtable, int nTable, int nDirs)
Renormalises a VBAP gain table (in-place) so it may be utilised for interpolation of data (for exampl...
Definition saf_vbap.c:370
void generateVBAPgainTable2D_srcs(float *src_dirs_deg, int S, float *ls_dirs_deg, int L, float **gtable, int *N_gtable, int *nPairs)
Generates a 2-D VBAP gain table based on specified source and loudspeaker directions.
Definition saf_vbap.c:391
void generateVBAPgainTable2D(float *ls_dirs_deg, int L, int az_res_deg, float **gtable, int *N_gtable, int *nPairs)
Generates a 2-D VBAP gain table based on specified loudspeaker directions.
Definition saf_vbap.c:429
void vbap3D(float *src_dirs, int src_num, int ls_num, int *ls_groups, int nFaces, float spread, float *layoutInvMtx, float **GainMtx)
Calculates 3D VBAP gains given pre-computed loudspeaker triangles for each source direction.
Definition saf_vbap.c:787
void invertLsMtx2D(float *U_spkr, int *ls_pairs, int N_pairs, float **layoutInvMtx)
Inverts a 2x2 loudspeaker matrix.
Definition saf_vbap.c:931
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 getPvalues(float DTT, float *freq, int nFreq, float *pValues)
Calculates the frequency dependent pValues, which can be applied to ENERGY normalised VBAP gains,...
Definition saf_vbap.c:476