70 int aziIndex, elevIndex, N_azi, idx3d;
72 float aziRes, elevRes, weights[1][3], itds3[3], itdInterp[1];
78 N_azi = (int)(360.0f / aziRes + 0.5f) + 1;
79 aziIndex = (int)(
matlab_fmodf(azimuth_deg + 180.0f, 360.0f) / aziRes + 0.5f);
80 elevIndex = (int)((elevation_deg + 90.0f) / elevRes + 0.5f);
81 idx3d = elevIndex * N_azi + aziIndex;
82 for (i = 0; i < 3; i++)
86 for (i = 0; i < 3; i++) {
95 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 1, 1, 3, 1,
98 (
float*)itdInterp, 1);
100 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 1, 2, 3, 1,
102 (
float*)magnitudes3[band], 2, 0,
103 (
float*)magInterp[band], 2);
111 ipd = cmplxf(0.0f, 0.0f);
112 h_intrp[band][0] = ccmulf(cmplxf(magInterp[band][0], 0.0f), cexpf(ipd));
113 h_intrp[band][1] = ccmulf(cmplxf(magInterp[band][1], 0.0f), conjf(cexpf(ipd)));
132 case LOUDSPEAKER_ARRAY_PRESET_DEFAULT:
134 case LOUDSPEAKER_ARRAY_PRESET_5PX:
136 for(ch=0; ch<nCH; ch++)
140 case LOUDSPEAKER_ARRAY_PRESET_7PX:
142 for(ch=0; ch<nCH; ch++)
146 case LOUDSPEAKER_ARRAY_PRESET_8PX:
148 for(ch=0; ch<nCH; ch++)
152 case LOUDSPEAKER_ARRAY_PRESET_9PX:
154 for(ch=0; ch<nCH; ch++)
158 case LOUDSPEAKER_ARRAY_PRESET_10PX:
160 for(ch=0; ch<nCH; ch++)
164 case LOUDSPEAKER_ARRAY_PRESET_11PX:
166 for(ch=0; ch<nCH; ch++)
170 case LOUDSPEAKER_ARRAY_PRESET_11PX_7_4:
172 for(ch=0; ch<nCH; ch++)
176 case LOUDSPEAKER_ARRAY_PRESET_13PX:
178 for(ch=0; ch<nCH; ch++)
182 case LOUDSPEAKER_ARRAY_PRESET_22PX:
184 for(ch=0; ch<nCH; ch++)
188 case LOUDSPEAKER_ARRAY_PRESET_22P2_9_10_3:
191 case LOUDSPEAKER_ARRAY_PRESET_AALTO_MCC:
193 for(ch=0; ch<nCH; ch++)
197 case LOUDSPEAKER_ARRAY_PRESET_AALTO_MCC_SUBSET:
199 for(ch=0; ch<nCH; ch++)
203 case LOUDSPEAKER_ARRAY_PRESET_AALTO_APAJA:
205 for(ch=0; ch<nCH; ch++)
209 case LOUDSPEAKER_ARRAY_PRESET_AALTO_LR:
211 for(ch=0; ch<nCH; ch++)
215 case LOUDSPEAKER_ARRAY_PRESET_DTU_AVIL:
217 for(ch=0; ch<nCH; ch++)
221 case LOUDSPEAKER_ARRAY_PRESET_ZYLIA_LAB:
223 for(ch=0; ch<nCH; ch++)
227 case LOUDSPEAKER_ARRAY_PRESET_T_DESIGN_4:
229 for(ch=0; ch<nCH; ch++)
233 case LOUDSPEAKER_ARRAY_PRESET_T_DESIGN_12:
235 for(ch=0; ch<nCH; ch++)
239 case LOUDSPEAKER_ARRAY_PRESET_T_DESIGN_24:
241 for(ch=0; ch<nCH; ch++)
245 case LOUDSPEAKER_ARRAY_PRESET_T_DESIGN_36:
247 for(ch=0; ch<nCH; ch++)
251 case LOUDSPEAKER_ARRAY_PRESET_T_DESIGN_48:
253 for(ch=0; ch<nCH; ch++)
257 case LOUDSPEAKER_ARRAY_PRESET_T_DESIGN_60:
259 for(ch=0; ch<nCH; ch++)
263 case LOUDSPEAKER_ARRAY_PRESET_SPH_COV_9:
265 for(ch=0; ch<nCH; ch++)
269 case LOUDSPEAKER_ARRAY_PRESET_SPH_COV_16:
271 for(ch=0; ch<nCH; ch++)
275 case LOUDSPEAKER_ARRAY_PRESET_SPH_COV_25:
277 for(ch=0; ch<nCH; ch++)
281 case LOUDSPEAKER_ARRAY_PRESET_SPH_COV_49:
283 for(ch=0; ch<nCH; ch++)
287 case LOUDSPEAKER_ARRAY_PRESET_SPH_COV_64:
289 for(ch=0; ch<nCH; ch++)
294 saf_assert(nCH>0,
"Number of loudspeakers must be more than 0");
308 sum_elev += fabsf(dirs_deg[i][1]);
LOUDSPEAKER_ARRAY_PRESETS
Available loudspeaker array presets.
CODEC_STATUS
Current status of the codec.
@ CODEC_STATUS_NOT_INITIALISED
Codec has not yet been initialised, or the codec configuration has changed.
@ CODEC_STATUS_INITIALISING
Codec is currently being initialised, input audio should not be processed.
#define HYBRID_BANDS
Number of frequency bands.
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, float dirs_deg[MAX_NUM_LOUDSPEAKERS][2], int *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.
#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 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.
#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 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 __default_LScoords128_deg[128][2]
Default Loudspeaker directions [azimuth, Elevation] - to replace above!
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 float __SphCovering_9_dirs_deg[9][2]
Directions [azimuth, Elevation] in degrees, for sphere covering: 9 dirs.
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 __Tdesign_degree_6_dirs_deg[24][2]
Directions [azimuth, Elevation] in degrees, for minimum Tdesign degree: 6.
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 float __22pX_dirs_deg[22][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a 22.x setup.
const float __SphCovering_25_dirs_deg[25][2]
Directions [azimuth, Elevation] in degrees, for sphere covering: 25 dirs.
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.
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
int N_hrir_dirs
number of HRIR directions in the current sofa file
float * hrtf_vbap_gtableComp
N_hrtf_vbap_gtable x 3.
Main structure for ambi_dec.
CODEC_STATUS codecStatus
see CODEC_STATUS
float freqVector[HYBRID_BANDS]
frequency vector for time-frequency transform, in Hz
ambi_dec_codecPars * pars
codec parameters