SAF
Loading...
Searching...
No Matches
spreader.h

An arbitrary array panner (HRIRs, microphone array IRs, etc.) with coherent and incoherent spreading modes.

An arbitrary array panner (HRIRs, microphone array IRs, etc.) with coherent and incoherent spreading modes.

Files

spreader.h (include), spreader_internal.h, spreader.c, spreader_internal.c

Include Header

/*
* Copyright 2021 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 __SPREADER_H_INCLUDED__
#define __SPREADER_H_INCLUDED__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "_common.h"
#define SPREADER_MAX_NUM_SOURCES ( 8 )
typedef enum {
/* ========================================================================== */
/* Main Functions */
/* ========================================================================== */
void spreader_create(void** const phSpr);
void spreader_destroy(void** const phSpr);
void spreader_init(void* const hSpr,
int samplerate);
void spreader_initCodec(void* const hSpr);
void spreader_process(void* const hSpr,
const float *const * inputs,
float* const* outputs,
int nInputs,
int nOutputs,
int nSamples);
/* ========================================================================== */
/* Set Functions */
/* ========================================================================== */
void spreader_refreshSettings(void* const hSpr);
void spreader_setSpreadingMode(void* const hSpr, int newMode);
void spreader_setAveragingCoeff(void* const hSpr, float newValue);
void spreader_setSourceAzi_deg(void* const hSpr,
int index,
float newAzi_deg);
void spreader_setSourceElev_deg(void* const hSpr,
int index,
float newElev_deg);
void spreader_setSourceSpread_deg(void* const hSpr,
int index,
float newSpread_deg);
void spreader_setNumSources(void* const hSpr, int new_nSources);
void spreader_setUseDefaultHRIRsflag(void* const hSpr, int newState);
void spreader_setSofaFilePath(void* const hSpr, const char* path);
/* ========================================================================== */
/* Get Functions */
/* ========================================================================== */
float spreader_getProgressBar0_1(void* const hSpr);
void spreader_getProgressBarText(void* const hSpr, char* text);
int* spreader_getDirectionActivePtr(void* const hSpr, int index);
int spreader_getSpreadingMode(void* const hSpr);
float spreader_getAveragingCoeff(void* const hSpr);
float spreader_getSourceAzi_deg(void* const hSpr, int index);
float spreader_getSourceElev_deg(void* const hSpr, int index);
float spreader_getSourceSpread_deg(void* const hSpr, int index);
int spreader_getNumSources(void* const hSpr);
int spreader_getNumOutputs(void* const hSpr);
int spreader_getNDirs(void* const hSpr);
float spreader_getIRAzi_deg(void* const hSpr, int index);
float spreader_getIRElev_deg(void* const hSpr, int index);
int spreader_getIRlength(void* const hSpr);
int spreader_getIRsamplerate(void* const hSpr);
int spreader_getUseDefaultHRIRsflag(void* const hSpr);
char* spreader_getSofaFilePath(void* const hSpr);
int spreader_getDAWsamplerate(void* const hSpr);
#ifdef __cplusplus
} /* extern "C" { */
#endif /* __cplusplus */
#endif /* __SPREADER_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 spreader_init(void *const hSpr, int samplerate)
Initialises an instance of spreader with default settings.
Definition spreader.c:195
int spreader_getNumSources(void *const hSpr)
Returns the number of inputs/sources in the current config.
Definition spreader.c:833
int spreader_getProcessingDelay(void)
Returns the processing delay in samples (may be used for delay compensation purposes)
Definition spreader.c:908
int spreader_getIRsamplerate(void *const hSpr)
Returns the IR sample rate.
Definition spreader.c:880
int spreader_getMaxNumSources(void)
Returns the maximum number of input sources supported by spreader.
Definition spreader.c:839
int spreader_getNDirs(void *const hSpr)
Returns the number of directions in the currently used HRIR set.
Definition spreader.c:850
float spreader_getIRAzi_deg(void *const hSpr, int index)
Returns the IR/TF azimuth for a given index, in DEGREES.
Definition spreader.c:856
void spreader_setSourceSpread_deg(void *const hSpr, int index, float newSpread_deg)
Sets the source spread for a specific channel index, in DEGREES.
Definition spreader.c:732
int * spreader_getDirectionActivePtr(void *const hSpr, int index)
Returns the pointer to a vector describing which directions are currently being used for the spreadin...
Definition spreader.c:794
void spreader_setSpreadingMode(void *const hSpr, int newMode)
Sets the spreading mode (see SPREADER_PROC_MODES)
Definition spreader.c:697
float spreader_getSourceElev_deg(void *const hSpr, int index)
Returns the source elevation for a given source index, in DEGREES.
Definition spreader.c:819
void spreader_create(void **const phSpr)
Creates an instance of the spreader.
Definition spreader.c:35
int spreader_getFrameSize(void)
Returns the processing framesize (i.e., number of samples processed with every _process() call )
Definition spreader.c:771
int spreader_getIRlength(void *const hSpr)
Returns the length of IRs in time-domain samples.
Definition spreader.c:874
int spreader_getDAWsamplerate(void *const hSpr)
Returns the DAW/Host sample rate.
Definition spreader.c:902
void spreader_initCodec(void *const hSpr)
Intialises the codec variables, based on current global/user parameters.
Definition spreader.c:208
float spreader_getAveragingCoeff(void *const hSpr)
Returns the averaging coefficient [0..1].
Definition spreader.c:806
SPREADER_PROC_MODES
Available processing modes.
Definition spreader.h:55
@ SPREADER_MODE_NAIVE
Simple coherent copies of the input signal(s) areassigned to the spreading areas.
Definition spreader.h:56
@ SPREADER_MODE_EVD
Basic solution based on an Eigenvalue decomposition.
Definition spreader.h:59
@ SPREADER_MODE_OM
Optimal mixing solution.
Definition spreader.h:58
float spreader_getProgressBar0_1(void *const hSpr)
(Optional) Returns current intialisation/processing progress, between 0..1
Definition spreader.c:782
float spreader_getIRElev_deg(void *const hSpr, int index)
Returns the IR/TF elevation for a given index, in DEGREES.
Definition spreader.c:865
void spreader_setSofaFilePath(void *const hSpr, const char *path)
Sets the file path for a .sofa file, in order to employ a custom HRIR set for the decoding.
Definition spreader.c:758
float spreader_getSourceSpread_deg(void *const hSpr, int index)
Returns the source spread for a given source index, in DEGREES.
Definition spreader.c:826
void spreader_getProgressBarText(void *const hSpr, char *text)
(Optional) Returns current intialisation/processing progress text
Definition spreader.c:788
int spreader_getNumOutputs(void *const hSpr)
Returns the number of ears possessed by the average homo sapien.
Definition spreader.c:844
void spreader_setSourceElev_deg(void *const hSpr, int index, float newElev_deg)
Sets the panning elevation for a specific channel index, in DEGREES.
Definition spreader.c:722
void spreader_setNumSources(void *const hSpr, int new_nSources)
Sets the number of input channels/sources to binauralise.
Definition spreader.c:742
void spreader_refreshSettings(void *const hSpr)
Sets all intialisation flags to 1; re-initialising all settings/variables as spreader is currently co...
Definition spreader.c:692
int spreader_getUseDefaultHRIRsflag(void *const hSpr)
Returns the value of a flag used to dictate whether the default HRIRs in the Spatial_Audio_Framework ...
Definition spreader.c:886
void spreader_setSourceAzi_deg(void *const hSpr, int index, float newAzi_deg)
Sets the panning azimuth for a specific channel index, in DEGREES.
Definition spreader.c:710
float spreader_getSourceAzi_deg(void *const hSpr, int index)
Returns the source azimuth for a given source index, in DEGREES.
Definition spreader.c:812
void spreader_destroy(void **const phSpr)
Destroys an instance of the spreader.
Definition spreader.c:120
int spreader_getSpreadingMode(void *const hSpr)
Returns the spreading mode (see SPREADER_PROC_MODES)
Definition spreader.c:800
void spreader_setAveragingCoeff(void *const hSpr, float newValue)
Sets the averaging coefficient [0..1].
Definition spreader.c:704
char * spreader_getSofaFilePath(void *const hSpr)
Returns the file path for a .sofa file.
Definition spreader.c:892
void spreader_setUseDefaultHRIRsflag(void *const hSpr, int newState)
Sets flag to dictate whether the default HRIRs in the Spatial_Audio_Framework should be used (1),...
Definition spreader.c:749
CODEC_STATUS spreader_getCodecStatus(void *const hSpr)
Returns current codec status codec status (see CODEC_STATUS enum)
Definition spreader.c:776
void spreader_process(void *const hSpr, const float *const *inputs, float *const *outputs, int nInputs, int nOutputs, int nSamples)
Spatialises and spreads the input signals in the user specified directions.
Definition spreader.c:361