SAF
Loading...
Searching...
No Matches
ambi_dec.h

A frequency-dependent Ambisonic decoder for reproducing Ambisonic sound scenes over loudspeakers.

A frequency-dependent Ambisonic decoder for reproducing Ambisonic sound scenes over loudspeakers

Files

ambi_dec.h (include), ambi_dec_internal.h, ambi_dec.c, ambi_dec_internal.c

Include Header

/*
* Copyright 2017-2018 Leo McCormack
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef __AMBI_DEC_H_INCLUDED__
#define __AMBI_DEC_H_INCLUDED__
#include "_common.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* ========================================================================== */
/* Presets + Constants */
/* ========================================================================== */
typedef enum {
#define AMBI_DEC_NUM_DECODING_METHODS ( 4 )
typedef enum {
#define AMBI_DEC_TRANSITION_MIN_VALUE ( 500.0f )
#define AMBI_DEC_TRANSITION_MAX_VALUE ( 2000.0f )
/* ========================================================================== */
/* Main Functions */
/* ========================================================================== */
void ambi_dec_create(void** const phAmbi);
void ambi_dec_destroy(void** const phAmbi);
void ambi_dec_init(void* const hAmbi,
int samplerate);
void ambi_dec_initCodec(void* const hAmbi);
void ambi_dec_process(void* const hAmbi,
const float *const * inputs,
float* const* outputs,
int nInputs,
int nOutputs,
int nSamples);
/* ========================================================================== */
/* Set Functions */
/* ========================================================================== */
void ambi_dec_refreshSettings(void* const hAmbi);
void ambi_dec_setMasterDecOrder(void* const hAmbi, int newValue);
void ambi_dec_setDecOrder(void* const hAmbi, int newValue, int bandIdx);
void ambi_dec_setDecOrderAllBands(void* const hAmbi, int newValue);
void ambi_dec_setLoudspeakerAzi_deg(void* const hAmbi,
int index,
float newAzi_deg);
void ambi_dec_setLoudspeakerElev_deg(void* const hAmbi,
int index,
float newElev_deg);
void ambi_dec_setNumLoudspeakers(void* const hAmbi, int new_nLoudspeakers);
void ambi_dec_setBinauraliseLSflag(void* const hAmbi, int newState);
void ambi_dec_setUseDefaultHRIRsflag(void* const hAmbi, int newState);
void ambi_dec_setSofaFilePath(void* const hAmbi, const char* path);
void ambi_dec_setEnableHRIRsPreProc(void* const hAmbi, int newState);
void ambi_dec_setSourcePreset(void* const hAmbi, int newPresetID);
void ambi_dec_setOutputConfigPreset(void* const hAmbi, int newPresetID);
void ambi_dec_setChOrder(void* const hAmbi, int newOrder);
void ambi_dec_setNormType(void* const hAmbi, int newType);
void ambi_dec_setDecMethod(void* const hAmbi, int index, int newID);
void ambi_dec_setDecEnableMaxrE(void* const hAmbi, int index, int newID);
void ambi_dec_setDecNormType(void* const hAmbi, int index, int newID);
void ambi_dec_setTransitionFreq(void* const hAmbi, float newValue);
/* ========================================================================== */
/* Get Functions */
/* ========================================================================== */
float ambi_dec_getProgressBar0_1(void* const hAmbi);
void ambi_dec_getProgressBarText(void* const hAmbi, char* text);
int ambi_dec_getMasterDecOrder(void* const hAmbi);
int ambi_dec_getDecOrder(void* const hAmbi, int bandIdx);
int ambi_dec_getDecOrderAllBands(void* const hAmbi);
void ambi_dec_getDecOrderHandle(void* const hAmbi,
float** pX_vector,
int** pY_values,
int* pNpoints);
float ambi_dec_getLoudspeakerAzi_deg(void* const hAmbi, int index);
float ambi_dec_getLoudspeakerElev_deg(void* const hAmbi, int index);
int ambi_dec_getNumLoudspeakers(void* const hAmbi);
int ambi_dec_getNSHrequired(void* const hAmbi);
int ambi_dec_getBinauraliseLSflag(void* const hAmbi);
int ambi_dec_getUseDefaultHRIRsflag(void* const hAmbi);
char* ambi_dec_getSofaFilePath(void* const hAmbi);
int ambi_dec_getEnableHRIRsPreProc(void* const hAmbi);
int ambi_dec_getChOrder(void* const hAmbi);
int ambi_dec_getNormType(void* const hAmbi);
int ambi_dec_getDecMethod(void* const hAmbi, int index);
int ambi_dec_getDecEnableMaxrE(void* const hAmbi, int index);
int ambi_dec_getDecNormType(void* const hAmbi, int index);
float ambi_dec_getTransitionFreq(void* const hAmbi);
int ambi_dec_getHRIRsamplerate(void* const hAmbi);
int ambi_dec_getDAWsamplerate(void* const hAmbi);
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
#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