SAF
|
A frequency-dependent Ambisonic decoder for reproducing Ambisonic sound scenes over loudspeakers. More...
#include "ambi_dec_internal.h"
Go to the source code of this file.
Functions | |
void | ambi_dec_create (void **const phAmbi) |
Creates an instance of the ambi_dec. | |
void | ambi_dec_destroy (void **const phAmbi) |
Destroys an instance of the ambi_dec. | |
void | ambi_dec_init (void *const hAmbi, int sampleRate) |
Initialises an instance of ambi_dec with default settings. | |
void | ambi_dec_initCodec (void *const hAmbi) |
Intialises the codec variables, based on current global/user parameters. | |
void | ambi_dec_process (void *const hAmbi, const float *const *inputs, float *const *const outputs, int nInputs, int nOutputs, int nSamples) |
Decodes input spherical harmonic signals to the loudspeaker channels. | |
void | ambi_dec_refreshSettings (void *const hAmbi) |
Sets all intialisation flags to 1. | |
void | ambi_dec_setMasterDecOrder (void *const hAmbi, int newValue) |
Sets the master decoding order. | |
void | ambi_dec_setDecOrder (void *const hAmbi, int newValue, int bandIdx) |
Sets the decoding order for a given frequency band. | |
void | ambi_dec_setDecOrderAllBands (void *const hAmbi, int newValue) |
Sets the decoding order for all frequency bands. | |
void | ambi_dec_setLoudspeakerAzi_deg (void *const hAmbi, int index, float newAzi_deg) |
Sets the azimuth of a specific loudspeaker. | |
void | ambi_dec_setLoudspeakerElev_deg (void *const hAmbi, int index, float newElev_deg) |
Sets the elevation of a specific loudspeaker. | |
void | ambi_dec_setNumLoudspeakers (void *const hAmbi, int new_nLoudspeakers) |
Sets the number of loudspeakers to decode to. | |
void | ambi_dec_setBinauraliseLSflag (void *const hAmbi, int newState) |
Sets flag to dictate whether the output loudspeaker signals should be binauralised. | |
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), or a custom HRIR set loaded via a SOFA file (0). | |
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. | |
void | ambi_dec_setEnableHRIRsPreProc (void *const hAmbi, int newState) |
Enable (1) or disable (0) the pre-processing applied to the HRTFs. | |
void | ambi_dec_setOutputConfigPreset (void *const hAmbi, int newPresetID) |
Sets the output loudspeaker preset. | |
void | ambi_dec_setSourcePreset (void *const hAmbi, int newPresetID) |
Sets the source preset (ideal SH or SH signals derived from mic arrays) | |
void | ambi_dec_setChOrder (void *const hAmbi, int newOrder) |
Sets the Ambisonic channel ordering convention to decode with, in order to match the convention employed by the input signals (see CH_ORDER enum) | |
void | ambi_dec_setNormType (void *const hAmbi, int newType) |
Sets the Ambisonic normalisation convention to decode with, in order to match with the convention employed by the input signals (see NORM_TYPES enum) | |
void | ambi_dec_setDecMethod (void *const hAmbi, int index, int newID) |
Sets the decoding method for a specific decoder. | |
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. | |
void | ambi_dec_setDecNormType (void *const hAmbi, int index, int newID) |
Sets the equalisation approach for one of the decoders. | |
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. | |
int | ambi_dec_getFrameSize (void) |
Returns the processing framesize (i.e., number of samples processed with every _process() call ) | |
CODEC_STATUS | ambi_dec_getCodecStatus (void *const hAmbi) |
Returns current codec status (see CODEC_STATUS enum) | |
float | ambi_dec_getProgressBar0_1 (void *const hAmbi) |
(Optional) Returns current intialisation/processing progress, between 0..1 | |
void | ambi_dec_getProgressBarText (void *const hAmbi, char *text) |
(Optional) Returns current intialisation/processing progress text | |
int | ambi_dec_getMasterDecOrder (void *const hAmbi) |
Returns the master/maximum decoding order (see SH_ORDERS enum) | |
int | ambi_dec_getDecOrder (void *const hAmbi, int bandIdx) |
Returns the decoding order for a given frequency band index (see SH_ORDERS enum) | |
int | ambi_dec_getDecOrderAllBands (void *const hAmbi) |
Returns the decoding order for the first band (see SH_ORDERS enum) | |
void | ambi_dec_getDecOrderHandle (void *const hAmbi, float **pX_vector, int **pY_values, int *pNpoints) |
Returns handles for the decoding orders and frequency vector. | |
int | ambi_dec_getNumberOfBands (void) |
Returns the number of frequency bands employed by ambi_dec. | |
float | ambi_dec_getLoudspeakerAzi_deg (void *const hAmbi, int index) |
Returns the loudspeaker azimuth in degrees for a given index. | |
float | ambi_dec_getLoudspeakerElev_deg (void *const hAmbi, int index) |
Returns the loudspeaker elevation in degrees for a given index. | |
int | ambi_dec_getNumLoudspeakers (void *const hAmbi) |
Returns the number of loudspeakers in the current layout. | |
int | ambi_dec_getMaxNumLoudspeakers () |
Returns the maximum number of loudspeakers supported by ambi_dec. | |
int | ambi_dec_getNSHrequired (void *const hAmbi) |
Returns the number of spherical harmonic signals required by the current decoding order: (current_order + 1)^2. | |
int | ambi_dec_getBinauraliseLSflag (void *const hAmbi) |
Returns the value of a flag used to dictate whether the loudspeaker signals should be binauralised (0: output loudspeaker signals, 1: output binaural signals). | |
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 should be used (1), or a custom HRIR set loaded via a SOFA file (0). | |
char * | ambi_dec_getSofaFilePath (void *const hAmbi) |
Returns the file path for a .sofa file (WITH file extension) | |
int | ambi_dec_getEnableHRIRsPreProc (void *const hAmbi) |
Returns the flag indicating whether the pre-processing applied to the HRTFs is enabled (1) or disabled (0) | |
int | ambi_dec_getChOrder (void *const hAmbi) |
Returns the Ambisonic channel ordering convention currently being used to decode with, which should match the convention employed by the input signals (see CH_ORDER enum) | |
int | ambi_dec_getNormType (void *const hAmbi) |
Returns the Ambisonic normalisation convention currently being usedto decode with, which should match the convention employed by the input signals (see NORM_TYPES enum). | |
int | ambi_dec_getDecMethod (void *const hAmbi, int index) |
Returns the currently selected decoding method (see AMBI_DEC_DECODING_METHODS enum) | |
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 decoder. | |
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_APPROACH enum) | |
float | ambi_dec_getTransitionFreq (void *const hAmbi) |
Returns the frequency (in Hz) at which to transition from the low frequency decoder to the high frequency decoder. | |
int | ambi_dec_getHRIRsamplerate (void *const hAmbi) |
Returns the HRIR sample rate. | |
int | ambi_dec_getDAWsamplerate (void *const hAmbi) |
Returns the DAW/Host sample rate. | |
int | ambi_dec_getProcessingDelay () |
Returns the processing delay in samples; may be used for delay compensation features. | |
A frequency-dependent Ambisonic decoder for reproducing Ambisonic sound scenes over loudspeakers.
Different decoder settings can be specified for the low and high frequencies. A number of decoding options are also offered, including [1,2]. When utilising spherical harmonic signals derived from real microphone arrays, this implementation also allows the decoding order to be specified per frequency band; of course, this may also be used creatively. An optional, loudspeaker channel binauraliser is included, along with with SOFA file loading, for headphone listening.
The algorithms utilised in this Ambisonic decoder were pieced together and developed in collaboration with Archontis Politis.
Definition in file ambi_dec.c.
void ambi_dec_create | ( | void **const | phAmbi | ) |
Creates an instance of the ambi_dec.
[in] | phAmbi | (&) address of ambi_dec handle |
Definition at line 48 of file ambi_dec.c.
void ambi_dec_destroy | ( | void **const | phAmbi | ) |
Destroys an instance of the ambi_dec.
[in] | phAmbi | (&) address of ambi_dec handle |
Definition at line 119 of file ambi_dec.c.
int ambi_dec_getBinauraliseLSflag | ( | void *const | hAmbi | ) |
Returns the value of a flag used to dictate whether the loudspeaker signals should be binauralised (0: output loudspeaker signals, 1: output binaural signals).
Definition at line 920 of file ambi_dec.c.
int ambi_dec_getChOrder | ( | void *const | hAmbi | ) |
Returns the Ambisonic channel ordering convention currently being used to decode with, which should match the convention employed by the input signals (see CH_ORDER enum)
Definition at line 948 of file ambi_dec.c.
CODEC_STATUS ambi_dec_getCodecStatus | ( | void *const | hAmbi | ) |
Returns current codec status (see CODEC_STATUS enum)
Definition at line 836 of file ambi_dec.c.
int ambi_dec_getDAWsamplerate | ( | void *const | hAmbi | ) |
Returns the DAW/Host sample rate.
Definition at line 991 of file ambi_dec.c.
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 decoder.
[in] | hAmbi | ambi_dec handle |
[in] | index | Index for low (0) or high (1) frequency decoder |
Definition at line 966 of file ambi_dec.c.
int ambi_dec_getDecMethod | ( | void *const | hAmbi, |
int | index ) |
Returns the currently selected decoding method (see AMBI_DEC_DECODING_METHODS enum)
Definition at line 960 of file ambi_dec.c.
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_APPROACH enum)
[in] | hAmbi | ambi_dec handle |
[in] | index | Index for low (0) or high (1) frequency decoder |
Definition at line 972 of file ambi_dec.c.
int ambi_dec_getDecOrder | ( | void *const | hAmbi, |
int | bandIdx ) |
Returns the decoding order for a given frequency band index (see SH_ORDERS enum)
Definition at line 860 of file ambi_dec.c.
int ambi_dec_getDecOrderAllBands | ( | void *const | hAmbi | ) |
Returns the decoding order for the first band (see SH_ORDERS enum)
Definition at line 866 of file ambi_dec.c.
void ambi_dec_getDecOrderHandle | ( | void *const | hAmbi, |
float ** | pX_vector, | ||
int ** | pY_values, | ||
int * | pNpoints ) |
Returns handles for the decoding orders and frequency vector.
[in] | hAmbi | ambi_dec handle |
[out] | pX_vector | (&) frequency vector; pNpoints x 1 |
[out] | pY_values | (&) decoding order per frequency; pNpoints x 1 |
[out] | pNpoints | (&) number of grid points. |
Definition at line 872 of file ambi_dec.c.
int ambi_dec_getEnableHRIRsPreProc | ( | void *const | hAmbi | ) |
Returns the flag indicating whether the pre-processing applied to the HRTFs is enabled (1) or disabled (0)
Definition at line 942 of file ambi_dec.c.
int ambi_dec_getFrameSize | ( | void | ) |
Returns the processing framesize (i.e., number of samples processed with every _process() call )
Definition at line 831 of file ambi_dec.c.
int ambi_dec_getHRIRsamplerate | ( | void *const | hAmbi | ) |
Returns the HRIR sample rate.
Definition at line 984 of file ambi_dec.c.
float ambi_dec_getLoudspeakerAzi_deg | ( | void *const | hAmbi, |
int | index ) |
Returns the loudspeaker azimuth in degrees for a given index.
Definition at line 891 of file ambi_dec.c.
float ambi_dec_getLoudspeakerElev_deg | ( | void *const | hAmbi, |
int | index ) |
Returns the loudspeaker elevation in degrees for a given index.
Definition at line 897 of file ambi_dec.c.
int ambi_dec_getMasterDecOrder | ( | void *const | hAmbi | ) |
Returns the master/maximum decoding order (see SH_ORDERS enum)
Definition at line 854 of file ambi_dec.c.
int ambi_dec_getMaxNumLoudspeakers | ( | void | ) |
Returns the maximum number of loudspeakers supported by ambi_dec.
Definition at line 909 of file ambi_dec.c.
int ambi_dec_getNormType | ( | void *const | hAmbi | ) |
Returns the Ambisonic normalisation convention currently being usedto decode with, which should match the convention employed by the input signals (see NORM_TYPES enum).
Definition at line 954 of file ambi_dec.c.
int ambi_dec_getNSHrequired | ( | void *const | hAmbi | ) |
Returns the number of spherical harmonic signals required by the current decoding order: (current_order + 1)^2.
Definition at line 914 of file ambi_dec.c.
int ambi_dec_getNumberOfBands | ( | void | ) |
Returns the number of frequency bands employed by ambi_dec.
Definition at line 886 of file ambi_dec.c.
int ambi_dec_getNumLoudspeakers | ( | void *const | hAmbi | ) |
Returns the number of loudspeakers in the current layout.
Definition at line 903 of file ambi_dec.c.
int ambi_dec_getProcessingDelay | ( | void | ) |
Returns the processing delay in samples; may be used for delay compensation features.
Definition at line 997 of file ambi_dec.c.
float ambi_dec_getProgressBar0_1 | ( | void *const | hAmbi | ) |
(Optional) Returns current intialisation/processing progress, between 0..1
Definition at line 842 of file ambi_dec.c.
void ambi_dec_getProgressBarText | ( | void *const | hAmbi, |
char * | text ) |
(Optional) Returns current intialisation/processing progress text
Definition at line 848 of file ambi_dec.c.
char * ambi_dec_getSofaFilePath | ( | void *const | hAmbi | ) |
Returns the file path for a .sofa file (WITH file extension)
Definition at line 932 of file ambi_dec.c.
float ambi_dec_getTransitionFreq | ( | void *const | hAmbi | ) |
Returns the frequency (in Hz) at which to transition from the low frequency decoder to the high frequency decoder.
Definition at line 978 of file ambi_dec.c.
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 should be used (1), or a custom HRIR set loaded via a SOFA file (0).
Definition at line 926 of file ambi_dec.c.
void ambi_dec_init | ( | void *const | hAmbi, |
int | samplerate ) |
Initialises an instance of ambi_dec with default settings.
[in] | hAmbi | ambi_dec handle |
[in] | samplerate | Host samplerate. |
Definition at line 170 of file ambi_dec.c.
void ambi_dec_initCodec | ( | void *const | hAmbi | ) |
Intialises the codec variables, based on current global/user parameters.
[in] | hAmbi | ambi_dec handle |
Definition at line 183 of file ambi_dec.c.
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.
[in] | hAmbi | ambi_dec handle |
[in] | inputs | Input channel buffers; 2-D array: nInputs x nSamples |
[in] | outputs | Output channel buffers; 2-D array: nOutputs x nSamples |
[in] | nInputs | Number of input channels |
[in] | nOutputs | Number of output channels |
[in] | nSamples | Number of samples in 'inputs'/'output' matrices |
Definition at line 469 of file ambi_dec.c.
void ambi_dec_refreshSettings | ( | void *const | hAmbi | ) |
Sets all intialisation flags to 1.
Re-initialising all settings/variables, as ambi_dec is currently configured, at next available opportunity.
Definition at line 597 of file ambi_dec.c.
void ambi_dec_setBinauraliseLSflag | ( | void *const | hAmbi, |
int | newState ) |
Sets flag to dictate whether the output loudspeaker signals should be binauralised.
[in] | hAmbi | ambi_dec handle |
[in] | newState | '0' output loudspeaker signals, '1' output binaural signals |
Definition at line 673 of file ambi_dec.c.
void ambi_dec_setChOrder | ( | void *const | hAmbi, |
int | newOrder ) |
Sets the Ambisonic channel ordering convention to decode with, in order to match the convention employed by the input signals (see CH_ORDER enum)
Definition at line 789 of file ambi_dec.c.
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.
[in] | hAmbi | ambi_dec handle |
[in] | index | For low (0) or high (1) frequency decoder |
[in] | newID | '0' disabled, '1' enabled |
Definition at line 810 of file ambi_dec.c.
void ambi_dec_setDecMethod | ( | void *const | hAmbi, |
int | index, | ||
int | newID ) |
Sets the decoding method for a specific decoder.
ambi_dec employs two decoders, one for low frequencies and one for high frequencies. (use ambi_dec_setTransitionFreq() to dictate the transition frequency)
[in] | hAmbi | ambi_dec handle |
[in] | index | Index for low (0) or high (1) frequency decoder |
[in] | newID | New decoding method (see AMBI_DEC_DECODING_METHODS enum) |
Definition at line 803 of file ambi_dec.c.
void ambi_dec_setDecNormType | ( | void *const | hAmbi, |
int | index, | ||
int | newID ) |
Sets the equalisation approach for one of the decoders.
This is used to help keep the perceived loudness consistent, when using mixed decoding orders (i.e. different decoding orders for different frequency bands) ambi_dec either to preserves amplitude or energy for each order.
[in] | hAmbi | ambi_dec handle |
[in] | index | For low (0) or high (1) frequency decoder |
[in] | newID | see AMBI_DEC_DIFFUSE_FIELD_EQ_APPROACH enum |
Definition at line 816 of file ambi_dec.c.
void ambi_dec_setDecOrder | ( | void *const | hAmbi, |
int | newValue, | ||
int | bandIdx ) |
Sets the decoding order for a given frequency band.
[in] | hAmbi | ambi_dec handle |
[in] | newValue | New decoding order |
[in] | bandIdx | Frequency band index |
Definition at line 619 of file ambi_dec.c.
void ambi_dec_setDecOrderAllBands | ( | void *const | hAmbi, |
int | newValue ) |
Sets the decoding order for all frequency bands.
[in] | hAmbi | ambi_dec handle |
[in] | newValue | New decoding order |
Definition at line 625 of file ambi_dec.c.
void ambi_dec_setEnableHRIRsPreProc | ( | void *const | hAmbi, |
int | newState ) |
Enable (1) or disable (0) the pre-processing applied to the HRTFs.
Definition at line 703 of file ambi_dec.c.
void ambi_dec_setLoudspeakerAzi_deg | ( | void *const | hAmbi, |
int | index, | ||
float | newAzi_deg ) |
Sets the azimuth of a specific loudspeaker.
[in] | hAmbi | ambi_dec handle |
[in] | index | Loudspeaker index |
[in] | newAzi_deg | New azimuth in DEGREES |
Definition at line 634 of file ambi_dec.c.
void ambi_dec_setLoudspeakerElev_deg | ( | void *const | hAmbi, |
int | index, | ||
float | newElev_deg ) |
Sets the elevation of a specific loudspeaker.
[in] | hAmbi | ambi_dec handle |
[in] | index | Loudspeaker index |
[in] | newElev_deg | New elevation in DEGREES |
Definition at line 648 of file ambi_dec.c.
void ambi_dec_setMasterDecOrder | ( | void *const | hAmbi, |
int | newValue ) |
Sets the master decoding order.
However, the decoding order may be lower than this for any given frequency, this is just the maximum.
If decoding order is higher than the input signal order, the extra required channels are filled with zeros. If the decoding order is lower than the input signal order, the number input signals is truncated accordingly. (see SH_ORDERS enum)
Definition at line 607 of file ambi_dec.c.
void ambi_dec_setNormType | ( | void *const | hAmbi, |
int | newType ) |
Sets the Ambisonic normalisation convention to decode with, in order to match with the convention employed by the input signals (see NORM_TYPES enum)
Definition at line 796 of file ambi_dec.c.
void ambi_dec_setNumLoudspeakers | ( | void *const | hAmbi, |
int | new_nLoudspeakers ) |
Sets the number of loudspeakers to decode to.
Definition at line 660 of file ambi_dec.c.
void ambi_dec_setOutputConfigPreset | ( | void *const | hAmbi, |
int | newPresetID ) |
Sets the output loudspeaker preset.
For conveinience, presets for several popular arrangements are included (see LOUDSPEAKER_ARRAY_PRESETS enum).
Definition at line 712 of file ambi_dec.c.
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.
[in] | hAmbi | ambi_dec handle |
[in] | path | File path to .sofa file (WITH file extension) |
Definition at line 692 of file ambi_dec.c.
void ambi_dec_setSourcePreset | ( | void *const | hAmbi, |
int | newPresetID ) |
Sets the source preset (ideal SH or SH signals derived from mic arrays)
By default the decoder will decode at the maximum order for all frequencies. However, in the case of spherical harmonic input derived from microphone arrays, the available order is frequency dependent, therefore, different bands require different decoding orders. For conveinience, presets for a handful of comerically available microphone array are included (see MIC_PRESETS enum).
Definition at line 723 of file ambi_dec.c.
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.
[in] | hAmbi | ambi_dec handle |
[in] | newValue | New transition frequency, in Hz |
Definition at line 822 of file ambi_dec.c.
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), or a custom HRIR set loaded via a SOFA file (0).
[in] | hAmbi | ambi_dec handle |
[in] | newState | '0' use custom HRIR set, '1' use default HRIR set |
Definition at line 682 of file ambi_dec.c.