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
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
104
105/* ========================================================================== */
106/* Main Functions */
107/* ========================================================================== */
108
114void ambi_dec_create(void** const phAmbi);
115
121void ambi_dec_destroy(void** const phAmbi);
122
131void ambi_dec_init(void* const hAmbi,
132 int samplerate);
133
149void ambi_dec_initCodec(void* const hAmbi);
150
161void ambi_dec_process(void* const hAmbi,
162 const float *const * inputs,
163 float* const* outputs,
164 int nInputs,
165 int nOutputs,
166 int nSamples);
167
168
169/* ========================================================================== */
170/* Set Functions */
171/* ========================================================================== */
172
177void ambi_dec_refreshSettings(void* const hAmbi);
178
188void ambi_dec_setMasterDecOrder(void* const hAmbi, int newValue);
189
199void ambi_dec_setDecOrder(void* const hAmbi, int newValue, int bandIdx);
200
209void ambi_dec_setDecOrderAllBands(void* const hAmbi, int newValue);
210
218void ambi_dec_setLoudspeakerAzi_deg(void* const hAmbi,
219 int index,
220 float newAzi_deg);
221
229void ambi_dec_setLoudspeakerElev_deg(void* const hAmbi,
230 int index,
231 float newElev_deg);
232
236void ambi_dec_setNumLoudspeakers(void* const hAmbi, int new_nLoudspeakers);
237
246void ambi_dec_setBinauraliseLSflag(void* const hAmbi, int newState);
247
259void ambi_dec_setUseDefaultHRIRsflag(void* const hAmbi, int newState);
260
272void ambi_dec_setSofaFilePath(void* const hAmbi, const char* path);
273
275void ambi_dec_setEnableHRIRsPreProc(void* const hAmbi, int newState);
276
287void ambi_dec_setSourcePreset(void* const hAmbi, int newPresetID);
288
295void ambi_dec_setOutputConfigPreset(void* const hAmbi, int newPresetID);
296
301void ambi_dec_setChOrder(void* const hAmbi, int newOrder);
302
307void ambi_dec_setNormType(void* const hAmbi, int newType);
308
318void ambi_dec_setDecMethod(void* const hAmbi, int index, int newID);
319
328void ambi_dec_setDecEnableMaxrE(void* const hAmbi, int index, int newID);
329
343void ambi_dec_setDecNormType(void* const hAmbi, int index, int newID);
344
352void ambi_dec_setTransitionFreq(void* const hAmbi, float newValue);
353
354
355/* ========================================================================== */
356/* Get Functions */
357/* ========================================================================== */
358
363int ambi_dec_getFrameSize(void);
364
366CODEC_STATUS ambi_dec_getCodecStatus(void* const hAmbi);
367
373float ambi_dec_getProgressBar0_1(void* const hAmbi);
374
381void ambi_dec_getProgressBarText(void* const hAmbi, char* text);
382
384int ambi_dec_getMasterDecOrder(void* const hAmbi);
385
390int ambi_dec_getDecOrder(void* const hAmbi, int bandIdx);
391
393int ambi_dec_getDecOrderAllBands(void* const hAmbi);
394
403void ambi_dec_getDecOrderHandle(void* const hAmbi,
404 float** pX_vector,
405 int** pY_values,
406 int* pNpoints);
407
410
412float ambi_dec_getLoudspeakerAzi_deg(void* const hAmbi, int index);
413
415float ambi_dec_getLoudspeakerElev_deg(void* const hAmbi, int index);
416
418int ambi_dec_getNumLoudspeakers(void* const hAmbi);
419
422
427int ambi_dec_getNSHrequired(void* const hAmbi);
428
434int ambi_dec_getBinauraliseLSflag(void* const hAmbi);
435
444int ambi_dec_getUseDefaultHRIRsflag(void* const hAmbi);
445
453char* ambi_dec_getSofaFilePath(void* const hAmbi);
454
459int ambi_dec_getEnableHRIRsPreProc(void* const hAmbi);
460
466int ambi_dec_getChOrder(void* const hAmbi);
467
473int ambi_dec_getNormType(void* const hAmbi);
474
479int ambi_dec_getDecMethod(void* const hAmbi, int index);
480
489int ambi_dec_getDecEnableMaxrE(void* const hAmbi, int index);
490
502int ambi_dec_getDecNormType(void* const hAmbi, int index);
503
508float ambi_dec_getTransitionFreq(void* const hAmbi);
509
511int ambi_dec_getHRIRsamplerate(void* const hAmbi);
512
514int ambi_dec_getDAWsamplerate(void* const hAmbi);
515
521
522
523#ifdef __cplusplus
524} /* extern "C" */
525#endif /* __cplusplus */
526
527#endif /* __AMBI_DEC_H_INCLUDED__ */
A bunch of things that are common to many of the saf examples.
CODEC_STATUS
Current status of the codec.
Definition _common.h:201
void ambi_dec_setDecOrderAllBands(void *const hAmbi, int newValue)
Sets the decoding order for all frequency bands.
Definition ambi_dec.c:625
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:909
int ambi_dec_getNumLoudspeakers(void *const hAmbi)
Returns the number of loudspeakers in the current layout.
Definition ambi_dec.c:903
int ambi_dec_getMasterDecOrder(void *const hAmbi)
Returns the master/maximum decoding order (see SH_ORDERS enum)
Definition ambi_dec.c:854
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:914
void ambi_dec_setDecOrder(void *const hAmbi, int newValue, int bandIdx)
Sets the decoding order for a given frequency band.
Definition ambi_dec.c:619
float ambi_dec_getProgressBar0_1(void *const hAmbi)
(Optional) Returns current intialisation/processing progress, between 0..1
Definition ambi_dec.c:842
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:942
void ambi_dec_init(void *const hAmbi, int samplerate)
Initialises an instance of ambi_dec with default settings.
Definition ambi_dec.c:171
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:673
float ambi_dec_getLoudspeakerElev_deg(void *const hAmbi, int index)
Returns the loudspeaker elevation in degrees for a given index.
Definition ambi_dec.c:897
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:789
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:972
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:860
void ambi_dec_getProgressBarText(void *const hAmbi, char *text)
(Optional) Returns current intialisation/processing progress text
Definition ambi_dec.c:848
int ambi_dec_getFrameSize(void)
Returns the processing framesize (i.e., number of samples processed with every _process() call )
Definition ambi_dec.c:831
int ambi_dec_getNormType(void *const hAmbi)
Returns the Ambisonic normalisation convention currently being usedto decode with,...
Definition ambi_dec.c:954
int ambi_dec_getHRIRsamplerate(void *const hAmbi)
Returns the HRIR sample rate.
Definition ambi_dec.c:984
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:810
void ambi_dec_initCodec(void *const hAmbi)
Intialises the codec variables, based on current global/user parameters.
Definition ambi_dec.c:184
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:692
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:926
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:470
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:723
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:597
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:873
int ambi_dec_getDecOrderAllBands(void *const hAmbi)
Returns the decoding order for the first band (see SH_ORDERS enum)
Definition ambi_dec.c:866
void ambi_dec_setOutputConfigPreset(void *const hAmbi, int newPresetID)
Sets the output loudspeaker preset.
Definition ambi_dec.c:712
int ambi_dec_getProcessingDelay(void)
Returns the processing delay in samples; may be used for delay compensation features.
Definition ambi_dec.c:997
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
void ambi_dec_setDecNormType(void *const hAmbi, int index, int newID)
Sets the equalisation approach for one of the decoders.
Definition ambi_dec.c:816
int ambi_dec_getNumberOfBands(void)
Returns the number of frequency bands employed by ambi_dec.
Definition ambi_dec.c:886
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:978
void ambi_dec_setDecMethod(void *const hAmbi, int index, int newID)
Sets the decoding method for a specific decoder.
Definition ambi_dec.c:803
char * ambi_dec_getSofaFilePath(void *const hAmbi)
Returns the file path for a .sofa file (WITH file extension)
Definition ambi_dec.c:932
void ambi_dec_setLoudspeakerElev_deg(void *const hAmbi, int index, float newElev_deg)
Sets the elevation of a specific loudspeaker.
Definition ambi_dec.c:648
CODEC_STATUS ambi_dec_getCodecStatus(void *const hAmbi)
Returns current codec status (see CODEC_STATUS enum)
Definition ambi_dec.c:836
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:682
void ambi_dec_setMasterDecOrder(void *const hAmbi, int newValue)
Sets the master decoding order.
Definition ambi_dec.c:607
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:960
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:703
int ambi_dec_getChOrder(void *const hAmbi)
Returns the Ambisonic channel ordering convention currently being used to decode with,...
Definition ambi_dec.c:948
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:822
void ambi_dec_setLoudspeakerAzi_deg(void *const hAmbi, int index, float newAzi_deg)
Sets the azimuth of a specific loudspeaker.
Definition ambi_dec.c:634
void ambi_dec_setNumLoudspeakers(void *const hAmbi, int new_nLoudspeakers)
Sets the number of loudspeakers to decode to.
Definition ambi_dec.c:660
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:796
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:966
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:920
void ambi_dec_destroy(void **const phAmbi)
Destroys an instance of the ambi_dec.
Definition ambi_dec.c:120
int ambi_dec_getDAWsamplerate(void *const hAmbi)
Returns the DAW/Host sample rate.
Definition ambi_dec.c:991
float ambi_dec_getLoudspeakerAzi_deg(void *const hAmbi, int index)
Returns the loudspeaker azimuth in degrees for a given index.
Definition ambi_dec.c:891