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
57
90
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
228extern const int array2sh_defaultNumSensors;
229
232
233
234/* ========================================================================== */
235/* Main Functions */
236/* ========================================================================== */
237
243void array2sh_create(void** const phA2sh);
244
250void array2sh_destroy(void** const phA2sh);
251
258void array2sh_init(void* const hA2sh,
259 int samplerate);
260
266void array2sh_evalEncoder(void* const hA2sh);
267
279void array2sh_process(void* const hA2sh,
280 const float *const * inputs,
281 float* const* outputs,
282 int nInputs,
283 int nOutputs,
284 int nSamples);
285
286
287/* ========================================================================== */
288/* Set Functions */
289/* ========================================================================== */
290
295void array2sh_refreshSettings(void* const hA2sh);
296
298void array2sh_setEncodingOrder(void* const hA2sh, int newOrder);
299
310void array2sh_setRequestEncoderEvalFLAG(void* const hA2sh, int newState);
311
313void array2sh_setEvalStatus(void* const hA2sh, ARRAY2SH_EVAL_STATUS evalStatus);
314
321void array2sh_setDiffEQpastAliasing(void* const hA2sh, int newState);
322
327void array2sh_setPreset(void* const hA2sh,
329
338void array2sh_setSensorAzi_rad(void* const hA2sh, int index, float newAzi_rad);
339
348void array2sh_setSensorElev_rad(void* const hA2sh, int index, float newElev_rad);
349
359void array2sh_setSensorAzi_deg(void* const hA2sh, int index, float newAzi_deg);
360
369void array2sh_setSensorElev_deg(void* const hA2sh, int index, float newElev_deg);
370
372void array2sh_setNumSensors(void* const hA2sh, int newQ);
373
375void array2sh_setr(void* const hA2sh, float newr);
376
383void array2sh_setR(void* const hA2sh, float newR);
384
386void array2sh_setArrayType(void* const hA2sh, int newType);
387
389void array2sh_setWeightType(void* const hA2sh, int newType);
390
395void array2sh_setFilterType(void* const hA2sh, int newType);
396
401void array2sh_setRegPar(void* const hA2sh, float newVal);
402
407void array2sh_setChOrder(void* const hA2sh, int newOrder);
408
413void array2sh_setNormType(void* const hA2sh, int newType);
414
418void array2sh_setc(void* const hA2sh, float newc);
419
421void array2sh_setGain(void* const hA2sh, float newGain);
422
423
424/* ========================================================================== */
425/* Get Functions */
426/* ========================================================================== */
427
432int array2sh_getFrameSize(void);
433
436
440int array2sh_getReinitSHTmatrixFLAG(void* const hA2sh);
441
447float array2sh_getProgressBar0_1(void* const hA2sh);
448
455void array2sh_getProgressBarText(void* const hA2sh, char* text);
456
473int array2sh_getDiffEQpastAliasing(void* const hA2sh);
474
479int array2sh_getRequestEncoderEvalFLAG(void* const hA2sh);
480
482int array2sh_getEncodingOrder(void* const hA2sh);
483
488float array2sh_getSensorAzi_rad(void* const hA2sh, int index);
489
494float array2sh_getSensorElev_rad(void* const hA2sh, int index);
495
500float array2sh_getSensorAzi_deg(void* const hA2sh, int index);
501
506float array2sh_getSensorElev_deg(void* const hA2sh, int index);
507
509int array2sh_getNumSensors(void* const hA2sh);
510
513
518int array2sh_getMinNumSensors(void* const hA2sh);
519
524int array2sh_getNSHrequired(void* const hA2sh);
525
527float array2sh_getr(void* const hA2sh);
528
530float array2sh_getR(void* const hA2sh);
531
533int array2sh_getArrayType(void* const hA2sh);
534
536int array2sh_getWeightType(void* const hA2sh);
537
542int array2sh_getFilterType(void* const hA2sh);
543
548float array2sh_getRegPar(void* const hA2sh);
549
555int array2sh_getChOrder(void* const hA2sh);
556
562int array2sh_getNormType(void* const hA2sh);
563
568float array2sh_getc(void* const hA2sh);
569
571float array2sh_getGain(void* const hA2sh);
572
580float* array2sh_getFreqVector(void* const hA2sh, int* nFreqPoints);
581
592float** array2sh_getbN_inv(void* const hA2sh, int* nCurves, int* nFreqPoints);
593
604float** array2sh_getbN_modal(void* const hA2sh, int* nCurves, int* nFreqPoints);
605
627float* array2sh_getSpatialCorrelation_Handle(void* const hA2sh,
628 int* nCurves,
629 int* nFreqPoints);
630
652float* array2sh_getLevelDifference_Handle(void* const hA2sh, int* nCurves, int* nFreqPoints);
653
655int array2sh_getSamplingRate(void* const hA2sh);
656
662
663
664#ifdef __cplusplus
665} /* extern "C" { */
666#endif /* __cplusplus */
667
668#endif /* __ARRAY2SH_H_INCLUDED__ */
A bunch of things that are common to many of the saf examples.
#define MAX_NUM_INPUTS
Maximum number of input channels supported.
Definition _common.h:261
const int array2sh_defaultNumSensors
Default number of microphones.
float array2sh_getR(void *const hA2sh)
Returns the radius of the scatterer, in meters.
Definition array2sh.c:632
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:498
float * array2sh_getSpatialCorrelation_Handle(void *const hA2sh, int *nCurves, int *nFreqPoints)
Returns a pointer to the spatial correlation [1] data.
Definition array2sh.c:712
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:593
float array2sh_getr(void *const hA2sh)
Returns the radius of the array, in meters.
Definition array2sh.c:625
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:397
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:696
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:357
void array2sh_setR(void *const hA2sh, float newR)
Sets the radius (in meters) of the scatterer (only for Rigid arrays).
Definition array2sh.c:429
void array2sh_setEvalStatus(void *const hA2sh, ARRAY2SH_EVAL_STATUS evalStatus)
Sets current eval status (see ARRAY2SH_EVAL_STATUS enum)
Definition array2sh.c:312
void array2sh_destroy(void **const phA2sh)
Destroys an instance of array2sh.
Definition array2sh.c:106
void array2sh_setGain(void *const hA2sh, float newGain)
Sets the amount of post gain to apply after the encoding, in DECIBELS.
Definition array2sh.c:516
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:586
float * array2sh_getFreqVector(void *const hA2sh, int *nFreqPoints)
Returns a pointer to the frequency vector.
Definition array2sh.c:689
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:480
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:554
int array2sh_getMaxNumSensors(void)
Returns the maximum supported number of sensors which can be in the array.
Definition array2sh.c:608
void array2sh_setArrayType(void *const hA2sh, int newType)
Sets the type of array (see ARRAY2SH_ARRAY_TYPES enum)
Definition array2sh.c:442
int array2sh_getEncodingOrder(void *const hA2sh)
Returns the current encoding order (see SH_ORDERS enum)
Definition array2sh.c:566
float array2sh_getProgressBar0_1(void *const hA2sh)
(Optional) Returns current intialisation/processing progress, between 0..1
Definition array2sh.c:542
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:283
void array2sh_setEncodingOrder(void *const hA2sh, int newOrder)
Sets the encoding order (see SH_ORDERS enum)
Definition array2sh.c:290
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:469
int array2sh_getSamplingRate(void *const hA2sh)
Returns the DAW/Host sample rate.
Definition array2sh.c:728
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:384
float array2sh_getRegPar(void *const hA2sh)
Returns the value of the regurlisation parameter; the maximum permitted gain provided by the filters,...
Definition array2sh.c:659
float * array2sh_getLevelDifference_Handle(void *const hA2sh, int *nCurves, int *nFreqPoints)
Returns a pointer to the level-difference [1] data.
Definition array2sh.c:720
int array2sh_getArrayType(void *const hA2sh)
Returns the type of array.
Definition array2sh.c:639
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:333
int array2sh_getNormType(void *const hA2sh)
Returns the Ambisonic normalisation convention currently being usedto decode with,...
Definition array2sh.c:671
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:560
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:704
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:613
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:677
void array2sh_init(void *const hA2sh, int samplerate)
Initialises an instance of array2sh with default settings.
Definition array2sh.c:150
void array2sh_getProgressBarText(void *const hA2sh, char *text)
(Optional) Returns current intialisation/processing progress text
Definition array2sh.c:548
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:505
void array2sh_evalEncoder(void *const hA2sh)
Evaluates the encoder, based on current global/user parameters.
Definition array2sh.c:168
void array2sh_setr(void *const hA2sh, float newr)
Sets the radius of the array.
Definition array2sh.c:416
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:344
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:370
const float array2sh_defaultSensorsDirections[MAX_NUM_INPUTS][2]
Default microphone directions (degrees)
int array2sh_getNSHrequired(void *const hA2sh)
Returns the number of spherical harmonic signals required by the current encoding order: (current_ord...
Definition array2sh.c:619
void array2sh_setWeightType(void *const hA2sh, int newType)
Sets the type of weights to use (see ARRAY2SH_WEIGHT_TYPES enum)
Definition array2sh.c:457
void array2sh_setDiffEQpastAliasing(void *const hA2sh, int newState)
Analyses what the theoretical spatial aliasing frequency is, and conducts diffuse-field equalisation ...
Definition array2sh.c:323
float array2sh_getGain(void *const hA2sh)
Returns the amount of post gain to apply after the encoding, in DECIBELS.
Definition array2sh.c:683
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:491
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:192
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:572
int array2sh_getFrameSize(void)
Returns the processing framesize (i.e., number of samples processed with every _process() call )
Definition array2sh.c:525
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:579
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:665
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:653
int array2sh_getWeightType(void *const hA2sh)
Returns the type of weights to use see ARRAY2SH_WEIGHT_TYPES enum.
Definition array2sh.c:646
int array2sh_getReinitSHTmatrixFLAG(void *const hA2sh)
Returns 0 if SHT is not be reinitialised, 1: if it is.
Definition array2sh.c:536
int array2sh_getProcessingDelay(void)
Returns the processing delay in samples (may be used for delay compensation features)
Definition array2sh.c:734
int array2sh_getNumSensors(void *const hA2sh)
Returns the number of sensors in the array.
Definition array2sh.c:600
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:306
ARRAY2SH_EVAL_STATUS array2sh_getEvalStatus(void *const hA2sh)
Returns current eval status (see ARRAY2SH_EVAL_STATUS enum)
Definition array2sh.c:530
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