SAF
Loading...
Searching...
No Matches
powermap_internal.h
Go to the documentation of this file.
1/*
2 * Copyright 2016-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
32#ifndef __POWERMAP_INTERNAL_H_INCLUDED__
33#define __POWERMAP_INTERNAL_H_INCLUDED__
34
35#include "powermap.h" /* Include header for this example */
36#include "saf.h" /* Main include header for SAF */
37#include "saf_externals.h" /* To also include SAF dependencies (cblas etc.) */
38
39#ifdef __cplusplus
40extern "C" {
41#endif /* __cplusplus */
42
43/* ========================================================================== */
44/* Internal Parameters */
45/* ========================================================================== */
46
47#if !defined(POWERMAP_FRAME_SIZE)
48# if defined(FRAME_SIZE) /* Use the global framesize if it is specified: */
49# define POWERMAP_FRAME_SIZE ( FRAME_SIZE )
50# else /* Otherwise, the default framesize for this example is: */
51# define POWERMAP_FRAME_SIZE ( 1024 )
52# endif
53#endif
54#define HOP_SIZE ( 128 )
55#define HYBRID_BANDS ( HOP_SIZE + 5 )
56#define TIME_SLOTS ( POWERMAP_FRAME_SIZE / HOP_SIZE )
57#define NUM_DISP_SLOTS ( 2 )
58#define MAX_COV_AVG_COEFF ( 0.45f )
60/* Checks: */
61#if (POWERMAP_FRAME_SIZE % HOP_SIZE != 0)
62# error "POWERMAP_FRAME_SIZE must be an integer multiple of HOP_SIZE"
63#endif
64
65/* ========================================================================== */
66/* Structures */
67/* ========================================================================== */
68
70typedef struct _powermap_codecPars
71{
75 float* interp_table;
78 float* Y_grid[MAX_SH_ORDER];
79 float_complex* Y_grid_cmplx[MAX_SH_ORDER];
82
87typedef struct _powermap
88{
89 /* FIFO buffers */
93 /* TFT */
94 float** SHframeTD;
95 float_complex*** SHframeTF;
96 void* hSTFT;
97 float freqVector[HYBRID_BANDS];
98 float fs;
100 /* internal */
105 /* ana configuration */
112 /* display */
113 float* pmap;
114 float* prev_pmap;
115 float* pmap_grid[NUM_DISP_SLOTS];
122 /* User parameters */
124 int analysisOrderPerBand[HYBRID_BANDS];
125 float pmapEQ[HYBRID_BANDS];
136
137
138/* ========================================================================== */
139/* Internal Functions */
140/* ========================================================================== */
141
143void powermap_setCodecStatus(void* const hPm, CODEC_STATUS newStatus);
144
146void powermap_initAna(void* const hPm);
147
153void powermap_initTFT(void* const hPm);
154
155
156#ifdef __cplusplus
157} /* extern "C" */
158#endif /* __cplusplus */
159
160#endif /* __POWERMAP_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
HFOV_OPTIONS
Available horizontal field-of-view (FOV) options.
Definition _common.h:179
NORM_TYPES
Available Ambisonic normalisation conventions.
Definition _common.h:74
CH_ORDER
Available Ambisonic channel ordering conventions.
Definition _common.h:59
#define MAX_NUM_SH_SIGNALS
Maximum number of spherical harmonic components/signals supported.
Definition _common.h:239
CODEC_STATUS
Current status of the codec.
Definition _common.h:201
ASPECT_RATIO_OPTIONS
Available aspect ratios.
Definition _common.h:188
#define HYBRID_BANDS
Number of frequency bands.
#define NUM_DISP_SLOTS
Number of display slots.
A sound-field visualiser, which utilises spherical harmonic signals as input; note this code is a rem...
POWERMAP_MODES
Available power-map/activity-map options.
Definition powermap.h:58
void powermap_setCodecStatus(void *const hPm, CODEC_STATUS newStatus)
Sets codec status (see CODEC_STATUS enum)
void powermap_initTFT(void *const hPm)
Initialise the filterbank used by powermap.
#define POWERMAP_FRAME_SIZE
Framesize, in time-domain samples.
void powermap_initAna(void *const hPm)
Intialises the codec variables, based on current global/user parameters.
Main include header for the Spatial_Audio_Framework (SAF)
Include header for SAF externals.
Contains variables for scanning grids, and beamforming.
float * interp_dirs_deg
2D rectangular window interpolation directions, in degrees; FLAT: interp_nDirs x 2
float * interp_table
Spherical->2D interpolation table; FLAT: interp_nDirs x grid_nDirs.
int grid_nDirs
Number of scanning directions.
float * grid_dirs_deg
Spherical scanning grid directions, in degrees; FLAT: grid_nDirs x 2.
int interp_nTri
Number of triangles in the spherical triangulared grid.
int interp_nDirs
Number of interpolation directions.
Main structure for powermap.
float pmapAvgCoeff
Powermap averaging coefficient, [0..1].
powermap_codecPars * pars
codec parameters
float fs
Host sample rate, in Hz.
CH_ORDER chOrdering
Ambisonic channel order convention (see CH_ORDER)
int dispWidth
Number of pixels on the horizontal in the 2D interpolated powermap image.
float_complex *** SHframeTF
time-frequency domain SH input frame; HYBRID_BANDS x MAX_NUM_SH_SIGNALS x TIME_SLOTS
POWERMAP_MODES pmap_mode
see POWERMAP_MODES
PROC_STATUS procStatus
see PROC_STATUS
int pmapReady
0: powermap not started yet, 1: powermap is ready for plotting
float progressBar0_1
Current (re)initialisation progress, between [0..1].
float covAvgCoeff
Covariance matrix averaging coefficient, [0..1].
float * prev_pmap
grid_nDirs x 1
int new_masterOrder
New maximum/master SH analysis order (current value will be replaced by this after next re-init)
float pmap_grid_minVal
Current minimum value in pmap (used to normalise [0..1])
int recalcPmap
set this to 1 to generate a new powermap
HFOV_OPTIONS HFOVoption
see HFOV_OPTIONS
CODEC_STATUS codecStatus
see CODEC_STATUS
int FIFO_idx
FIFO buffer index.
int masterOrder
Current maximum/master SH analysis order.
float * pmap
grid_nDirs x 1
float ** SHframeTD
time-domain SH input frame; MAX_NUM_SH_SIGNALS x POWERMAP_FRAME_SIZE
ASPECT_RATIO_OPTIONS aspectRatioOption
see ASPECT_RATIO_OPTIONS
int dispSlotIdx
Current display slot.
NORM_TYPES norm
Ambisonic normalisation convention (see NORM_TYPES)
float pmap_grid_maxVal
Current maximum value in pmap (used to normalise [0..1])
int nSources
Current number of sources (used for MUSIC)
char * progressBarText
Current (re)initialisation step, string.
void * hSTFT
afSTFT handle