SAF
Loading...
Searching...
No Matches
ambi_dec.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
26
55
56#ifndef __AMBI_DEC_H_INCLUDED__
57#define __AMBI_DEC_H_INCLUDED__
58
59#include "_common.h"
60
61#ifdef __cplusplus
62extern "C" {
63#endif /* __cplusplus */
64
65/* ========================================================================== */
66/* Presets + Constants */
67/* ========================================================================== */
68
80
82#define AMBI_DEC_NUM_DECODING_METHODS ( 4 )
83
97
99#define AMBI_DEC_TRANSITION_MIN_VALUE ( 500.0f )
100
102#define AMBI_DEC_TRANSITION_MAX_VALUE ( 2000.0f )
103
105extern const int ambi_dec_defaultNumLoudspeakers;
106
109
110
111/* ========================================================================== */
112/* Main Functions */
113/* ========================================================================== */
114
120void ambi_dec_create(void** const phAmbi);
121
127void ambi_dec_destroy(void** const phAmbi);
128
137void ambi_dec_init(void* const hAmbi,
138 int samplerate);
139
155void ambi_dec_initCodec(void* const hAmbi);
156
167void ambi_dec_process(void* const hAmbi,
168 const float *const * inputs,
169 float* const* outputs,
170 int nInputs,
171 int nOutputs,
172 int nSamples);
173
174
175/* ========================================================================== */
176/* Set Functions */
177/* ========================================================================== */
178
183void ambi_dec_refreshSettings(void* const hAmbi);
184
194void ambi_dec_setMasterDecOrder(void* const hAmbi, int newValue);
195
205void ambi_dec_setDecOrder(void* const hAmbi, int newValue, int bandIdx);
206
215void ambi_dec_setDecOrderAllBands(void* const hAmbi, int newValue);
216
224void ambi_dec_setLoudspeakerAzi_deg(void* const hAmbi,
225 int index,
226 float newAzi_deg);
227
235void ambi_dec_setLoudspeakerElev_deg(void* const hAmbi,
236 int index,
237 float newElev_deg);
238
242void ambi_dec_setNumLoudspeakers(void* const hAmbi, int new_nLoudspeakers);
243
252void ambi_dec_setBinauraliseLSflag(void* const hAmbi, int newState);
253
265void ambi_dec_setUseDefaultHRIRsflag(void* const hAmbi, int newState);
266
278void ambi_dec_setSofaFilePath(void* const hAmbi, const char* path);
279
281void ambi_dec_setEnableHRIRsPreProc(void* const hAmbi, int newState);
282
293void ambi_dec_setSourcePreset(void* const hAmbi, int newPresetID);
294
301void ambi_dec_setOutputConfigPreset(void* const hAmbi, int newPresetID);
302
307void ambi_dec_setChOrder(void* const hAmbi, int newOrder);
308
313void ambi_dec_setNormType(void* const hAmbi, int newType);
314
324void ambi_dec_setDecMethod(void* const hAmbi, int index, int newID);
325
334void ambi_dec_setDecEnableMaxrE(void* const hAmbi, int index, int newID);
335
349void ambi_dec_setDecNormType(void* const hAmbi, int index, int newID);
350
358void ambi_dec_setTransitionFreq(void* const hAmbi, float newValue);
359
360
361/* ========================================================================== */
362/* Get Functions */
363/* ========================================================================== */
364
369int ambi_dec_getFrameSize(void);
370
372CODEC_STATUS ambi_dec_getCodecStatus(void* const hAmbi);
373
379float ambi_dec_getProgressBar0_1(void* const hAmbi);
380
387void ambi_dec_getProgressBarText(void* const hAmbi, char* text);
388
390int ambi_dec_getMasterDecOrder(void* const hAmbi);
391
396int ambi_dec_getDecOrder(void* const hAmbi, int bandIdx);
397
399int ambi_dec_getDecOrderAllBands(void* const hAmbi);
400
409void ambi_dec_getDecOrderHandle(void* const hAmbi,
410 float** pX_vector,
411 int** pY_values,
412 int* pNpoints);
413
416
418float ambi_dec_getLoudspeakerAzi_deg(void* const hAmbi, int index);
419
421float ambi_dec_getLoudspeakerElev_deg(void* const hAmbi, int index);
422
424int ambi_dec_getNumLoudspeakers(void* const hAmbi);
425
428
433int ambi_dec_getNSHrequired(void* const hAmbi);
434
440int ambi_dec_getBinauraliseLSflag(void* const hAmbi);
441
450int ambi_dec_getUseDefaultHRIRsflag(void* const hAmbi);
451
459char* ambi_dec_getSofaFilePath(void* const hAmbi);
460
465int ambi_dec_getEnableHRIRsPreProc(void* const hAmbi);
466
472int ambi_dec_getChOrder(void* const hAmbi);
473
479int ambi_dec_getNormType(void* const hAmbi);
480
485int ambi_dec_getDecMethod(void* const hAmbi, int index);
486
495int ambi_dec_getDecEnableMaxrE(void* const hAmbi, int index);
496
508int ambi_dec_getDecNormType(void* const hAmbi, int index);
509
514float ambi_dec_getTransitionFreq(void* const hAmbi);
515
517int ambi_dec_getHRIRsamplerate(void* const hAmbi);
518
520int ambi_dec_getDAWsamplerate(void* const hAmbi);
521
527
528
529#ifdef __cplusplus
530} /* extern "C" */
531#endif /* __cplusplus */
532
533#endif /* __AMBI_DEC_H_INCLUDED__ */
A bunch of things that are common to many of the saf examples.
#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
void ambi_dec_setDecOrderAllBands(void *const hAmbi, int newValue)
Sets the decoding order for all frequency bands.
Definition ambi_dec.c:661
void ambi_dec_create(void **const phAmbi)
Creates an instance of the ambi_dec.
Definition ambi_dec.c:49
int ambi_dec_getMaxNumLoudspeakers(void)
Returns the maximum number of loudspeakers supported by ambi_dec.
Definition ambi_dec.c:945
int ambi_dec_getNumLoudspeakers(void *const hAmbi)
Returns the number of loudspeakers in the current layout.
Definition ambi_dec.c:939
int ambi_dec_getMasterDecOrder(void *const hAmbi)
Returns the master/maximum decoding order (see SH_ORDERS enum)
Definition ambi_dec.c:890
int ambi_dec_getNSHrequired(void *const hAmbi)
Returns the number of spherical harmonic signals required by the current decoding order: (current_ord...
Definition ambi_dec.c:950
void ambi_dec_setDecOrder(void *const hAmbi, int newValue, int bandIdx)
Sets the decoding order for a given frequency band.
Definition ambi_dec.c:655
float ambi_dec_getProgressBar0_1(void *const hAmbi)
(Optional) Returns current intialisation/processing progress, between 0..1
Definition ambi_dec.c:878
int ambi_dec_getEnableHRIRsPreProc(void *const hAmbi)
Returns the flag indicating whether the pre-processing applied to the HRTFs is enabled (1) or disable...
Definition ambi_dec.c:978
const int ambi_dec_defaultNumLoudspeakers
Default number of Loudspeakers.
void ambi_dec_init(void *const hAmbi, int samplerate)
Initialises an instance of ambi_dec with default settings.
Definition ambi_dec.c:173
void ambi_dec_setBinauraliseLSflag(void *const hAmbi, int newState)
Sets flag to dictate whether the output loudspeaker signals should be binauralised.
Definition ambi_dec.c:709
float ambi_dec_getLoudspeakerElev_deg(void *const hAmbi, int index)
Returns the loudspeaker elevation in degrees for a given index.
Definition ambi_dec.c:933
void ambi_dec_setChOrder(void *const hAmbi, int newOrder)
Sets the Ambisonic channel ordering convention to decode with, in order to match the convention emplo...
Definition ambi_dec.c:825
int ambi_dec_getDecNormType(void *const hAmbi, int index)
Returns the current equalisation approach for one of the decoders (see AMBI_DEC_DIFFUSE_FIELD_EQ_APPR...
Definition ambi_dec.c:1008
int ambi_dec_getDecOrder(void *const hAmbi, int bandIdx)
Returns the decoding order for a given frequency band index (see SH_ORDERS enum)
Definition ambi_dec.c:896
void ambi_dec_getProgressBarText(void *const hAmbi, char *text)
(Optional) Returns current intialisation/processing progress text
Definition ambi_dec.c:884
int ambi_dec_getFrameSize(void)
Returns the processing framesize (i.e., number of samples processed with every _process() call )
Definition ambi_dec.c:867
int ambi_dec_getNormType(void *const hAmbi)
Returns the Ambisonic normalisation convention currently being usedto decode with,...
Definition ambi_dec.c:990
int ambi_dec_getHRIRsamplerate(void *const hAmbi)
Returns the HRIR sample rate.
Definition ambi_dec.c:1020
void ambi_dec_setDecEnableMaxrE(void *const hAmbi, int index, int newID)
Sets a flag to enable/disable (1 or 0) the max_rE weighting for one of the decoders.
Definition ambi_dec.c:846
void ambi_dec_initCodec(void *const hAmbi)
Intialises the codec variables, based on current global/user parameters.
Definition ambi_dec.c:191
void ambi_dec_setSofaFilePath(void *const hAmbi, const char *path)
Sets the file path for a .sofa file, in order to employ a custom HRIR set for the decoding.
Definition ambi_dec.c:728
int ambi_dec_getUseDefaultHRIRsflag(void *const hAmbi)
Returns the value of a flag used to dictate whether the default HRIRs in the Spatial_Audio_Framework ...
Definition ambi_dec.c:962
void ambi_dec_process(void *const hAmbi, const float *const *inputs, float *const *outputs, int nInputs, int nOutputs, int nSamples)
Decodes input spherical harmonic signals to the loudspeaker channels.
Definition ambi_dec.c:509
void ambi_dec_setSourcePreset(void *const hAmbi, int newPresetID)
Sets the source preset (ideal SH or SH signals derived from mic arrays)
Definition ambi_dec.c:759
AMBI_DEC_DIFFUSE_FIELD_EQ_APPROACH
When using mixed order decoding (i.e.
Definition ambi_dec.h:92
@ AMPLITUDE_PRESERVING
preserve omni amplitude
Definition ambi_dec.h:93
@ ENERGY_PRESERVING
preserve omni energy
Definition ambi_dec.h:94
void ambi_dec_refreshSettings(void *const hAmbi)
Sets all intialisation flags to 1.
Definition ambi_dec.c:636
void ambi_dec_getDecOrderHandle(void *const hAmbi, float **pX_vector, int **pY_values, int *pNpoints)
Returns handles for the decoding orders and frequency vector.
Definition ambi_dec.c:909
int ambi_dec_getDecOrderAllBands(void *const hAmbi)
Returns the decoding order for the first band (see SH_ORDERS enum)
Definition ambi_dec.c:902
void ambi_dec_setOutputConfigPreset(void *const hAmbi, int newPresetID)
Sets the output loudspeaker preset.
Definition ambi_dec.c:748
int ambi_dec_getProcessingDelay(void)
Returns the processing delay in samples; may be used for delay compensation features.
Definition ambi_dec.c:1033
AMBI_DEC_DECODING_METHODS
Available decoding methods.
Definition ambi_dec.h:73
@ DECODING_METHOD_SAD
Sampling Ambisonic Decoder (SAD)
Definition ambi_dec.h:74
@ DECODING_METHOD_MMD
Mode-Matching Decoder (MMD)
Definition ambi_dec.h:75
@ DECODING_METHOD_EPAD
Energy-Preserving Ambisonic Decoder (EPAD)
Definition ambi_dec.h:76
@ DECODING_METHOD_ALLRAD
All-Round Ambisonic Decoder (AllRAD)
Definition ambi_dec.h:77
const float ambi_dec_defaultLoudspeakerDirections[MAX_NUM_OUTPUTS][2]
Default Loudspeaker directions.
void ambi_dec_setDecNormType(void *const hAmbi, int index, int newID)
Sets the equalisation approach for one of the decoders.
Definition ambi_dec.c:852
int ambi_dec_getNumberOfBands(void)
Returns the number of frequency bands employed by ambi_dec.
Definition ambi_dec.c:922
float ambi_dec_getTransitionFreq(void *const hAmbi)
Returns the frequency (in Hz) at which to transition from the low frequency decoder to the high frequ...
Definition ambi_dec.c:1014
void ambi_dec_setDecMethod(void *const hAmbi, int index, int newID)
Sets the decoding method for a specific decoder.
Definition ambi_dec.c:839
char * ambi_dec_getSofaFilePath(void *const hAmbi)
Returns the file path for a .sofa file (WITH file extension)
Definition ambi_dec.c:968
void ambi_dec_setLoudspeakerElev_deg(void *const hAmbi, int index, float newElev_deg)
Sets the elevation of a specific loudspeaker.
Definition ambi_dec.c:684
CODEC_STATUS ambi_dec_getCodecStatus(void *const hAmbi)
Returns current codec status (see CODEC_STATUS enum)
Definition ambi_dec.c:872
void ambi_dec_setUseDefaultHRIRsflag(void *const hAmbi, int newState)
Sets flag to dictate whether the default HRIRs in the Spatial_Audio_Framework should be used (1),...
Definition ambi_dec.c:718
void ambi_dec_setMasterDecOrder(void *const hAmbi, int newValue)
Sets the master decoding order.
Definition ambi_dec.c:643
int ambi_dec_getDecMethod(void *const hAmbi, int index)
Returns the currently selected decoding method (see AMBI_DEC_DECODING_METHODS enum)
Definition ambi_dec.c:996
void ambi_dec_setEnableHRIRsPreProc(void *const hAmbi, int newState)
Enable (1) or disable (0) the pre-processing applied to the HRTFs.
Definition ambi_dec.c:739
int ambi_dec_getChOrder(void *const hAmbi)
Returns the Ambisonic channel ordering convention currently being used to decode with,...
Definition ambi_dec.c:984
void ambi_dec_setTransitionFreq(void *const hAmbi, float newValue)
Sets the frequeny at which to transition from the low frequency decoder to the high frequency decoder...
Definition ambi_dec.c:858
void ambi_dec_setLoudspeakerAzi_deg(void *const hAmbi, int index, float newAzi_deg)
Sets the azimuth of a specific loudspeaker.
Definition ambi_dec.c:670
void ambi_dec_setNumLoudspeakers(void *const hAmbi, int new_nLoudspeakers)
Sets the number of loudspeakers to decode to.
Definition ambi_dec.c:696
void ambi_dec_setNormType(void *const hAmbi, int newType)
Sets the Ambisonic normalisation convention to decode with, in order to match with the convention emp...
Definition ambi_dec.c:832
int ambi_dec_getDecEnableMaxrE(void *const hAmbi, int index)
Returns the value of a flag used to dictate whether the max_rE weighting is being applied by a given ...
Definition ambi_dec.c:1002
int ambi_dec_getBinauraliseLSflag(void *const hAmbi)
Returns the value of a flag used to dictate whether the loudspeaker signals should be binauralised (0...
Definition ambi_dec.c:956
void ambi_dec_destroy(void **const phAmbi)
Destroys an instance of the ambi_dec.
Definition ambi_dec.c:122
int ambi_dec_getDAWsamplerate(void *const hAmbi)
Returns the DAW/Host sample rate.
Definition ambi_dec.c:1027
float ambi_dec_getLoudspeakerAzi_deg(void *const hAmbi, int index)
Returns the loudspeaker azimuth in degrees for a given index.
Definition ambi_dec.c:927