forked from leomccormack/Spatial_Audio_Framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsldoa.h
318 lines (272 loc) · 12.3 KB
/
sldoa.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
/*
* 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.
*/
/**
* @example sldoa.h
* @brief A spatially-localised active-intensity (SLAI) based direction-of-
* arrival estimator (SLDoA)
*
* ### Files
* sldoa.h (include), sldoa_internal.h, sldoa_database.h, sldoa.c,
* sldoa_internal.c, sldoa_database.c
* ### Include Header
*/
/**
* @file sldoa.h
* @brief A spatially-localised active-intensity (SLAI) based direction-of-
* arrival estimator (SLDoA)
*
* VBAP gain patterns are imposed on the spherical harmonic signals, such that
* the DoA can be estimated in a spatially-constrained region; thus mitigating
* the effect of interferes and reflections arriving from other directions.
* The DoA is estimated per sector for each frequency band.
*
* The algorithms within sldoa were developed in collaboration with Symeon
* Delikaris-Manias and Angelo Farina, and are explained in more detail in [1,2]
*
* @see [1] McCormack, L., Delikaris-Manias, S., Politis, A., Pavlidi, D.,
* Farina, A., Pinardi, D. and Pulkki, V., 2019. Applications of
* Spatially Localized Active-Intensity Vectors for Sound-Field
* Visualization. Journal of the Audio Engineering Society, 67(11),
* pp.840-854.
* @see [2] McCormack, L., Delikaris-Manias, S., Farina, A., Pinardi, D., and
* Pulkki, V., "Real-time conversion of sensor array signals into
* spherical harmonic signals with applications to spatially localised
* sub-band sound-field analysis," in Audio Engineering Society
* Convention 144, Audio Engineering Society, 2018.
*
* @author Leo McCormack
* @date 18.10.2017
* @license ISC
*/
#ifndef __SLDOA_H_INCLUDED__
#define __SLDOA_H_INCLUDED__
#include "_common.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* ========================================================================== */
/* Main Functions */
/* ========================================================================== */
/**
* Creates an instance of the sldoa
*
* @param[in] phSld (&) address of sldoa handle
*/
void sldoa_create(void** const phSld);
/**
* Destroys an instance of the sldoa
*
* @param[in] phSld (&) address of sldoa handle
*/
void sldoa_destroy(void** const phSld);
/**
* Initialises an instance of sldoa with default settings
*
* @warning This should not be called while _process() is on-going!
*
* @param[in] hSld sldoa handle
* @param[in] samplerate Host samplerate.
*/
void sldoa_init(void* const hSld,
float samplerate);
/**
* Intialises the codec variables, based on current global/user parameters
*
* @note This function is fully threadsafe. It can even be called periodically
* via a timer on one thread, while calling _process() on another thread.
* Since, if a set function is called (that warrants a re-init), then a
* flag is triggered internally and the next time this function is called,
* it will wait until the current process() function has completed before
* reinitialising the relevant parameters. If the _initCodec() takes
* longer than the time it takes for process() to be called again, then
* process() is simply bypassed until the codec is ready.
* @note This function does nothing if no re-initialisations are required.
*
* @param[in] hSld - sldoa handle
*/
void sldoa_initCodec(void* const hSld);
/**
* Applies the spatially-localised active-intensity based direction-of-arrival
* estimator (SLDoA) onto the input signals [1,2].
*
* @param[in] hSld sldoa handle
* @param[in] inputs Input channel buffers; 2-D array: nInputs x nSamples
* @param[in] nInputs Number of input channels
* @param[in] nSamples Number of samples in 'inputs'/'output' matrices
* @param[in] isPlaying Flag to say if there is audio in the damn input buffers,
* 0: no audio, reduced processing, 1: audio, full processing
*
* @see [1] McCormack, L., Delikaris-Manias, S., Farina, A., Pinardi, D., and
* Pulkki, V., “Real-time conversion of sensor array signals into
* spherical harmonic signals with applications to spatially localised
* sub-band sound-field analysis,” in Audio Engineering Society
* Convention 144, Audio Engineering Society, 2018.
* @see [2] McCormack, L., Delikaris-Manias, S., Politis, A., Pavlidi, D.,
* Farina, A., Pinardi, D. and Pulkki, V., 2019. Applications of
* Spatially Localized Active-Intensity Vectors for Sound-Field
* Visualization. Journal of the Audio Engineering Society, 67(11),
* pp.840-854.
*/
void sldoa_analysis(void* const hSld,
const float *const * inputs,
int nInputs,
int nSamples,
int isPlaying);
/* ========================================================================== */
/* Set Functions */
/* ========================================================================== */
/** Sets the maximum input/analysis order (see #SH_ORDERS enum) */
void sldoa_setMasterOrder(void* const hSld, int newValue);
/**
* Sets all intialisation flags to 1; re-initialising all settings/variables
* as sldoa is currently configured, at next available opportunity.
*/
void sldoa_refreshSettings(void* const hSld);
/** Sets the maximum analysis frequency, in Hz */
void sldoa_setMaxFreq(void* const hSld, float newFreq);
/** Sets the minimum analysis frequency, in Hz */
void sldoa_setMinFreq(void* const hSld, float newFreq);
/** Sets the DoA averaging coefficient, 0..1 */
void sldoa_setAvg(void* const hSld, float newAvg);
/** Sets the input/analysis order for one specific frequency band */
void sldoa_setAnaOrder(void* const hSld, int newValue, int bandIdx);
/** Sets the input/analysis order for all frequency bands */
void sldoa_setAnaOrderAllBands(void* const hSld, int newValue);
/**
* 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 sldoa_setChOrder(void* const hSld, int newOrder);
/**
* 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 sldoa_setNormType(void* const hSld, int newType);
/**
* Sets an input preset, the microphone/hyrophone array used to capture
* the input signals (see #MIC_PRESETS enum)
*/
void sldoa_setSourcePreset(void* const hSld, int newPresetID);
/* ========================================================================== */
/* Get Functions */
/* ========================================================================== */
/**
* Returns the processing framesize (i.e., number of samples processed with
* every _process() call )
*/
int sldoa_getFrameSize(void);
/** Returns current codec status (see #CODEC_STATUS enum) */
CODEC_STATUS sldoa_getCodecStatus(void* const hSld);
/**
* (Optional) Returns current intialisation/processing progress, between 0..1
* - 0: intialisation/processing has started
* - 1: intialisation/processing has ended
*/
float sldoa_getProgressBar0_1(void* const hSld);
/**
* (Optional) Returns current intialisation/processing progress text
*
* @note "text" string should be (at least) of length:
* #PROGRESSBARTEXT_CHAR_LENGTH
*/
void sldoa_getProgressBarText(void* const hSld, char* text);
/** Returns the current maximum analysis/input order (see #SH_ORDERS enum) */
int sldoa_getMasterOrder(void* const hSld);
/** Returns the current sampling rate, in Hz */
int sldoa_getSamplingRate(void* const hSld);
/** Returns the maximum analysis frequency, in Hz */
float sldoa_getMaxFreq(void* const hSld);
/** Returns the minimum analysis frequency, in Hz */
float sldoa_getMinFreq(void* const hSld);
/** Returns the current DoA averaging coefficient value, 0..1 */
float sldoa_getAvg(void* const hSld);
/** Returns the number frequency bands employed by sldoa */
int sldoa_getNumberOfBands(void);
/**
* Returns the number of spherical harmonic signals required by the current
* analysis order: (current_order + 1)^2
*/
int sldoa_getNSHrequired(void* const hSld);
/**
* Returns the analysis output data. Including the DoAs per frequency, and per
* sector, accompanied by colour coefficients (red: high frequencies, blue:
* low frequencies), and alpha coefficients (more opaque: higher energy, more
* transpararent: less energy).
*
* @note nBands can be found by using sldoa_getNumberOfBands()
*
* @param[in] hSld sldoa handle
* @param[out] pAzi_deg (&) azimuth of estimated DoAs;
* FLAT: pNsectorsPerBand x nBands
* @param[out] pElev_deg (&) elevation of estimated DoAs;
* FLAT: pNsectorsPerBand x nBands
* @param[out] pColourScale (&) colour scale, 0..1, 1:red, 0: blue
* FLAT: pNsectorsPerBand x nBands
* @param[out] pAlphaScale (&) alpha scale, 0..1, 1: opaque, 0: transparent
* FLAT: pNsectorsPerBand x nBands
* @param[out] pNsectorsPerBand (&) number of sectors per frequency;
* pNsectorsPerBand x 1
* @param[out] pMaxNumSectors (&) maximum number of sectors
* @param[out] pStartBand (&) band index corresponding to lowest frequency
* @param[out] pEndBand (&) band index corresponding to highest
* frequency
*/
void sldoa_getDisplayData(void * const hSld,
float** pAzi_deg,
float** pElev_deg,
float** pColourScale,
float** pAlphaScale,
int** pNsectorsPerBand,
int* pMaxNumSectors,
int* pStartBand,
int* pEndBand);
/** Returns the input/analysis order for one specific frequency band */
int sldoa_getAnaOrder(void* const hSld, int bandIdx);
/** Returns the input/analysis order for the first frequency band */
int sldoa_getAnaOrderAllBands(void* const hSld);
/**
* Returns the input/analysis order for all frequency bands
*
* @param[in] hSld sldoa handle
* @param[out] pX_vector (&) frequency vector; pNpoints x 1
* @param[out] pY_values (&) input/analysis orders; pNpoints x 1
* @param[out] pNpoints (&) number of frequency bands
*/
void sldoa_getAnaOrderHandle(void* const hSld,
float** pX_vector,
int** pY_values,
int* pNpoints);
/**
* 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 sldoa_getChOrder(void* const hSld);
/**
* 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 sldoa_getNormType(void* const hSld);
/**
* Returns the processing delay in samples (may be used for delay compensation
* features)
*/
int sldoa_getProcessingDelay(void);
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
#endif /* __SLDOA_H_INCLUDED__ */