SAF
Loading...
Searching...
No Matches
panner_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
44#ifndef __PANNER_INTERNAL_H_INCLUDED__
45#define __PANNER_INTERNAL_H_INCLUDED__
46
47#include "panner.h" /* Include header for this example */
48#include "saf.h" /* Main include header for SAF */
49#include "saf_externals.h" /* To also include SAF dependencies (cblas etc.) */
50
51#ifdef __cplusplus
52extern "C" {
53#endif /* __cplusplus */
54
55/* ========================================================================== */
56/* Internal Parameters */
57/* ========================================================================== */
58
59#define FORCE_3D_LAYOUT
60#if !defined(PANNER_FRAME_SIZE)
61# if defined(FRAME_SIZE) /* Use the global framesize if it is specified: */
62# define PANNER_FRAME_SIZE ( FRAME_SIZE )
63# else /* Otherwise, the default framesize for this example is: */
64# define PANNER_FRAME_SIZE ( 128 )
65# endif
66#endif
67#define HOP_SIZE ( 128 )
68#define HYBRID_BANDS ( HOP_SIZE + 5 )
69#define TIME_SLOTS ( PANNER_FRAME_SIZE / HOP_SIZE )
71/* Checks: */
72#if (PANNER_FRAME_SIZE % HOP_SIZE != 0)
73# error "PANNER_FRAME_SIZE must be an integer multiple of HOP_SIZE"
74#endif
75
76/* ========================================================================== */
77/* Structures */
78/* ========================================================================== */
79
84typedef struct _panner
85{
86 /* audio buffers */
87 float** inputFrameTD;
88 float** outputFrameTD;
89 float_complex*** inputframeTF;
90 float_complex*** outputframeTF;
91 int fs;
93 /* time-frequency transform */
94 float freqVector[HYBRID_BANDS];
95 void* hSTFT;
97 /* Internal */
98 int vbapTableRes[2];
99 float* vbap_gtable;
103 /* flags */
108 int recalc_gainsFLAG[MAX_NUM_INPUTS];
112 /* misc. */
113 float src_dirs_rot_deg[MAX_NUM_INPUTS][2];
114 float src_dirs_rot_xyz[MAX_NUM_INPUTS][3];
115 float src_dirs_xyz[MAX_NUM_INPUTS][3];
121 /* pValue */
122 float pValue[HYBRID_BANDS];
124 /* user parameters */
126 float src_dirs_deg[MAX_NUM_INPUTS][2];
127 float DTT;
130 float loudpkrs_dirs_deg[MAX_NUM_OUTPUTS][2];
131 float yaw;
132 float roll;
133 float pitch;
139
140
141/* ========================================================================== */
142/* Internal Functions */
143/* ========================================================================== */
144
146void panner_setCodecStatus(void* const hPan, CODEC_STATUS newStatus);
147
153void panner_initGainTables(void* const hPan);
154
160void panner_initTFT(void* const hPan);
161
171 float dirs_deg[MAX_NUM_INPUTS][2],
172 int* newNCH,
173 int* nDims);
174
184 float dirs_deg[MAX_NUM_INPUTS][2],
185 int* newNCH,
186 int* nDims);
187
188
189#ifdef __cplusplus
190} /* extern "C" */
191#endif /* __cplusplus */
192
193#endif /* __PANNER_INTERNAL_H_INCLUDED__ */
LOUDSPEAKER_ARRAY_PRESETS
Available loudspeaker array presets.
Definition _common.h:99
#define MAX_NUM_INPUTS
Maximum number of input channels supported.
Definition _common.h:233
#define MAX_NUM_OUTPUTS
Maximum number of output channels supported.
Definition _common.h:236
SOURCE_CONFIG_PRESETS
Available source configurations presets to use for encoding/panning.
Definition _common.h:133
PROC_STATUS
Current status of the processing loop.
Definition _common.h:219
CODEC_STATUS
Current status of the codec.
Definition _common.h:201
#define HYBRID_BANDS
Number of frequency bands.
A frequency-dependent 3D panner based on the Vector-base Amplitude Panning (VBAP) method [1],...
void panner_initGainTables(void *const hPan)
Intialises the VBAP gain table used for panning.
void panner_setCodecStatus(void *const hPan, CODEC_STATUS newStatus)
Sets codec status (see CODEC_STATUS enum)
void panner_loadLoudspeakerPreset(LOUDSPEAKER_ARRAY_PRESETS preset, float dirs_deg[MAX_NUM_INPUTS][2], int *newNCH, int *nDims)
Loads source/loudspeaker directions from preset.
void panner_initTFT(void *const hPan)
Initialise the filterbank used by panner.
void panner_loadSourcePreset(SOURCE_CONFIG_PRESETS preset, float dirs_deg[MAX_NUM_INPUTS][2], int *newNCH, int *nDims)
Loads source directions from preset.
Main include header for the Spatial_Audio_Framework (SAF)
Include header for SAF externals.
Main structure for panner.
float roll
roll (Euler) rotation angle, in degrees
float DTT
Room coefficient [3].
float ** inputFrameTD
Input signals, in the time-domain; MAX_NUM_INPUTS x PANNER_FRAME_SIZE.
int N_vbap_gtable
Number of directions in the VBAP gain table.
CODEC_STATUS codecStatus
see CODEC_STATUS
int nSources
Current number of inputs/sources.
float_complex *** inputframeTF
Input signals, in the time-frequency domain; HYBRID_BANDS x MAX_NUM_INPUTS x TIME_SLOTS.
int nTriangles
Number of loudspeaker triangles.
float_complex *** outputframeTF
Output signals, in the time-frequency domain; HYBRID_BANDS x MAX_NUM_OUTPUTS x TIME_SLOTS.
int recalc_M_rotFLAG
1: recalculate the rotation matrix, 0: do not
int output_nDims
Dimensionality of the loudspeaker array, 2: 2-D, 3: 3-D.
int new_nSources
New number of inputs/sources.
int nLoudpkrs
Current number of loudspeakers in the array.
float spread_deg
Source spread/MDAP [2].
float yaw
yaw (Euler) rotation angle, in degrees
char * progressBarText
Current (re)initialisation step, string.
float * vbap_gtable
Current VBAP gains; FLAT: N_hrtf_vbap_gtable x nLoudpkrs.
PROC_STATUS procStatus
see PROC_STATUS
float ** outputFrameTD
Output signals, in the time-domain; MAX_NUM_OUTPUTS x PANNER_FRAME_SIZE.
float pitch
pitch (Euler) rotation angle, in degrees
int bFlipRoll
flag to flip the sign of the roll rotation angle
int new_nLoudpkrs
New number of loudspeakers in the array.
void * hSTFT
afSTFT handle
int fs
Host sampling rate.
float progressBar0_1
Current (re)initialisation progress, between [0..1].
int reInitGainTables
1: reinitialise the VBAP gain table, 0: do not
int bFlipPitch
flag to flip the sign of the pitch rotation angle
int bFlipYaw
flag to flip the sign of the yaw rotation angle