SAF
Loading...
Searching...
No Matches
array2sh.h
Go to the documentation of this file.
1/*
2 * Copyright 2017-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
91#ifndef __ARRAY2SH_H_INCLUDED__
92#define __ARRAY2SH_H_INCLUDED__
93
94#include "_common.h"
95
96#ifdef __cplusplus
97extern "C" {
98#endif /* __cplusplus */
99
100/* ========================================================================== */
101/* Presets + Constants */
102/* ========================================================================== */
103
105typedef enum {
106 MICROPHONE_ARRAY_PRESET_DEFAULT = 1,
107 MICROPHONE_ARRAY_PRESET_AALTO_HYDROPHONE,
108 MICROPHONE_ARRAY_PRESET_SENNHEISER_AMBEO,
109 MICROPHONE_ARRAY_PRESET_CORE_SOUND_TETRAMIC,
110 MICROPHONE_ARRAY_PRESET_ZOOM_H3VR_PRESET,
111 MICROPHONE_ARRAY_PRESET_SOUND_FIELD_SPS200,
112 MICROPHONE_ARRAY_PRESET_ZYLIA_1D,
113 MICROPHONE_ARRAY_PRESET_EIGENMIKE32,
114 MICROPHONE_ARRAY_PRESET_EIGENMIKE64,
115 MICROPHONE_ARRAY_PRESET_DTU_MIC
116
118
146
148#define ARRAY2SH_NUM_FILTER_TYPES ( 4 )
149
161
163#define ARRAY2SH_NUM_ARRAY_TYPES ( 2 )
164
176
178#define ARRAY2SH_NUM_WEIGHT_TYPES ( 6 )
179
193
195#define ARRAY2SH_MAX_NUM_SENSORS ( MAX_NUM_CHANNELS )
196
198#define ARRAY2SH_MAX_GAIN_MIN_VALUE ( 0.0f )
199
201#define ARRAY2SH_MAX_GAIN_MAX_VALUE ( 80.0f )
202
204#define ARRAY2SH_POST_GAIN_MIN_VALUE ( -60.0f )
205
207#define ARRAY2SH_POST_GAIN_MAX_VALUE ( 12.0f )
208
210#define ARRAY2SH_SPEED_OF_SOUND_MIN_VALUE ( 200.0f )
211
213#define ARRAY2SH_SPEED_OF_SOUND_MAX_VALUE ( 2000.0f )
214
216#define ARRAY2SH_ARRAY_RADIUS_MIN_VALUE ( 1.0f )
217
219#define ARRAY2SH_ARRAY_RADIUS_MAX_VALUE ( 400.0f )
220
222#define ARRAY2SH_BAFFLE_RADIUS_MIN_VALUE ( 1.0f )
223
225#define ARRAY2SH_BAFFLE_RADIUS_MAX_VALUE ( 400.0f )
226
227
228/* ========================================================================== */
229/* Main Functions */
230/* ========================================================================== */
231
237void array2sh_create(void** const phA2sh);
238
244void array2sh_destroy(void** const phA2sh);
245
252void array2sh_init(void* const hA2sh,
253 int samplerate);
254
260void array2sh_evalEncoder(void* const hA2sh);
261
273void array2sh_process(void* const hA2sh,
274 const float *const * inputs,
275 float* const* outputs,
276 int nInputs,
277 int nOutputs,
278 int nSamples);
279
280
281/* ========================================================================== */
282/* Set Functions */
283/* ========================================================================== */
284
289void array2sh_refreshSettings(void* const hA2sh);
290
292void array2sh_setEncodingOrder(void* const hA2sh, int newOrder);
293
304void array2sh_setRequestEncoderEvalFLAG(void* const hA2sh, int newState);
305
307void array2sh_setEvalStatus(void* const hA2sh, ARRAY2SH_EVAL_STATUS evalStatus);
308
315void array2sh_setDiffEQpastAliasing(void* const hA2sh, int newState);
316
321void array2sh_setPreset(void* const hA2sh,
323
332void array2sh_setSensorAzi_rad(void* const hA2sh, int index, float newAzi_rad);
333
342void array2sh_setSensorElev_rad(void* const hA2sh, int index, float newElev_rad);
343
353void array2sh_setSensorAzi_deg(void* const hA2sh, int index, float newAzi_deg);
354
363void array2sh_setSensorElev_deg(void* const hA2sh, int index, float newElev_deg);
364
366void array2sh_setNumSensors(void* const hA2sh, int newQ);
367
369void array2sh_setr(void* const hA2sh, float newr);
370
377void array2sh_setR(void* const hA2sh, float newR);
378
380void array2sh_setArrayType(void* const hA2sh, int newType);
381
383void array2sh_setWeightType(void* const hA2sh, int newType);
384
389void array2sh_setFilterType(void* const hA2sh, int newType);
390
395void array2sh_setRegPar(void* const hA2sh, float newVal);
396
401void array2sh_setChOrder(void* const hA2sh, int newOrder);
402
407void array2sh_setNormType(void* const hA2sh, int newType);
408
412void array2sh_setc(void* const hA2sh, float newc);
413
415void array2sh_setGain(void* const hA2sh, float newGain);
416
417
418/* ========================================================================== */
419/* Get Functions */
420/* ========================================================================== */
421
426int array2sh_getFrameSize(void);
427
430
434int array2sh_getReinitSHTmatrixFLAG(void* const hA2sh);
435
441float array2sh_getProgressBar0_1(void* const hA2sh);
442
449void array2sh_getProgressBarText(void* const hA2sh, char* text);
450
467int array2sh_getDiffEQpastAliasing(void* const hA2sh);
468
473int array2sh_getRequestEncoderEvalFLAG(void* const hA2sh);
474
476int array2sh_getEncodingOrder(void* const hA2sh);
477
482float array2sh_getSensorAzi_rad(void* const hA2sh, int index);
483
488float array2sh_getSensorElev_rad(void* const hA2sh, int index);
489
494float array2sh_getSensorAzi_deg(void* const hA2sh, int index);
495
500float array2sh_getSensorElev_deg(void* const hA2sh, int index);
501
503int array2sh_getNumSensors(void* const hA2sh);
504
507
512int array2sh_getMinNumSensors(void* const hA2sh);
513
518int array2sh_getNSHrequired(void* const hA2sh);
519
521float array2sh_getr(void* const hA2sh);
522
524float array2sh_getR(void* const hA2sh);
525
527int array2sh_getArrayType(void* const hA2sh);
528
530int array2sh_getWeightType(void* const hA2sh);
531
536int array2sh_getFilterType(void* const hA2sh);
537
542float array2sh_getRegPar(void* const hA2sh);
543
549int array2sh_getChOrder(void* const hA2sh);
550
556int array2sh_getNormType(void* const hA2sh);
557
562float array2sh_getc(void* const hA2sh);
563
565float array2sh_getGain(void* const hA2sh);
566
574float* array2sh_getFreqVector(void* const hA2sh, int* nFreqPoints);
575
586float** array2sh_getbN_inv(void* const hA2sh, int* nCurves, int* nFreqPoints);
587
598float** array2sh_getbN_modal(void* const hA2sh, int* nCurves, int* nFreqPoints);
599
621float* array2sh_getSpatialCorrelation_Handle(void* const hA2sh,
622 int* nCurves,
623 int* nFreqPoints);
624
646float* array2sh_getLevelDifference_Handle(void* const hA2sh, int* nCurves, int* nFreqPoints);
647
649int array2sh_getSamplingRate(void* const hA2sh);
650
656
657
658#ifdef __cplusplus
659} /* extern "C" { */
660#endif /* __cplusplus */
661
662#endif /* __ARRAY2SH_H_INCLUDED__ */
A bunch of things that are common to many of the saf examples.
float array2sh_getR(void *const hA2sh)
Returns the radius of the scatterer, in meters.
Definition array2sh.c:623
void array2sh_setNormType(void *const hA2sh, int newType)
Sets the Ambisonic normalisation convention to encode with, in order to match with the convention emp...
Definition array2sh.c:489
float * array2sh_getSpatialCorrelation_Handle(void *const hA2sh, int *nCurves, int *nFreqPoints)
Returns a pointer to the spatial correlation [1] data.
Definition array2sh.c:703
float array2sh_getSensorElev_deg(void *const hA2sh, int index)
Returns a particular sensor's elevation w.r.t to the origin of the array, in DEGREES.
Definition array2sh.c:584
float array2sh_getr(void *const hA2sh)
Returns the radius of the array, in meters.
Definition array2sh.c:616
ARRAY2SH_MICROPHONE_ARRAY_PRESETS
Available microphone array presets.
Definition array2sh.h:105
void array2sh_setNumSensors(void *const hA2sh, int newQ)
Sets the number of sensors in the array.
Definition array2sh.c:391
float ** array2sh_getbN_inv(void *const hA2sh, int *nCurves, int *nFreqPoints)
Returns the regularised inversion of the modal coefficients per frequency (may be used for optional p...
Definition array2sh.c:687
void array2sh_setSensorElev_rad(void *const hA2sh, int index, float newElev_rad)
Sets a particular sensor's elevation (radians) w.r.t to the origin of the array.
Definition array2sh.c:351
void array2sh_setR(void *const hA2sh, float newR)
Sets the radius (in meters) of the scatterer (only for Rigid arrays).
Definition array2sh.c:423
void array2sh_setEvalStatus(void *const hA2sh, ARRAY2SH_EVAL_STATUS evalStatus)
Sets current eval status (see ARRAY2SH_EVAL_STATUS enum)
Definition array2sh.c:306
void array2sh_destroy(void **const phA2sh)
Destroys an instance of array2sh.
Definition array2sh.c:105
void array2sh_setGain(void *const hA2sh, float newGain)
Sets the amount of post gain to apply after the encoding, in DECIBELS.
Definition array2sh.c:507
float array2sh_getSensorAzi_deg(void *const hA2sh, int index)
Returns a particular sensor's azimuth w.r.t to the origin of the array, in DEGREES.
Definition array2sh.c:577
float * array2sh_getFreqVector(void *const hA2sh, int *nFreqPoints)
Returns a pointer to the frequency vector.
Definition array2sh.c:680
ARRAY2SH_FILTER_TYPES
Available encoding filter approaches.
Definition array2sh.h:134
@ FILTER_Z_STYLE
Encoding filters based on a linear-phase filter- bank approach [3].
Definition array2sh.h:140
@ FILTER_SOFT_LIM
Encoding filters based on a 'soft-limiting' regularised inversion of the modal responses [1].
Definition array2sh.h:135
@ FILTER_Z_STYLE_MAXRE
Same as FILTER_Z_STYLE, only it also has max_rE weights baked in.
Definition array2sh.h:142
@ FILTER_TIKHONOV
Encoding filters based on a 'Tikhonov' regularised inversion of the modal responses [2].
Definition array2sh.h:138
void array2sh_create(void **const phA2sh)
Creates an instance of array2sh.
Definition array2sh.c:53
void array2sh_setRegPar(void *const hA2sh, float newVal)
Sets the value of the regularisation parameter (the maximum permitted gain of the filters),...
Definition array2sh.c:471
int array2sh_getRequestEncoderEvalFLAG(void *const hA2sh)
Returns a flag, which is '1' if there has been a recent request to evaluate the current encoding perf...
Definition array2sh.c:545
int array2sh_getMaxNumSensors(void)
Returns the maximum supported number of sensors which can be in the array.
Definition array2sh.c:599
void array2sh_setArrayType(void *const hA2sh, int newType)
Sets the type of array (see ARRAY2SH_ARRAY_TYPES enum)
Definition array2sh.c:436
int array2sh_getEncodingOrder(void *const hA2sh)
Returns the current encoding order (see SH_ORDERS enum)
Definition array2sh.c:557
float array2sh_getProgressBar0_1(void *const hA2sh)
(Optional) Returns current intialisation/processing progress, between 0..1
Definition array2sh.c:533
void array2sh_refreshSettings(void *const hA2sh)
Sets all intialisation flags to 1; re-initialising all settings/variables as array2sh is currently co...
Definition array2sh.c:277
void array2sh_setEncodingOrder(void *const hA2sh, int newOrder)
Sets the encoding order (see SH_ORDERS enum)
Definition array2sh.c:284
void array2sh_setFilterType(void *const hA2sh, int newType)
Sets the type filter design to employ for computing the encoding matrices (see ARRAY2SH_FILTER_TYPES ...
Definition array2sh.c:460
int array2sh_getSamplingRate(void *const hA2sh)
Returns the DAW/Host sample rate.
Definition array2sh.c:719
void array2sh_setSensorElev_deg(void *const hA2sh, int index, float newElev_deg)
Sets a particular sensor's elevation (degrees) w.r.t to the origin of the array.
Definition array2sh.c:378
float array2sh_getRegPar(void *const hA2sh)
Returns the value of the regurlisation parameter; the maximum permitted gain provided by the filters,...
Definition array2sh.c:650
float * array2sh_getLevelDifference_Handle(void *const hA2sh, int *nCurves, int *nFreqPoints)
Returns a pointer to the level-difference [1] data.
Definition array2sh.c:711
int array2sh_getArrayType(void *const hA2sh)
Returns the type of array.
Definition array2sh.c:630
void array2sh_setPreset(void *const hA2sh, ARRAY2SH_MICROPHONE_ARRAY_PRESETS preset)
Sets a pre-defined microphone/hydrophone array preset (See ARRAY2SH_MICROPHONE_ARRAY_PRESETS enum)
Definition array2sh.c:327
int array2sh_getNormType(void *const hA2sh)
Returns the Ambisonic normalisation convention currently being usedto decode with,...
Definition array2sh.c:662
int array2sh_getDiffEQpastAliasing(void *const hA2sh)
Flag to enabled/disable diffuse equalisation above the spatial aliasing limit of the array (0: disabl...
Definition array2sh.c:551
float ** array2sh_getbN_modal(void *const hA2sh, int *nCurves, int *nFreqPoints)
Returns the direct inversion of the modal coefficients per frequency (may be used for optional plotti...
Definition array2sh.c:695
ARRAY2SH_WEIGHT_TYPES
List of supported sensor directivities and array construction types.
Definition array2sh.h:166
@ WEIGHT_RIGID_OMNI
Rigid baffle construction with omni sensors.
Definition array2sh.h:167
@ WEIGHT_OPEN_OMNI
Open array construction with omni sensors.
Definition array2sh.h:171
@ WEIGHT_OPEN_DIPOLE
Open array construction with dipole sensors.
Definition array2sh.h:173
@ WEIGHT_RIGID_CARD
Rigid baffle construction with cardioid sensors.
Definition array2sh.h:168
@ WEIGHT_RIGID_DIPOLE
Rigid baffle construction with dipole sensors.
Definition array2sh.h:170
@ WEIGHT_OPEN_CARD
Open array construction with cardioid sensors.
Definition array2sh.h:172
int array2sh_getMinNumSensors(void *const hA2sh)
Returns the minimum number of sensors which can be in the array [(current_order+1)^2].
Definition array2sh.c:604
float array2sh_getc(void *const hA2sh)
Returns the speed of sound of the medium (~343m/s air, ~1480m/s water), in m/s.
Definition array2sh.c:668
void array2sh_init(void *const hA2sh, int samplerate)
Initialises an instance of array2sh with default settings.
Definition array2sh.c:149
void array2sh_getProgressBarText(void *const hA2sh, char *text)
(Optional) Returns current intialisation/processing progress text
Definition array2sh.c:539
void array2sh_setc(void *const hA2sh, float newc)
Sets the speed of sound of the medium (~343m/s air, ~1480m/s water), in m/s.
Definition array2sh.c:496
void array2sh_evalEncoder(void *const hA2sh)
Evaluates the encoder, based on current global/user parameters.
Definition array2sh.c:162
void array2sh_setr(void *const hA2sh, float newr)
Sets the radius of the array.
Definition array2sh.c:410
void array2sh_setSensorAzi_rad(void *const hA2sh, int index, float newAzi_rad)
Sets a particular sensor's azimuth (radians) w.r.t to the origin of the array.
Definition array2sh.c:338
void array2sh_setSensorAzi_deg(void *const hA2sh, int index, float newAzi_deg)
Sets a particular sensor's azimuth (degrees) w.r.t to the origin of the array.
Definition array2sh.c:364
int array2sh_getNSHrequired(void *const hA2sh)
Returns the number of spherical harmonic signals required by the current encoding order: (current_ord...
Definition array2sh.c:610
void array2sh_setWeightType(void *const hA2sh, int newType)
Sets the type of weights to use (see ARRAY2SH_WEIGHT_TYPES enum)
Definition array2sh.c:448
void array2sh_setDiffEQpastAliasing(void *const hA2sh, int newState)
Analyses what the theoretical spatial aliasing frequency is, and conducts diffuse-field equalisation ...
Definition array2sh.c:317
float array2sh_getGain(void *const hA2sh)
Returns the amount of post gain to apply after the encoding, in DECIBELS.
Definition array2sh.c:674
void array2sh_setChOrder(void *const hA2sh, int newOrder)
Sets the Ambisonic channel ordering convention to encode with, in order to match the convention emplo...
Definition array2sh.c:482
void array2sh_process(void *const hA2sh, const float *const *inputs, float *const *outputs, int nInputs, int nOutputs, int nSamples)
Spatially encode microphone/hydrophone array signals into spherical harmonic signals.
Definition array2sh.c:186
float array2sh_getSensorAzi_rad(void *const hA2sh, int index)
Returns a particular sensor's azimuth w.r.t to the origin of the array, in RADIANS.
Definition array2sh.c:563
int array2sh_getFrameSize(void)
Returns the processing framesize (i.e., number of samples processed with every _process() call )
Definition array2sh.c:516
float array2sh_getSensorElev_rad(void *const hA2sh, int index)
Returns a particular sensor's elevation w.r.t to the origin of the array, in RADIANS.
Definition array2sh.c:570
ARRAY2SH_ARRAY_TYPES
List of supported array types.
Definition array2sh.h:156
@ ARRAY_CYLINDRICAL
Cylindrial arrangement of sensors (open/rigid)
Definition array2sh.h:158
@ ARRAY_SPHERICAL
Spherical arrangement of sensors (open/rigid)
Definition array2sh.h:157
int array2sh_getChOrder(void *const hA2sh)
Returns the Ambisonic channel ordering convention currently being used to decode with,...
Definition array2sh.c:656
int array2sh_getFilterType(void *const hA2sh)
Returns the type filter design to employ for computing the encoding matrices (see ARRAY2SH_FILTER_TYP...
Definition array2sh.c:644
int array2sh_getWeightType(void *const hA2sh)
Returns the type of weights to use see ARRAY2SH_WEIGHT_TYPES enum.
Definition array2sh.c:637
int array2sh_getReinitSHTmatrixFLAG(void *const hA2sh)
Returns 0 if SHT is not be reinitialised, 1: if it is.
Definition array2sh.c:527
int array2sh_getProcessingDelay(void)
Returns the processing delay in samples (may be used for delay compensation features)
Definition array2sh.c:725
int array2sh_getNumSensors(void *const hA2sh)
Returns the number of sensors in the array.
Definition array2sh.c:591
void array2sh_setRequestEncoderEvalFLAG(void *const hA2sh, int newState)
Evaluates the performance of the current encoding filters when applied to a theoretical model of the ...
Definition array2sh.c:300
ARRAY2SH_EVAL_STATUS array2sh_getEvalStatus(void *const hA2sh)
Returns current eval status (see ARRAY2SH_EVAL_STATUS enum)
Definition array2sh.c:521
ARRAY2SH_EVAL_STATUS
Current status of the encoder evaluation output data.
Definition array2sh.h:186
@ EVAL_STATUS_RECENTLY_EVALUATED
Encoder has recently been evaluated.
Definition array2sh.h:188
@ EVAL_STATUS_EVALUATING
Encoder is being evaluated.
Definition array2sh.h:190
@ EVAL_STATUS_EVALUATED
Encoder has been evaluated.
Definition array2sh.h:187
@ EVAL_STATUS_NOT_EVALUATED
Encoder has not been evaluated.
Definition array2sh.h:189