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
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 */
60 float inputFrameTD[MAX_NUM_INPUTS][AMBI_ENC_FRAME_SIZE];
61 float prev_inputFrameTD[MAX_NUM_INPUTS][AMBI_ENC_FRAME_SIZE];
62 float tempFrame_fadeOut[MAX_NUM_SH_SIGNALS][AMBI_ENC_FRAME_SIZE];
64 float outputFrameTD_fadeIn[MAX_NUM_SH_SIGNALS][AMBI_ENC_FRAME_SIZE];
67 /* Internal variables */
68 float fs;
69 int recalc_SH_FLAG[MAX_NUM_INPUTS];
72 float interpolator_fadeIn[AMBI_ENC_FRAME_SIZE];
73 float interpolator_fadeOut[AMBI_ENC_FRAME_SIZE];
76 /* user parameters */
78 float src_dirs_deg[MAX_NUM_INPUTS][2];
83 float src_gains[MAX_NUM_INPUTS];
86
87
88/* ========================================================================== */
89/* Internal Functions */
90/* ========================================================================== */
91
107 float dirs_deg[MAX_NUM_INPUTS][2],
108 int* nCH);
109
110
111#ifdef __cplusplus
112} /* extern "C" { */
113#endif /* __cplusplus */
114
115#endif /* __AMBI_ENC_INTERNAL_H_INCLUDED__ */
#define MAX_NUM_INPUTS
Maximum number of input channels supported.
Definition _common.h:233
SOURCE_CONFIG_PRESETS
Available source configurations presets to use for encoding/panning.
Definition _common.h:133
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
SH_ORDERS
Available spherical harmonic (SH) input/output order options.
Definition _common.h:38
A basic Ambisonic encoder.
void loadSourceConfigPreset(SOURCE_CONFIG_PRESETS preset, float dirs_deg[MAX_NUM_INPUTS][2], int *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.
int enablePostScaling
Flag 1: output signals scaled by 1/sqrt(nSources), 0: disabled.
int new_nSources
New number of input signals (current value will be replaced by this after next re-init)
CH_ORDER chOrdering
Ambisonic channel order convention (see CH_ORDER)
int nSources
Current number of input signals.
NORM_TYPES norm
Ambisonic normalisation convention (see NORM_TYPES)
float fs
Host sampling rate.
SH_ORDERS order
Current SH encoding order.