SAF
Loading...
Searching...
No Matches
saf_hoa.h
Go to the documentation of this file.
1/*
2 * Copyright 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
34#ifndef __SAF_HOA_H_INCLUDED__
35#define __SAF_HOA_H_INCLUDED__
36
37#ifdef __cplusplus
38extern "C" {
39#endif /* __cplusplus */
40
42
43/* ========================================================================== */
44/* Enums */
45/* ========================================================================== */
46
112
173
193
214
215
216/* ========================================================================== */
217/* Misc. Functions */
218/* ========================================================================== */
219
237void convertHOAChannelConvention(/* Input Arguments */
238 float* insig,
239 int order,
240 int signalLength,
241 HOA_CH_ORDER inConvention,
242 HOA_CH_ORDER outConvention);
243
262void convertHOANormConvention(/* Input Arguments */
263 float* insig,
264 int order,
265 int signalLength,
266 HOA_NORM inConvention,
267 HOA_NORM outConvention);
268
293void getRSH(/* Input Arguments */
294 int order,
295 float* dirs_deg,
296 int nDirs,
297 /* Output Arguments */
298 float* Y);
299
328void getRSH_recur(/* Input Arguments */
329 int order,
330 float* dirs_deg,
331 int nDirs,
332 /* Output Arguments */
333 float* Y);
334
335
336/* ========================================================================== */
337/* Main Functions */
338/* ========================================================================== */
339
363void getMaxREweights(/* Input Arguments */
364 int order,
365 int diagMtxFlag,
366 /* Output Arguments */
367 float* a_n);
368
388void truncationEQ(/* Input arguments */
389 float* w_n,
390 int order_truncated,
391 int order_target,
392 double* kr,
393 int nBands,
394 float softThreshold,
395 /* Output arguments */
396 float* gain);
397
413void getLoudspeakerDecoderMtx(/* Input Arguments */
414 float* ls_dirs_deg,
415 int nLS,
417 int order,
418 int enableMaxrE,
419 /* Output Arguments */
420 float* decMtx);
421
447void getBinauralAmbiDecoderMtx(/* Input Arguments */
448 float_complex* hrtfs,
449 float* hrtf_dirs_deg,
450 int N_dirs,
451 int N_bands,
453 int order,
454 float* freqVector,
455 float* itd_s,
456 float* weights,
457 int enableDiffCM,
458 int enableMaxrE,
459 /* Output Arguments */
460 float_complex* decMtx);
461
484void getBinauralAmbiDecoderFilters(/* Input Arguments */
485 float_complex* hrtfs,
486 float* hrtf_dirs_deg,
487 int N_dirs,
488 int fftSize,
489 float fs,
491 int order,
492 float* itd_s,
493 float* weights,
494 int enableDiffCM,
495 int enableMaxrE,
496 /* Output Arguments */
497 float* decFilters);
498
520void applyDiffCovMatching(/* Input Arguments */
521 float_complex* hrtfs,
522 float* hrtf_dirs_deg,
523 int N_dirs,
524 int N_bands,
525 int order,
526 float* weights,
527 /* Input/Output Arguments */
528 float_complex* decMtx);
529
530
531#ifdef __cplusplus
532} /* extern "C" */
533#endif /* __cplusplus */
534
535#endif /* __SAF_HOA_H_INCLUDED__ */
536
537 /* doxygen addtogroup HOA */
void applyDiffCovMatching(float_complex *hrtfs, float *hrtf_dirs_deg, int N_dirs, int N_bands, int order, float *weights, float_complex *decMtx)
Imposes a diffuse-field covariance constraint on a given binaural decoding matrix,...
Definition saf_hoa.c:503
void getBinauralAmbiDecoderMtx(float_complex *hrtfs, float *hrtf_dirs_deg, int N_dirs, int N_bands, BINAURAL_AMBI_DECODER_METHODS method, int order, float *freqVector, float *itd_s, float *weights, int enableDiffCM, int enableMaxrE, float_complex *decMtx)
Computes binaural ambisonic decoding matrices (one per frequency) at a specific order,...
Definition saf_hoa.c:395
void convertHOAChannelConvention(float *insig, int order, int signalLength, HOA_CH_ORDER inConvention, HOA_CH_ORDER outConvention)
Converts an Ambisonic signal from one channel ordering convention to another.
Definition saf_hoa.c:41
HOA_CH_ORDER
Available Ambisonic channel ordering conventions.
Definition saf_hoa.h:183
void getLoudspeakerDecoderMtx(float *ls_dirs_deg, int nLS, LOUDSPEAKER_AMBI_DECODER_METHODS method, int order, int enableMaxrE, float *decMtx)
Computes an ambisonic decoding matrix of a specific order, for a given loudspeaker layout.
Definition saf_hoa.c:327
void getBinauralAmbiDecoderFilters(float_complex *hrtfs, float *hrtf_dirs_deg, int N_dirs, int fftSize, float fs, BINAURAL_AMBI_DECODER_METHODS method, int order, float *itd_s, float *weights, int enableDiffCM, int enableMaxrE, float *decFilters)
Computes binaural ambisonic decoding filters for a given HRTF set.
Definition saf_hoa.c:453
LOUDSPEAKER_AMBI_DECODER_METHODS
Ambisonic decoding options for loudspeaker playback.
Definition saf_hoa.h:61
void getRSH(int order, float *dirs_deg, int nDirs, float *Y)
Computes real-valued spherical harmonics [1] for each given direction on the unit sphere.
Definition saf_hoa.c:119
HOA_NORM
Available Ambisonic normalisation conventions.
Definition saf_hoa.h:203
void convertHOANormConvention(float *insig, int order, int signalLength, HOA_NORM inConvention, HOA_NORM outConvention)
Converts an Ambisonic signal from one normalisation convention to another.
Definition saf_hoa.c:73
BINAURAL_AMBI_DECODER_METHODS
Ambisonic decoding options for binaural/headphone playback.
Definition saf_hoa.h:134
void getRSH_recur(int order, float *dirs_deg, int nDirs, float *Y)
Computes real-valued spherical harmonics [1] for each given direction on the unit sphere.
Definition saf_hoa.c:153
void getMaxREweights(int order, int diagMtxFlag, float *a_n)
Computes the weights required to manipulate a hyper-cardioid beam-pattern, such that it has maximum e...
Definition saf_hoa.c:236
void truncationEQ(float *w_n, int order_truncated, int order_target, double *kr, int nBands, float softThreshold, float *gain)
Filter that equalises the high frequency roll-off due to SH truncation and tapering; as described in ...
Definition saf_hoa.c:270
@ HOA_CH_ORDER_FUMA
Furse-Malham (FuMa) convention, often used by older recordings.
Definition saf_hoa.h:187
@ HOA_CH_ORDER_ACN
Ambisonic Channel numbering (ACN) convention, which is employed by all spherical harmonic related fun...
Definition saf_hoa.h:184
@ LOUDSPEAKER_DECODER_ALLRAD
All-Round Ambisonic Decoder (AllRAD): SAD decoding to a t-design, panned for the target loudspeaker d...
Definition saf_hoa.h:109
@ LOUDSPEAKER_DECODER_SAD
Sampling Ambisonic Decoder (SAD): transpose of the loudspeaker spherical harmonic matrix,...
Definition saf_hoa.h:76
@ LOUDSPEAKER_DECODER_DEFAULT
The default decoder is LOUDSPEAKER_DECODER_SAD.
Definition saf_hoa.h:65
@ LOUDSPEAKER_DECODER_EPAD
Energy-Preserving Ambisonic Decoder (EPAD) [1].
Definition saf_hoa.h:96
@ LOUDSPEAKER_DECODER_MMD
Mode-Matching Decoder (MMD): pseudo-inverse of the loudspeaker spherical harmonic matrix.
Definition saf_hoa.h:89
@ HOA_NORM_FUMA
Furse-Malham (FuMa) convention.
Definition saf_hoa.h:208
@ HOA_NORM_SN3D
Schmidt semi-normalisation (SN3D) convention, as used by the AmbiX standard.
Definition saf_hoa.h:206
@ HOA_NORM_N3D
Orthonormalised (N3D) convention, which is the default convention used by SAF.
Definition saf_hoa.h:204
@ BINAURAL_DECODER_MAGLS
Magnitude least-squares decoder [3].
Definition saf_hoa.h:170
@ BINAURAL_DECODER_LS
Least-squares (LS) decoder.
Definition saf_hoa.h:144
@ BINAURAL_DECODER_SPR
Spatial resampling decoder (on the same lines as the virtual loudspeaker approach) [4].
Definition saf_hoa.h:157
@ BINAURAL_DECODER_DEFAULT
The default decoder is BINAURAL_DECODER_LS.
Definition saf_hoa.h:138
@ BINAURAL_DECODER_TA
Time-alignment decoder [2].
Definition saf_hoa.h:165
@ BINAURAL_DECODER_LSDIFFEQ
Least-squares (LS) decoder with diffuse-field spectral equalisation [1].
Definition saf_hoa.h:152
Contains wrappers for handling complex numbers across both C99-compliant compilers and Microsoft Visu...