46#ifndef __AMBI_DEC_INTERNAL_H_INCLUDED__
47#define __AMBI_DEC_INTERNAL_H_INCLUDED__
61#if !defined(AMBI_DEC_FRAME_SIZE)
62# if defined(FRAME_SIZE)
63# define AMBI_DEC_FRAME_SIZE ( FRAME_SIZE )
65# define AMBI_DEC_FRAME_SIZE ( 128 )
68#define HOP_SIZE ( 128 )
69#define HYBRID_BANDS ( HOP_SIZE + 5 )
70#define TIME_SLOTS ( AMBI_DEC_FRAME_SIZE / HOP_SIZE )
71#define MAX_NUM_LOUDSPEAKERS ( MAX_NUM_OUTPUTS )
72#define MIN_NUM_LOUDSPEAKERS ( 4 )
73#define NUM_DECODERS ( 2 )
76#if (AMBI_DEC_FRAME_SIZE % HOP_SIZE != 0)
77# error "AMBI_DEC_FRAME_SIZE must be an integer multiple of HOP_SIZE"
80#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__)
96typedef struct _ambi_dec_codecPars
135typedef struct _ambi_dec
#define MAX_SH_ORDER
Maximum supported Ambisonic order.
LOUDSPEAKER_ARRAY_PRESETS
Available loudspeaker array presets.
CODEC_STATUS
Current status of the codec.
#define HYBRID_BANDS
Number of frequency bands.
A frequency-dependent Ambisonic decoder for reproducing Ambisonic sound scenes over loudspeakers.
AMBI_DEC_DIFFUSE_FIELD_EQ_APPROACH
When using mixed order decoding (i.e.
AMBI_DEC_DECODING_METHODS
Available decoding methods.
void loadLoudspeakerArrayPreset(LOUDSPEAKER_ARRAY_PRESETS preset, _Atomic_FLOAT32 dirs_deg[MAX_NUM_LOUDSPEAKERS][2], _Atomic_INT32 *nCH, int *nDims)
Returns the loudspeaker directions for a specified loudspeaker array preset.
void ambi_dec_setCodecStatus(void *const hCmp, CODEC_STATUS newStatus)
Sets codec status (see CODEC_STATUS enum)
#define HYBRID_BANDS
Number of frequency bands.
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.
#define MAX_NUM_LOUDSPEAKERS
Maximum permitted output channels.
#define NUM_DECODERS
One for low-frequencies and another for high-frequencies.
#define NUM_EARS
2 (true for most humans)
Main include header for the Spatial_Audio_Framework (SAF)
Include header for SAF externals.
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_complex hrtf_interp[MAX_NUM_LOUDSPEAKERS][HYBRID_BANDS][NUM_EARS]
interpolated HRTFs
_Atomic_INT32 hrir_len
length of the HRIRs, this can be truncated, see "saf_sofa_reader.h"
char * sofa_filepath
absolute/relevative file path for a sofa file
float * M_dec_maxrE[NUM_DECODERS][MAX_SH_ORDER]
ambisonic decoding matrices with maxrE weighting ([0] for low-freq, [1] for high-freq); FLAT: nLoudsp...
float * M_dec[NUM_DECODERS][MAX_SH_ORDER]
ambisonic decoding matrices ([0] for low-freq, [1] for high-freq); FLAT: nLoudspeakers x nSH
int hrtf_nTriangles
number of triangle groups after triangulation
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_complex * hrtf_fb
HRTF filterbank coefficients; nBands x nCH x N_hrirs.
float_complex * M_dec_cmplx_maxrE[NUM_DECODERS][MAX_SH_ORDER]
complex ambisonic decoding matrices with maxrE weighting ([0] for low-freq, [1] for high-freq); FLAT:...
_Atomic_INT32 hrir_fs
sampling rate of the HRIRs, should ideally match the host sampling rate, although not required
float * hrtf_fb_mag
magnitudes of the HRTF filterbank coefficients; nBands x nCH x N_hrirs
int N_hrtf_vbap_gtable
number of interpolation directions
float_complex * M_dec_cmplx[NUM_DECODERS][MAX_SH_ORDER]
complex ambisonic decoding matrices ([0] for low-freq, [1] for high-freq); FLAT: nLoudspeakers x nSH
float * weights
grid integration weights of hrirs; N_hrirs x 1
float * hrtf_vbap_gtableComp
N_hrtf_vbap_gtable x 3.
float * hrirs
time domain HRIRs; N_hrir_dirs x 2 x hrir_len
float M_norm[NUM_DECODERS][MAX_SH_ORDER][2]
norm coefficients to preserve omni energy/amplitude between different orders and decoders
float * hrir_dirs_deg
directions of the HRIRs in degrees [azi elev]; N_hrir_dirs x 2
Main structure for ambi_dec.
_Atomic_AMBI_DEC_DIFFUSE_FIELD_EQ_APPROACH diffEQmode[NUM_DECODERS]
diffuse-field EQ approach; see AMBI_DEC_DIFFUSE_FIELD_EQ_APPROACH enum
_Atomic_INT32 masterOrder
Current maximum/master decoding order.
_Atomic_INT32 new_masterOrder
if new_masterOrder != masterOrder, ambi_dec is reinitialised (current value will be replaced by this ...
_Atomic_INT32 reinit_hrtfsFLAG
0: no init required, 1: init required
_Atomic_CH_ORDER chOrdering
Ambisonic channel order convention (see CH_ORDER)
_Atomic_INT32 nLoudpkrs
number of loudspeakers/virtual loudspeakers
int afSTFTdelay
for host delay compensation
int loudpkrs_nDims
dimensionality of the current loudspeaker set-up
float ** SHFrameTD
Input spherical harmonic (SH) signals in the time-domain; MAX_NUM_SH_SIGNALS x AMBI_DEC_FRAME_SIZE.
_Atomic_FLOAT32 transitionFreq
transition frequency for the 2 decoders, in Hz
float_complex *** binframeTF
Output binaural signals in the time-frequency domain; HYBRID_BANDS x NUM_EARS x TIME_SLOTS.
_Atomic_INT32 recalc_hrtf_interpFLAG[MAX_NUM_LOUDSPEAKERS]
0: no init required, 1: init required
_Atomic_INT32 enableHRIRsPreProc
flag to apply pre-processing to the currently loaded HRTFs
_Atomic_NORM_TYPES norm
Ambisonic normalisation convention (see NORM_TYPES)
_Atomic_FLOAT32 loudpkrs_dirs_deg[MAX_NUM_LOUDSPEAKERS][2]
loudspeaker directions in degrees [azi, elev]
_Atomic_INT32 orderPerBand[HYBRID_BANDS]
Ambisonic decoding order per frequency band 1..SH_ORDER.
_Atomic_AMBI_DEC_DECODING_METHODS dec_method[NUM_DECODERS]
decoding methods for each decoder, see AMBI_DEC_DECODING_METHODS enum
void * hSTFT
afSTFT handle
_Atomic_INT32 useDefaultHRIRsFLAG
1: use default HRIRs in database, 0: use those from SOFA file
float_complex *** SHframeTF
Input spherical harmonic (SH) signals in the time-frequency domain; HYBRID_BANDS x MAX_NUM_SH_SIGNALS...
float ** outputFrameTD
Output loudspeaker or binaural signals in the time-domain; MAX_NUM_LOUDSPEAKERS x AMBI_DEC_FRAME_SIZE...
_Atomic_INT32 new_binauraliseLS
if new_binauraliseLS != binauraliseLS, ambi_dec is reinitialised (current value will be replaced by t...
_Atomic_PROC_STATUS procStatus
see PROC_STATUS
_Atomic_INT32 binauraliseLS
1: convolve loudspeaker signals with HRTFs, 0: output loudspeaker signals
_Atomic_INT32 fs
host sampling rate
_Atomic_CODEC_STATUS codecStatus
see CODEC_STATUS
_Atomic_INT32 rE_WEIGHT[NUM_DECODERS]
0:disabled, 1: enable max_rE weight
float freqVector[HYBRID_BANDS]
frequency vector for time-frequency transform, in Hz
char * progressBarText
Current (re)initialisation step, string.
_Atomic_FLOAT32 progressBar0_1
Current (re)initialisation progress, between [0..1].
ambi_dec_codecPars * pars
codec parameters
float_complex *** outputframeTF
Output loudspeaker signals in the time-frequency domain; HYBRID_BANDS x MAX_NUM_LOUDSPEAKERS x TIME_S...
_Atomic_INT32 new_nLoudpkrs
if new_nLoudpkrs != nLoudpkrs, afSTFT is reinitialised (current value will be replaced by this after ...