SAF
Loading...
Searching...
No Matches
ambi_enc_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
25
26#ifndef __AMBI_ENC_INTERNAL_H_INCLUDED__
27#define __AMBI_ENC_INTERNAL_H_INCLUDED__
28
29#include "ambi_enc.h" /* Include header for this example */
30#include "saf.h" /* Main include header for SAF */
31#include "saf_externals.h" /* To also include SAF dependencies (cblas etc.) */
32
33#ifdef __cplusplus
34extern "C" {
35#endif /* __cplusplus */
36
37/* ========================================================================== */
38/* Internal Parameters */
39/* ========================================================================== */
40
41#if !defined(AMBI_ENC_FRAME_SIZE)
42# if defined(FRAME_SIZE) /* Use the global framesize if it is specified: */
43# define AMBI_ENC_FRAME_SIZE ( FRAME_SIZE )
44# else /* Otherwise, the default framesize for this example is: */
45# define AMBI_ENC_FRAME_SIZE ( 64 )
46# endif
47#endif
48
49/* ========================================================================== */
50/* Structures */
51/* ========================================================================== */
52
57typedef struct _ambi_enc
58{
59 /* Internal audio buffers */
65
66 /* Internal variables */
67 float fs;
73 _Atomic_INT32 new_nSources;
74
75 /* user parameters */
76 _Atomic_INT32 nSources;
77 _Atomic_FLOAT32 src_dirs_deg[MAX_NUM_INPUTS][2];
78 _Atomic_CH_ORDER chOrdering;
79 _Atomic_NORM_TYPES norm;
80 _Atomic_SH_ORDERS order;
81 _Atomic_INT32 enablePostScaling;
82 _Atomic_FLOAT32 src_gains[MAX_NUM_INPUTS];
83
85
86
87/* ========================================================================== */
88/* Internal Functions */
89/* ========================================================================== */
90
106 _Atomic_FLOAT32 dirs_deg[MAX_NUM_INPUTS][2],
107 _Atomic_INT32* nCH);
108
109
110#ifdef __cplusplus
111} /* extern "C" { */
112#endif /* __cplusplus */
113
114#endif /* __AMBI_ENC_INTERNAL_H_INCLUDED__ */
#define MAX_NUM_INPUTS
Maximum number of input channels supported.
Definition _common.h:237
SOURCE_CONFIG_PRESETS
Available source configurations presets to use for encoding/panning.
Definition _common.h:137
#define MAX_NUM_SH_SIGNALS
Maximum number of spherical harmonic components/signals supported.
Definition _common.h:243
A basic Ambisonic encoder.
void loadSourceConfigPreset(SOURCE_CONFIG_PRESETS preset, _Atomic_FLOAT32 dirs_deg[MAX_NUM_INPUTS][2], _Atomic_INT32 *nCH)
Returns the source directions for a specified source config preset.
#define AMBI_ENC_FRAME_SIZE
Framesize, in time-domain samples.
Main include header for the Spatial_Audio_Framework (SAF)
Include header for SAF externals.
Main structure for ambi_enc.
float tempFrame[MAX_NUM_SH_SIGNALS][AMBI_ENC_FRAME_SIZE]
Temporary frame.
float Y[MAX_NUM_SH_SIGNALS][MAX_NUM_INPUTS]
SH weights.
_Atomic_INT32 enablePostScaling
Flag 1: output signals scaled by 1/sqrt(nSources), 0: disabled.
_Atomic_NORM_TYPES norm
Ambisonic normalisation convention (see NORM_TYPES)
float interpolator_fadeIn[AMBI_ENC_FRAME_SIZE]
Linear Interpolator (fade-in)
_Atomic_FLOAT32 src_gains[MAX_NUM_INPUTS]
Gains applied per source.
float inputFrameTD[MAX_NUM_INPUTS][AMBI_ENC_FRAME_SIZE]
Input frame of signals.
float tempFrame_fadeOut[MAX_NUM_SH_SIGNALS][AMBI_ENC_FRAME_SIZE]
Temporary frame with linear interpolation (fade-out) applied.
_Atomic_INT32 nSources
Current number of input signals.
_Atomic_CH_ORDER chOrdering
Ambisonic channel order convention (see CH_ORDER)
_Atomic_SH_ORDERS order
Current SH encoding order.
float outputFrameTD[MAX_NUM_SH_SIGNALS][AMBI_ENC_FRAME_SIZE]
Output frame of SH signals.
_Atomic_INT32 new_nSources
New number of input signals (current value will be replaced by this after next re-init)
_Atomic_FLOAT32 src_dirs_deg[MAX_NUM_INPUTS][2]
Source directions, in degrees.
float prev_Y[MAX_NUM_SH_SIGNALS][MAX_NUM_INPUTS]
Previous SH weights.
float fs
Host sampling rate.
float outputFrameTD_fadeIn[MAX_NUM_SH_SIGNALS][AMBI_ENC_FRAME_SIZE]
Output frame of SH signals with linear interpolation (fade-in) applied.
_Atomic_INT32 recalc_SH_FLAG[MAX_NUM_INPUTS]
Flags, 1: recalc SH weights, 0: do not.
float interpolator_fadeOut[AMBI_ENC_FRAME_SIZE]
Linear Interpolator (fade-out)