SAF
Loading...
Searching...
No Matches
sldoa_internal.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
46#ifndef __SLDOA_INTERNAL_H_INCLUDED__
47#define __SLDOA_INTERNAL_H_INCLUDED__
48
49#include "sldoa.h" /* Include header for this example */
50#include "saf.h" /* Main include header for SAF */
51#include "saf_externals.h" /* To also include SAF dependencies (cblas etc.) */
52
53#ifdef __cplusplus
54extern "C" {
55#endif /* __cplusplus */
56
57/* ========================================================================== */
58/* Internal Parameters */
59/* ========================================================================== */
60
61#if !defined(SLDOA_FRAME_SIZE)
62# if defined(FRAME_SIZE) /* Use the global framesize if it is specified: */
63# define SLDOA_FRAME_SIZE ( FRAME_SIZE )
64# else /* Otherwise, the default framesize for this example is: */
65# define SLDOA_FRAME_SIZE ( 512 )
66# endif
67#endif
68#define ORDER2NUMSECTORS(L) ( L*L )
69#define HOP_SIZE ( 128 )
70#define HYBRID_BANDS ( HOP_SIZE + 5 )
71#define TIME_SLOTS ( SLDOA_FRAME_SIZE / HOP_SIZE )
72#define MAX_NUM_SECTORS ( 64 )
73#define NUM_DISP_SLOTS ( 2 )
75/* Checks: */
76#if (SLDOA_FRAME_SIZE % HOP_SIZE != 0)
77# error "SLDOA_FRAME_SIZE must be an integer multiple of HOP_SIZE"
78#endif
79
80/* ========================================================================== */
81/* Structures */
82/* ========================================================================== */
83
85typedef struct _sldoa
86{
87 /* FIFO buffers */
89 float** inFIFO;
91 /* TFT */
92 float** SHframeTD;
93 float_complex*** SHframeTF;
94 void* hSTFT;
95 float freqVector[HYBRID_BANDS];
96 float fs;
98 /* ana configuration */
104 /* internal */
105 int nGrid;
106 float** grid_Y;
109 float_complex* secCoeffs[MAX_SH_ORDER-1];
110 float doa_rad[HYBRID_BANDS][MAX_NUM_SECTORS][2];
112 int nSectorsPerBand[HYBRID_BANDS];
115 /* display */
116 float* azi_deg[NUM_DISP_SLOTS];
117 float* elev_deg[NUM_DISP_SLOTS];
118 float* colourScale[NUM_DISP_SLOTS];
119 float* alphaScale[NUM_DISP_SLOTS];
122 /* User parameters */
124 int analysisOrderPerBand[HYBRID_BANDS];
125 float maxFreq;
126 float minFreq;
127 float avg_ms;
131} sldoa_data;
132
133
134/* ========================================================================== */
135/* Internal Functions */
136/* ========================================================================== */
137
139void sldoa_setCodecStatus(void* const hSld, CODEC_STATUS newStatus);
140
157void sldoa_initAna(void* const hSld);
158
167void sldoa_initTFT(void* const hSld);
168
193void sldoa_estimateDoA(float_complex** SHframeTF,
194 int anaOrder,
195 float_complex* secCoeffs,
196 float doa[MAX_NUM_SECTORS][TIME_SLOTS][2],
197 float energy[MAX_NUM_SECTORS][TIME_SLOTS]);
198
199
200#ifdef __cplusplus
201} /* extern "C" */
202#endif /* __cplusplus */
203
204#endif /* __SLDOA_INTERNAL_H_INCLUDED__ */
#define MAX_SH_ORDER
Maximum supported Ambisonic order.
Definition _common.h:52
PROC_STATUS
Current status of the processing loop.
Definition _common.h:219
NORM_TYPES
Available Ambisonic normalisation conventions.
Definition _common.h:74
CH_ORDER
Available Ambisonic channel ordering conventions.
Definition _common.h:59
CODEC_STATUS
Current status of the codec.
Definition _common.h:201
#define HYBRID_BANDS
Number of frequency bands.
#define NUM_DISP_SLOTS
Number of display slots.
Main include header for the Spatial_Audio_Framework (SAF)
Include header for SAF externals.
A spatially-localised active-intensity (SLAI) based direction-of- arrival estimator (SLDoA)
#define TIME_SLOTS
Processing relies on fdHop = 16.
void sldoa_setCodecStatus(void *const hSld, CODEC_STATUS newStatus)
Sets codec status (see CODEC_STATUS enum)
#define MAX_NUM_SECTORS
maximum number of sectors, TODO: expand beyond 64 (which is the max possible in the spherecovering gr...
void sldoa_initAna(void *const hSld)
Intialises the codec variables, based on current global/user parameters.
void sldoa_initTFT(void *const hSld)
Initialise the filterbank used by sldoa.
void sldoa_estimateDoA(float_complex **SHframeTF, int anaOrder, float_complex *secCoeffs, float doa[MAX_NUM_SECTORS][TIME_SLOTS][2], float energy[MAX_NUM_SECTORS][TIME_SLOTS])
Estimates the DoA using the active intensity vectors derived from spatially localised sectors,...
Main struct for sldoa.
int FIFO_idx
FIFO buffer index.
float maxFreq
Maximum display frequency, in Hz.
int new_masterOrder
New master/maximum analysis order (current value will be replaced by this after next re-init)
float fs
Host sampling rate, in Hz.
float progressBar0_1
Current (re)initialisation progress, between [0..1].
PROC_STATUS procStatus
see PROC_STATUS
float ** inFIFO
FIFO buffer.
void * hSTFT
afSTFT handle
CODEC_STATUS codecStatus
see CODEC_STATUS
float minFreq
Minimum display frequency, in Hz.
float ** grid_Y_dipoles_norm
SH basis.
char * progressBarText
Current (re)initialisation step, string.
NORM_TYPES norm
Ambisonic normalisation convention (see NORM_TYPES)
float_complex *** SHframeTF
time-frequency domain SH input frame; HYBRID_BANDS x MAX_NUM_SH_SIGNALS x TIME_SLOTS
float ** grid_dirs_deg
Grid directions, in degrees.
float ** SHframeTD
time-domain SH input frame; MAX_NUM_SH_SIGNALS x SLDOA_FRAME_SIZE
float avg_ms
Temporal averaging, in ms.
CH_ORDER chOrdering
Ambisonic channel order convention (see CH_ORDER)
float ** grid_Y
SH basis.
int masterOrder
Current master/maximum analysis order.
int nGrid
Number of grid directions.
int current_disp_idx
Current display slot.