SAF
Loading...
Searching...
No Matches
spreader.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 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
42#ifndef __SPREADER_H_INCLUDED__
43#define __SPREADER_H_INCLUDED__
44
45#ifdef __cplusplus
46extern "C" {
47#endif /* __cplusplus */
48
49#include "_common.h"
50
52#define SPREADER_MAX_NUM_SOURCES ( 8 )
53
62
63/* ========================================================================== */
64/* Main Functions */
65/* ========================================================================== */
66
72void spreader_create(void** const phSpr);
73
79void spreader_destroy(void** const phSpr);
80
89void spreader_init(void* const hSpr,
90 int samplerate);
91
107void spreader_initCodec(void* const hSpr);
108
119void spreader_process(void* const hSpr,
120 const float *const * inputs,
121 float* const* outputs,
122 int nInputs,
123 int nOutputs,
124 int nSamples);
125
126
127/* ========================================================================== */
128/* Set Functions */
129/* ========================================================================== */
130
135void spreader_refreshSettings(void* const hSpr);
136
138void spreader_setSpreadingMode(void* const hSpr, int newMode);
139
141void spreader_setAveragingCoeff(void* const hSpr, float newValue);
142
144void spreader_setSourceAzi_deg(void* const hSpr,
145 int index,
146 float newAzi_deg);
147
149void spreader_setSourceElev_deg(void* const hSpr,
150 int index,
151 float newElev_deg);
152
154void spreader_setSourceSpread_deg(void* const hSpr,
155 int index,
156 float newSpread_deg);
157
159void spreader_setNumSources(void* const hSpr, int new_nSources);
160
169void spreader_setUseDefaultHRIRsflag(void* const hSpr, int newState);
170
182void spreader_setSofaFilePath(void* const hSpr, const char* path);
183
184
185/* ========================================================================== */
186/* Get Functions */
187/* ========================================================================== */
188
193int spreader_getFrameSize(void);
194
196CODEC_STATUS spreader_getCodecStatus(void* const hSpr);
197
203float spreader_getProgressBar0_1(void* const hSpr);
204
211void spreader_getProgressBarText(void* const hSpr, char* text);
212
217int* spreader_getDirectionActivePtr(void* const hSpr, int index);
218
220int spreader_getSpreadingMode(void* const hSpr);
221
223float spreader_getAveragingCoeff(void* const hSpr);
224
226float spreader_getSourceAzi_deg(void* const hSpr, int index);
227
229float spreader_getSourceElev_deg(void* const hSpr, int index);
230
232float spreader_getSourceSpread_deg(void* const hSpr, int index);
233
235int spreader_getNumSources(void* const hSpr);
236
239
241int spreader_getNumOutputs(void* const hSpr);
242
244int spreader_getNDirs(void* const hSpr);
245
247float spreader_getIRAzi_deg(void* const hSpr, int index);
248
250float spreader_getIRElev_deg(void* const hSpr, int index);
251
253int spreader_getIRlength(void* const hSpr);
254
256int spreader_getIRsamplerate(void* const hSpr);
257
266int spreader_getUseDefaultHRIRsflag(void* const hSpr);
267
278char* spreader_getSofaFilePath(void* const hSpr);
279
281int spreader_getDAWsamplerate(void* const hSpr);
282
288
289
290#ifdef __cplusplus
291} /* extern "C" { */
292#endif /* __cplusplus */
293
294#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