SAF
Loading...
Searching...
No Matches
ambi_bin.h
Go to the documentation of this file.
1/*
2 * Copyright 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
109#ifndef __AMBI_BIN_H_INCLUDED__
110#define __AMBI_BIN_H_INCLUDED__
111
112#include "_common.h"
113
114#ifdef __cplusplus
115extern "C" {
116#endif /* __cplusplus */
117
118/* ========================================================================== */
119/* Presets + Constants */
120/* ========================================================================== */
121
136
138#define AMBI_BIN_NUM_DECODING_METHODS ( 5 )
139
147
149#define AMBI_BIN_NUM_HRIR_PREPROC_OPTIONS ( 4 )
150
151
152/* ========================================================================== */
153/* Main Functions */
154/* ========================================================================== */
155
161void ambi_bin_create(void** const phAmbi);
162
168void ambi_bin_destroy(void** const phAmbi);
169
178void ambi_bin_init(void* const hAmbi,
179 int samplerate);
180
196void ambi_bin_initCodec(void* const hAmbi);
197
208void ambi_bin_process(void* const hAmbi,
209 const float *const * inputs,
210 float* const* const outputs,
211 int nInputs,
212 int nOutputs,
213 int nSamples);
214
215
216/* ========================================================================== */
217/* Set Functions */
218/* ========================================================================== */
219
224void ambi_bin_refreshParams(void* const hAmbi);
225
237void ambi_bin_setUseDefaultHRIRsflag(void* const hAmbi, int newState);
238
250void ambi_bin_setSofaFilePath(void* const hAmbi, const char* path);
251
260void ambi_bin_setInputOrderPreset(void* const hAmbi,
261 SH_ORDERS newPreset);
262
266void ambi_bin_setDecodingMethod(void* const hAmbi,
267 AMBI_BIN_DECODING_METHODS newMethod);
268
273void ambi_bin_setChOrder(void* const hAmbi, int newOrder);
274
279void ambi_bin_setNormType(void* const hAmbi, int newType);
280
282void ambi_bin_setEnableMaxRE(void* const hAmbi, int newState);
283
285void ambi_bin_setEnableDiffuseMatching(void* const hAmbi, int newState);
286
288void ambi_bin_setEnableTruncationEQ(void* const hAmbi, int newState);
289
291void ambi_bin_setHRIRsPreProc(void* const hAmbi, AMBI_BIN_PREPROC newType);
292
294void ambi_bin_setEnableRotation(void* const hAmbi, int newState);
295
297void ambi_bin_setYaw(void* const hAmbi, float newYaw_deg);
298
300void ambi_bin_setPitch(void* const hAmbi, float newPitch);
301
303void ambi_bin_setRoll(void* const hAmbi, float newRoll);
304
306void ambi_bin_setFlipYaw(void* const hAmbi, int newState);
307
309void ambi_bin_setFlipPitch(void* const hAmbi, int newState);
310
312void ambi_bin_setFlipRoll(void* const hAmbi, int newState);
313
318void ambi_bin_setRPYflag(void* const hAmbi, int newState);
319
320
321/* ========================================================================== */
322/* Get Functions */
323/* ========================================================================== */
324
329int ambi_bin_getFrameSize(void);
330
332CODEC_STATUS ambi_bin_getCodecStatus(void* const hAmbi);
333
335float ambi_bin_getProgressBar0_1(void* const hAmbi);
336
343void ambi_bin_getProgressBarText(void* const hAmbi, char* text);
344
353int ambi_bin_getUseDefaultHRIRsflag(void* const hAmbi);
354
362int ambi_bin_getInputOrderPreset(void* const hAmbi);
363
369
378char* ambi_bin_getSofaFilePath(void* const hAmbi);
379
385int ambi_bin_getChOrder(void* const hAmbi);
386
392int ambi_bin_getNormType(void* const hAmbi);
393
395int ambi_bin_getNumEars(void);
396
401int ambi_bin_getNSHrequired(void* const hAmbi);
402
407int ambi_bin_getEnableMaxRE(void* const hAmbi);
408
413int ambi_bin_getEnableDiffuseMatching(void* const hAmbi);
414
419int ambi_bin_getEnableTruncationEQ(void* const hAmbi);
420
426
431int ambi_bin_getEnableRotation(void* const hAmbi);
432
434float ambi_bin_getYaw(void* const hAmbi);
435
437float ambi_bin_getPitch(void* const hAmbi);
438
440float ambi_bin_getRoll(void* const hAmbi);
441
446int ambi_bin_getFlipYaw(void* const hAmbi);
447
452int ambi_bin_getFlipPitch(void* const hAmbi);
453
458int ambi_bin_getFlipRoll(void* const hAmbi);
459
464int ambi_bin_getRPYflag(void* const hAmbi);
465
467int ambi_bin_getNDirs(void* const hAmbi);
468
470int ambi_bin_getHRIRlength(void* const hAmbi);
471
473int ambi_bin_getHRIRsamplerate(void* const hAmbi);
474
476int ambi_bin_getDAWsamplerate(void* const hAmbi);
477
483
484
485#ifdef __cplusplus
486} /* extern "C" { */
487#endif /* __cplusplus */
488
489#endif /* __AMBI_BIN_H_INCLUDED__ */
A bunch of things that are common to many of the saf examples.
SH_ORDERS
Available spherical harmonic (SH) input/output order options.
Definition _common.h:38
CODEC_STATUS
Current status of the codec.
Definition _common.h:201
void ambi_bin_setChOrder(void *const hAmbi, int newOrder)
Sets the Ambisonic channel ordering convention to decode with, in order to match the convention emplo...
Definition ambi_bin.c:555
int ambi_bin_getNSHrequired(void *const hAmbi)
Returns the number of spherical harmonic signals required by the current decoding order: (current_ord...
Definition ambi_bin.c:760
void ambi_bin_setInputOrderPreset(void *const hAmbi, SH_ORDERS newPreset)
Sets the decoding order (see SH_ORDERS enum)
Definition ambi_bin.c:534
int ambi_bin_getEnableMaxRE(void *const hAmbi)
Returns the flag value which dictates whether to enable/disable maxrE weighting ('0' disabled,...
Definition ambi_bin.c:737
int ambi_bin_getHRIRsamplerate(void *const hAmbi)
Returns the HRIR sample rate.
Definition ambi_bin.c:828
int ambi_bin_getNormType(void *const hAmbi)
Returns the Ambisonic normalisation convention currently being usedto decode with,...
Definition ambi_bin.c:731
void ambi_bin_setFlipRoll(void *const hAmbi, int newState)
Sets a flag as to whether to "flip" the sign of the current 'roll' angle.
Definition ambi_bin.c:650
void ambi_bin_setPitch(void *const hAmbi, float newPitch)
Sets the 'pitch' rotation angle, in degrees.
Definition ambi_bin.c:618
int ambi_bin_getProcessingDelay(void)
Returns the processing delay in samples (may be used for delay compensation features)
Definition ambi_bin.c:841
int ambi_bin_getEnableTruncationEQ(void *const hAmbi)
Returns the flag value which dictates whether the truncation EQ is currently enabled ('0' disabled,...
Definition ambi_bin.c:749
int ambi_bin_getEnableDiffuseMatching(void *const hAmbi)
Returns the flag value which dictates whether the diffuse covariance contraint is currently enabled (...
Definition ambi_bin.c:743
AMBI_BIN_PREPROC ambi_bin_getHRIRsPreProc(void *const hAmbi)
Returns HRIR pre-processing strategy.
Definition ambi_bin.c:697
AMBI_BIN_DECODING_METHODS ambi_bin_getDecodingMethod(void *const hAmbi)
Returns the currently selected decoding method (see AMBI_BIN_DECODING_METHODS enum)
Definition ambi_bin.c:709
int ambi_bin_getDAWsamplerate(void *const hAmbi)
Returns the DAW/Host sample rate.
Definition ambi_bin.c:835
void ambi_bin_create(void **const phAmbi)
Creates an instance of ambi_bin.
Definition ambi_bin.c:51
void ambi_bin_setHRIRsPreProc(void *const hAmbi, AMBI_BIN_PREPROC newType)
Sets HRIR pre-processing strategy (see AMBI_BIN_PREPROC enum)
Definition ambi_bin.c:596
void ambi_bin_setFlipYaw(void *const hAmbi, int newState)
Sets a flag as to whether to "flip" the sign of the current 'yaw' angle.
Definition ambi_bin.c:632
AMBI_BIN_DECODING_METHODS
Available decoding methods for the ambi_bin example.
Definition ambi_bin.h:126
@ DECODING_METHOD_LSDIFFEQ
Least-squares (LS) decoder with diffuse-field spectral equalisation.
Definition ambi_bin.h:128
@ DECODING_METHOD_LS
Least-squares (LS) decoder.
Definition ambi_bin.h:127
@ DECODING_METHOD_SPR
Spatial resampling decoder (on the same lines as the virtual loudspeaker approach)
Definition ambi_bin.h:130
@ DECODING_METHOD_TA
Time-alignment (TA)
Definition ambi_bin.h:132
@ DECODING_METHOD_MAGLS
Magnitude least-squares decoder (MagLS)
Definition ambi_bin.h:133
void ambi_bin_setEnableMaxRE(void *const hAmbi, int newState)
Sets a flag to enable/disable the max_rE weighting.
Definition ambi_bin.c:569
void ambi_bin_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_bin.c:522
int ambi_bin_getEnableRotation(void *const hAmbi)
Returns the flag value which dictates whether to enable/disable sound-field rotation ('0' disabled,...
Definition ambi_bin.c:766
int ambi_bin_getChOrder(void *const hAmbi)
Returns the Ambisonic channel ordering convention currently being used to decode with,...
Definition ambi_bin.c:725
int ambi_bin_getNumEars(void)
Returns the number of ears possessed by the average homo sapien (2)
Definition ambi_bin.c:755
void ambi_bin_initCodec(void *const hAmbi)
Intialises the codec variables, based on current global/user parameters.
Definition ambi_bin.c:169
void ambi_bin_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 binaural channels.
Definition ambi_bin.c:403
float ambi_bin_getPitch(void *const hAmbi)
Returns the 'pitch' rotation angle, in degrees.
Definition ambi_bin.c:778
void ambi_bin_setFlipPitch(void *const hAmbi, int newState)
Sets a flag as to whether to "flip" the sign of the current 'pitch' angle.
Definition ambi_bin.c:641
int ambi_bin_getHRIRlength(void *const hAmbi)
Returns the length of HRIRs in time-domain samples.
Definition ambi_bin.c:821
float ambi_bin_getRoll(void *const hAmbi)
Returns the 'roll' rotation angle, in degrees.
Definition ambi_bin.c:784
void ambi_bin_setNormType(void *const hAmbi, int newType)
Sets the Ambisonic normalisation convention to decode with, in order to match with the convention emp...
Definition ambi_bin.c:562
void ambi_bin_setEnableRotation(void *const hAmbi, int newState)
Sets the flag to enable/disable (1 or 0) sound-field rotation.
Definition ambi_bin.c:605
void ambi_bin_setRPYflag(void *const hAmbi, int newState)
Sets a flag as to whether to use "yaw-pitch-roll" (0) or "roll-pitch-yaw" (1) rotation order.
Definition ambi_bin.c:659
int ambi_bin_getFlipPitch(void *const hAmbi)
Returns a flag as to whether to "flip" the sign of the current 'pitch' angle ('0' do not flip sign,...
Definition ambi_bin.c:796
int ambi_bin_getFlipRoll(void *const hAmbi)
Returns a flag as to whether to "flip" the sign of the current 'roll' angle ('0' do not flip sign,...
Definition ambi_bin.c:802
void ambi_bin_setYaw(void *const hAmbi, float newYaw_deg)
Sets the 'yaw' rotation angle, in degrees.
Definition ambi_bin.c:611
int ambi_bin_getFrameSize(void)
Returns the processing framesize (i.e., number of samples processed with every _process() call )
Definition ambi_bin.c:668
char * ambi_bin_getSofaFilePath(void *const hAmbi)
Returns the file path for a .sofa file.
Definition ambi_bin.c:715
float ambi_bin_getProgressBar0_1(void *const hAmbi)
(Optional) Returns current intialisation/processing progress, between 0..1
Definition ambi_bin.c:679
void ambi_bin_destroy(void **const phAmbi)
Destroys an instance of ambi_bin.
Definition ambi_bin.c:111
void ambi_bin_setUseDefaultHRIRsflag(void *const hAmbi, int newState)
Sets flag to dictate whether the default HRIRs in the Spatial_Audio_Framework should be used,...
Definition ambi_bin.c:512
AMBI_BIN_PREPROC
Available HRIR pre-preprocessing options.
Definition ambi_bin.h:141
@ HRIR_PREPROC_PHASE
Phase simplification based on ITD.
Definition ambi_bin.h:144
@ HRIR_PREPROC_EQ
Diffuse-field EQ (compensates CTF)
Definition ambi_bin.h:143
@ HRIR_PREPROC_OFF
No pre-processing active.
Definition ambi_bin.h:142
@ HRIR_PREPROC_ALL
Diffuse-field EQ AND phase-simplification.
Definition ambi_bin.h:145
void ambi_bin_setEnableTruncationEQ(void *const hAmbi, int newState)
Sets a flag to enable/disable (1 or 0) truncation EQ.
Definition ambi_bin.c:587
int ambi_bin_getRPYflag(void *const hAmbi)
Returns a flag as to whether to use "yaw-pitch-roll" (0) or "roll-pitch-yaw" (1) rotation order.
Definition ambi_bin.c:808
int ambi_bin_getFlipYaw(void *const hAmbi)
Returns a flag as to whether to "flip" the sign of the current 'yaw' angle ('0' do not flip sign,...
Definition ambi_bin.c:790
int ambi_bin_getInputOrderPreset(void *const hAmbi)
Returns the decoding order.
Definition ambi_bin.c:703
void ambi_bin_setDecodingMethod(void *const hAmbi, AMBI_BIN_DECODING_METHODS newMethod)
Sets the decoding method (see AMBI_BIN_DECODING_METHODS enum)
Definition ambi_bin.c:548
void ambi_bin_setEnableDiffuseMatching(void *const hAmbi, int newState)
Sets a flag to enable/disable (1 or 0) the diffuse-covariance constraint.
Definition ambi_bin.c:578
CODEC_STATUS ambi_bin_getCodecStatus(void *const hAmbi)
Returns current codec status, see CODEC_STATUS enum.
Definition ambi_bin.c:673
int ambi_bin_getUseDefaultHRIRsflag(void *const hAmbi)
Returns the value of a flag used to dictate whether the default HRIRs in the Spatial_Audio_Framework ...
Definition ambi_bin.c:691
float ambi_bin_getYaw(void *const hAmbi)
Returns the 'yaw' rotation angle, in degree.
Definition ambi_bin.c:772
int ambi_bin_getNDirs(void *const hAmbi)
Returns the number of directions in the currently used HRIR set.
Definition ambi_bin.c:814
void ambi_bin_getProgressBarText(void *const hAmbi, char *text)
(Optional) Returns current intialisation/processing progress text
Definition ambi_bin.c:685
void ambi_bin_init(void *const hAmbi, int samplerate)
Initialises ambi_bin with default settings, and samplerate.
Definition ambi_bin.c:149
void ambi_bin_setRoll(void *const hAmbi, float newRoll)
Sets the 'roll' rotation angle, in degrees.
Definition ambi_bin.c:625
void ambi_bin_refreshParams(void *const hAmbi)
Sets intialisation flags to 1, so as to re-initialise all settings/variables (as ambi_bin is currentl...
Definition ambi_bin.c:505