SAF
Loading...
Searching...
No Matches
binauraliser.h

Convolves input audio (up to 64 channels) with interpolated HRTFs in the time-frequency domain.

Convolves input audio (up to 64 channels) with interpolated HRTFs in the time-frequency domain.

Files

binauraliser.h (include), binauraliser_internal.h, binauraliser.c, binauraliser_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 __BINAURALISER_H_INCLUDED__
#define __BINAURALISER_H_INCLUDED__
#include "_common.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* ========================================================================== */
/* Presets + Constants */
/* ========================================================================== */
typedef enum {
INTERP_TRI = 1,
/* ========================================================================== */
/* Main Functions */
/* ========================================================================== */
void binauraliser_create(void** const phBin);
void binauraliser_destroy(void** const phBin);
void binauraliser_init(void* const hBin,
int samplerate);
void binauraliser_initCodec(void* const hBin);
void binauraliser_process(void* const hBin,
const float *const * inputs,
float* const* outputs,
int nInputs,
int nOutputs,
int nSamples);
/* ========================================================================== */
/* Set Functions */
/* ========================================================================== */
void binauraliser_refreshSettings(void* const hBin);
void binauraliser_setSourceAzi_deg(void* const hBin,
int index,
float newAzi_deg);
void binauraliser_setSourceElev_deg(void* const hBin,
int index,
float newElev_deg);
void binauraliser_setNumSources(void* const hBin, int new_nSources);
void binauraliser_setUseDefaultHRIRsflag(void* const hBin, int newState);
void binauraliser_setSofaFilePath(void* const hBin, const char* path);
void binauraliser_setEnableHRIRsDiffuseEQ(void* const hBin, int newState);
void binauraliser_setInputConfigPreset(void* const hBin, int newPresetID);
void binauraliser_setEnableRotation(void* const hBin, int newState);
void binauraliser_setYaw(void* const hBin, float newYaw);
void binauraliser_setPitch(void* const hBin, float newPitch);
void binauraliser_setRoll(void* const hBin, float newRoll);
void binauraliser_setFlipYaw(void* const hBin, int newState);
void binauraliser_setFlipPitch(void* const hBin, int newState);
void binauraliser_setFlipRoll(void* const hBin, int newState);
void binauraliser_setRPYflag(void* const hBin, int newState);
void binauraliser_setInterpMode(void* const hBin, int newMode);
void binauraliser_setSourceGain(void* const hBin, int srcIdx, float newGain);
void binauraliser_setSourceSolo(void* const hBin, int srcIdx);
void binauraliser_setUnSolo(void* const hBin);
/* ========================================================================== */
/* Get Functions */
/* ========================================================================== */
float binauraliser_getProgressBar0_1(void* const hBin);
void binauraliser_getProgressBarText(void* const hBin, char* text);
float binauraliser_getSourceAzi_deg(void* const hBin, int index);
float binauraliser_getSourceElev_deg(void* const hBin, int index);
int binauraliser_getNumSources(void* const hBin);
int binauraliser_getNDirs(void* const hBin);
int binauraliser_getNTriangles(void* const hBin);
float binauraliser_getHRIRAzi_deg(void* const hBin, int index);
float binauraliser_getHRIRElev_deg(void* const hBin, int index);
int binauraliser_getHRIRlength(void* const hBin);
int binauraliser_getHRIRsamplerate(void* const hBin);
char* binauraliser_getSofaFilePath(void* const hBin);
int binauraliser_getDAWsamplerate(void* const hBin);
int binauraliser_getEnableRotation(void* const hBin);
float binauraliser_getYaw(void* const hBin);
float binauraliser_getPitch(void* const hBin);
float binauraliser_getRoll(void* const hBin);
int binauraliser_getFlipYaw(void* const hBin);
int binauraliser_getFlipPitch(void* const hBin);
int binauraliser_getFlipRoll(void* const hBin);
int binauraliser_getRPYflag(void* const hBin);
int binauraliser_getInterpMode(void* const hBin);
#ifdef __cplusplus
} /* extern "C" { */
#endif /* __cplusplus */
#endif /* __BINAURALISER_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
int binauraliser_getNTriangles(void *const hBin)
Returns the number of triangular groupings (faces) returned by the Convex Hull.
void binauraliser_setSofaFilePath(void *const hBin, const char *path)
Sets the file path for a .sofa file, in order to employ a custom HRIR set for the decoding.
void binauraliser_refreshSettings(void *const hBin)
Sets all intialisation flags to 1; re-initialising all settings/variables as binauraliser is currentl...
char * binauraliser_getSofaFilePath(void *const hBin)
Returns the file path for a .sofa file.
void binauraliser_setEnableHRIRsDiffuseEQ(void *const hBin, int newState)
Enable (1) or disable (0) the diffuse-field EQ applied to the HRTFs.
int binauraliser_getFlipPitch(void *const hBin)
Returns a flag as to whether to "flip" the sign of the current 'pitch' angle (0: do not flip sign,...
int binauraliser_getNDirs(void *const hBin)
Returns the number of directions in the currently used HRIR set.
void binauraliser_process(void *const hBin, const float *const *inputs, float *const *outputs, int nInputs, int nOutputs, int nSamples)
Binauralises the input signals at the user specified directions.
void binauraliser_destroy(void **const phBin)
Destroys an instance of the binauraliser.
int binauraliser_getUseDefaultHRIRsflag(void *const hBin)
Returns the value of a flag used to dictate whether the default HRIRs in the Spatial_Audio_Framework ...
void binauraliser_setRoll(void *const hBin, float newRoll)
Sets the 'roll' rotation angle, in DEGREES.
void binauraliser_initCodec(void *const hBin)
Intialises the codec variables, based on current global/user parameters.
int binauraliser_getFlipRoll(void *const hBin)
Returns a flag as to whether to "flip" the sign of the current 'roll' angle (0: do not flip sign,...
void binauraliser_setSourceAzi_deg(void *const hBin, int index, float newAzi_deg)
Sets the panning azimuth for a specific channel index, in DEGREES.
void binauraliser_setPitch(void *const hBin, float newPitch)
Sets the 'pitch' rotation angle, in DEGREES.
void binauraliser_setSourceGain(void *const hBin, int srcIdx, float newGain)
Sets gain factor for an input source.
int binauraliser_getEnableHRIRsDiffuseEQ(void *const hBin)
Returns the flag indicating whether the diffuse-field EQ applied to the HRTFs is enabled (1) or disab...
void binauraliser_setSourceElev_deg(void *const hBin, int index, float newElev_deg)
Sets the panning elevation for a specific channel index, in DEGREES.
void binauraliser_init(void *const hBin, int samplerate)
Initialises an instance of binauraliser with default settings.
float binauraliser_getProgressBar0_1(void *const hBin)
(Optional) Returns current intialisation/processing progress, between 0..1
INTERP_MODES
Available interpolation modes.
@ INTERP_TRI
Triangular interpolation.
@ INTERP_TRI_PS
Triangular interpolation (with phase-simplification)
CODEC_STATUS binauraliser_getCodecStatus(void *const hBin)
Returns current codec status codec status (see CODEC_STATUS enum)
int binauraliser_getMaxNumSources(void)
Returns the maximum number of input sources supported by binauraliser.
void binauraliser_create(void **const phBin)
Creates an instance of the binauraliser.
int binauraliser_getRPYflag(void *const hBin)
Returns a flag as to whether to use "yaw-pitch-roll" (0) or "roll-pitch-yaw" (1) rotation order.
float binauraliser_getPitch(void *const hBin)
Returns the 'pitch' rotation angle, in DEGREES.
int binauraliser_getFrameSize(void)
Returns the processing framesize (i.e., number of samples processed with every _process() call )
int binauraliser_getEnableRotation(void *const hBin)
Returns the flag value which dictates whether to enable/disable sound-field rotation (0: disabled,...
void binauraliser_setRPYflag(void *const hBin, int newState)
Sets a flag as to whether to use "yaw-pitch-roll" (0) or "roll-pitch-yaw" (1) rotation order.
int binauraliser_getNumEars(void)
Returns the number of ears possessed by the average homo sapien.
void binauraliser_getProgressBarText(void *const hBin, char *text)
(Optional) Returns current intialisation/processing progress text
int binauraliser_getProcessingDelay(void)
Returns the processing delay in samples (may be used for delay compensation purposes)
int binauraliser_getDAWsamplerate(void *const hBin)
Returns the DAW/Host sample rate.
int binauraliser_getHRIRsamplerate(void *const hBin)
Returns the HRIR sample rate.
float binauraliser_getYaw(void *const hBin)
Returns the 'yaw' rotation angle, in DEGREES.
float binauraliser_getSourceElev_deg(void *const hBin, int index)
Returns the source elevation for a given index, in DEGREES.
void binauraliser_setFlipPitch(void *const hBin, int newState)
Sets a flag as to whether to "flip" the sign of the current 'pitch' angle (0: do not flip sign,...
void binauraliser_setEnableRotation(void *const hBin, int newState)
Sets the flag to enable/disable (1 or 0) rotation.
void binauraliser_setFlipYaw(void *const hBin, int newState)
Sets a flag as to whether to "flip" the sign of the current 'yaw' angle (0: do not flip sign,...
void binauraliser_setYaw(void *const hBin, float newYaw)
Sets the 'yaw' rotation angle, in DEGREES.
void binauraliser_setInputConfigPreset(void *const hBin, int newPresetID)
Loads an input preset (see SOURCE_CONFIG_PRESETS enum)
void binauraliser_setInterpMode(void *const hBin, int newMode)
NOT IMPLEMENTED YET.
void binauraliser_setUseDefaultHRIRsflag(void *const hBin, int newState)
Sets flag to dictate whether the default HRIRs in the Spatial_Audio_Framework should be used (1),...
void binauraliser_setUnSolo(void *const hBin)
Unsolo / unmute all sources.
float binauraliser_getHRIRElev_deg(void *const hBin, int index)
Returns the HRIR/HRTF elevation for a given index, in DEGREES.
float binauraliser_getSourceAzi_deg(void *const hBin, int index)
Returns the source azimuth for a given index, in DEGREES.
float binauraliser_getRoll(void *const hBin)
Returns the 'roll' rotation angle, in DEGREES.
void binauraliser_setFlipRoll(void *const hBin, int newState)
Sets a flag as to whether to "flip" the sign of the current 'roll' angle (0: do not flip sign,...
int binauraliser_getFlipYaw(void *const hBin)
Returns a flag as to whether to "flip" the sign of the current 'yaw' angle (0: do not flip sign,...
int binauraliser_getInterpMode(void *const hBin)
NOT IMPLEMENTED YET.
int binauraliser_getHRIRlength(void *const hBin)
Returns the length of HRIRs in time-domain samples.
float binauraliser_getHRIRAzi_deg(void *const hBin, int index)
Returns the HRIR/HRTF azimuth for a given index, in DEGREES.
void binauraliser_setSourceSolo(void *const hBin, int srcIdx)
Set a source to solo.
void binauraliser_setNumSources(void *const hBin, int new_nSources)
Sets the number of input channels/sources to binauralise.
int binauraliser_getNumSources(void *const hBin)
Returns the number of inputs/sources in the current layout.