SAF
Loading...
Searching...
No Matches
ambi_enc_internal.c
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#include "ambi_enc.h"
27#include "ambi_enc_internal.h"
28
30(
32 float dirs_deg[MAX_NUM_INPUTS][2],
33 int* newNCH
34)
35{
36 int ch, i, nCH;
37
38 nCH = ch = 0;
39 switch(preset){
40 default:
41 /* fall through */
42 case SOURCE_CONFIG_PRESET_DEFAULT:
43 /* fall through */
44 case SOURCE_CONFIG_PRESET_MONO:
45 nCH = 1;
46 for(ch=0; ch<nCH; ch++)
47 for(i=0; i<2; i++)
48 dirs_deg[ch][i] = __mono_dirs_deg[ch][i];
49 break;
50 case SOURCE_CONFIG_PRESET_STEREO:
51 nCH = 2;
52 for(ch=0; ch<nCH; ch++)
53 for(i=0; i<2; i++)
54 dirs_deg[ch][i] = __stereo_dirs_deg[ch][i];
55 break;
56 case SOURCE_CONFIG_PRESET_5PX:
57 nCH = 5;
58 for(ch=0; ch<nCH; ch++)
59 for(i=0; i<2; i++)
60 dirs_deg[ch][i] = __5pX_dirs_deg[ch][i];
61 break;
62 case SOURCE_CONFIG_PRESET_7PX:
63 nCH = 7;
64 for(ch=0; ch<nCH; ch++)
65 for(i=0; i<2; i++)
66 dirs_deg[ch][i] = __7pX_dirs_deg[ch][i];
67 break;
68 case SOURCE_CONFIG_PRESET_8PX:
69 nCH = 8;
70 for(ch=0; ch<nCH; ch++)
71 for(i=0; i<2; i++)
72 dirs_deg[ch][i] = __8pX_dirs_deg[ch][i];
73 break;
74 case SOURCE_CONFIG_PRESET_9PX:
75 nCH = 9;
76 for(ch=0; ch<nCH; ch++)
77 for(i=0; i<2; i++)
78 dirs_deg[ch][i] = __9pX_dirs_deg[ch][i];
79 break;
80 case SOURCE_CONFIG_PRESET_10PX:
81 nCH = 10;
82 for(ch=0; ch<nCH; ch++)
83 for(i=0; i<2; i++)
84 dirs_deg[ch][i] = __10pX_dirs_deg[ch][i];
85 break;
86 case SOURCE_CONFIG_PRESET_11PX:
87 nCH = 11;
88 for(ch=0; ch<nCH; ch++)
89 for(i=0; i<2; i++)
90 dirs_deg[ch][i] = __11pX_dirs_deg[ch][i];
91 break;
92 case SOURCE_CONFIG_PRESET_11PX_7_4:
93 nCH = 11;
94 for(ch=0; ch<nCH; ch++)
95 for(i=0; i<2; i++)
96 dirs_deg[ch][i] = __11pX_7_4_dirs_deg[ch][i];
97 break;
98 case SOURCE_CONFIG_PRESET_13PX:
99 nCH = 13;
100 for(ch=0; ch<nCH; ch++)
101 for(i=0; i<2; i++)
102 dirs_deg[ch][i] = __13pX_dirs_deg[ch][i];
103 break;
104 case SOURCE_CONFIG_PRESET_22PX:
105 nCH = 22;
106 for(ch=0; ch<nCH; ch++)
107 for(i=0; i<2; i++)
108 dirs_deg[ch][i] = __22pX_dirs_deg[ch][i];
109 break;
110 case SOURCE_CONFIG_PRESET_22P2_9_10_3:
111 saf_print_error("Not suitable, since it contains LFE channels");
112 break;
113 case SOURCE_CONFIG_PRESET_AALTO_MCC:
114 nCH = 45;
115 for(ch=0; ch<nCH; ch++)
116 for(i=0; i<2; i++)
117 dirs_deg[ch][i] = __Aalto_MCC_dirs_deg[ch][i];
118 break;
119 case SOURCE_CONFIG_PRESET_AALTO_MCC_SUBSET:
120 nCH = 37;
121 for(ch=0; ch<nCH; ch++)
122 for(i=0; i<2; i++)
123 dirs_deg[ch][i] = __Aalto_MCCsubset_dirs_deg[ch][i];
124 break;
125 case SOURCE_CONFIG_PRESET_AALTO_APAJA:
126 nCH = 29;
127 for(ch=0; ch<nCH; ch++)
128 for(i=0; i<2; i++)
129 dirs_deg[ch][i] = __Aalto_Apaja_dirs_deg[ch][i];
130 break;
131 case SOURCE_CONFIG_PRESET_AALTO_LR:
132 nCH = 13;
133 for(ch=0; ch<nCH; ch++)
134 for(i=0; i<2; i++)
135 dirs_deg[ch][i] = __Aalto_LR_dirs_deg[ch][i];
136 break;
137 case SOURCE_CONFIG_PRESET_DTU_AVIL:
138 nCH = 64;
139 for(ch=0; ch<nCH; ch++)
140 for(i=0; i<2; i++)
141 dirs_deg[ch][i] = __DTU_AVIL_dirs_deg[ch][i];
142 break;
143 case SOURCE_CONFIG_PRESET_ZYLIA_LAB:
144 nCH = 22;
145 for(ch=0; ch<nCH; ch++)
146 for(i=0; i<2; i++)
147 dirs_deg[ch][i] = __Zylia_Lab_dirs_deg[ch][i];
148 break;
149 case SOURCE_CONFIG_PRESET_T_DESIGN_4:
150 nCH = 4;
151 for(ch=0; ch<nCH; ch++)
152 for(i=0; i<2; i++)
153 dirs_deg[ch][i] = __Tdesign_degree_2_dirs_deg[ch][i];
154 break;
155 case SOURCE_CONFIG_PRESET_T_DESIGN_12:
156 nCH = 12;
157 for(ch=0; ch<nCH; ch++)
158 for(i=0; i<2; i++)
159 dirs_deg[ch][i] = __Tdesign_degree_4_dirs_deg[ch][i];
160 break;
161 case SOURCE_CONFIG_PRESET_T_DESIGN_24:
162 nCH = 24;
163 for(ch=0; ch<nCH; ch++)
164 for(i=0; i<2; i++)
165 dirs_deg[ch][i] = __Tdesign_degree_6_dirs_deg[ch][i];
166 break;
167 case SOURCE_CONFIG_PRESET_T_DESIGN_36:
168 nCH = 36;
169 for(ch=0; ch<nCH; ch++)
170 for(i=0; i<2; i++)
171 dirs_deg[ch][i] = __Tdesign_degree_8_dirs_deg[ch][i];
172 break;
173 case SOURCE_CONFIG_PRESET_T_DESIGN_48:
174 nCH = 48;
175 for(ch=0; ch<nCH; ch++)
176 for(i=0; i<2; i++)
177 dirs_deg[ch][i] = __Tdesign_degree_9_dirs_deg[ch][i];
178 break;
179 case SOURCE_CONFIG_PRESET_T_DESIGN_60:
180 nCH = 60;
181 for(ch=0; ch<nCH; ch++)
182 for(i=0; i<2; i++)
183 dirs_deg[ch][i] = __Tdesign_degree_10_dirs_deg[ch][i];
184 break;
185 case SOURCE_CONFIG_PRESET_SPH_COV_9:
186 nCH = 9;
187 for(ch=0; ch<nCH; ch++)
188 for(i=0; i<2; i++)
189 dirs_deg[ch][i] = __SphCovering_9_dirs_deg[ch][i];
190 break;
191 case SOURCE_CONFIG_PRESET_SPH_COV_16:
192 nCH = 16;
193 for(ch=0; ch<nCH; ch++)
194 for(i=0; i<2; i++)
195 dirs_deg[ch][i] = __SphCovering_16_dirs_deg[ch][i];
196 break;
197 case SOURCE_CONFIG_PRESET_SPH_COV_25:
198 nCH = 25;
199 for(ch=0; ch<nCH; ch++)
200 for(i=0; i<2; i++)
201 dirs_deg[ch][i] = __SphCovering_25_dirs_deg[ch][i];
202 break;
203 case SOURCE_CONFIG_PRESET_SPH_COV_49:
204 nCH = 49;
205 for(ch=0; ch<nCH; ch++)
206 for(i=0; i<2; i++)
207 dirs_deg[ch][i] = __SphCovering_49_dirs_deg[ch][i];
208 break;
209 case SOURCE_CONFIG_PRESET_SPH_COV_64:
210 nCH = 64;
211 for(ch=0; ch<nCH; ch++)
212 for(i=0; i<2; i++)
213 dirs_deg[ch][i] = __SphCovering_64_dirs_deg[ch][i];
214 break;
215 }
216 saf_assert(nCH>0, "Number of channels must be more than 0");
217
218 /* Fill remaining slots with default coords */
219 for(; ch<MAX_NUM_INPUTS; ch++)
220 for(i=0; i<2; i++)
221 dirs_deg[ch][i] = __default_LScoords128_deg[ch][i];
222
223 /* specify new number of channels (for dynamically changing the number of TFT channels) */
224 (*newNCH) = nCH;
225}
#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
A basic Ambisonic encoder.
void loadSourceConfigPreset(SOURCE_CONFIG_PRESETS preset, float dirs_deg[MAX_NUM_INPUTS][2], int *newNCH)
Returns the source directions for a specified source config preset.
A basic Ambisonic encoder.
#define saf_print_error(message)
Macro to print a error message along with the filename and line number.
const float __Zylia_Lab_dirs_deg[22][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for the 22.x setup, at Zylia Labs.
#define saf_assert(x, message)
Macro to make an assertion, along with a string explaining its purpose.
const float __9pX_dirs_deg[9][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a 9.x setup.
const float __SphCovering_16_dirs_deg[16][2]
Directions [azimuth, Elevation] in degrees, for sphere covering: 16 dirs.
const float __Aalto_MCC_dirs_deg[45][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for the multi-channel anechoic chamber (MCC),...
const float __SphCovering_49_dirs_deg[49][2]
Directions [azimuth, Elevation] in degrees, for sphere covering: 49 dirs.
const float __mono_dirs_deg[1][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a mono setup.
const float __5pX_dirs_deg[5][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a 5.x setup.
const float __11pX_dirs_deg[11][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a 11.x setup.
const float __Tdesign_degree_9_dirs_deg[48][2]
Directions [azimuth, Elevation] in degrees, for minimum Tdesign degree: 9.
const float __Tdesign_degree_2_dirs_deg[4][2]
Directions [azimuth, Elevation] in degrees, for minimum Tdesign degree: 2.
const float __11pX_7_4_dirs_deg[11][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a 7.4.x setup.
const float __Tdesign_degree_8_dirs_deg[36][2]
Directions [azimuth, Elevation] in degrees, for minimum Tdesign degree: 8.
const float __default_LScoords128_deg[128][2]
Default Loudspeaker directions [azimuth, Elevation] - to replace above!
const float __Aalto_MCCsubset_dirs_deg[37][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for the multi-channel anechoic chamber (MCC) ...
const float __Aalto_Apaja_dirs_deg[29][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for the audio-visual listening room (Apaja),...
const float __SphCovering_9_dirs_deg[9][2]
Directions [azimuth, Elevation] in degrees, for sphere covering: 9 dirs.
const float __stereo_dirs_deg[2][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a stereo setup.
const float __SphCovering_64_dirs_deg[64][2]
Directions [azimuth, Elevation] in degrees, for sphere covering: 64 dirs.
const float __Tdesign_degree_4_dirs_deg[12][2]
Directions [azimuth, Elevation] in degrees, for minimum Tdesign degree: 4.
const float __Aalto_LR_dirs_deg[13][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for the ITU standard listening room (LR),...
const float __DTU_AVIL_dirs_deg[64][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for the Audio Visual Immersion Lab (AVIL),...
const float __8pX_dirs_deg[8][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a 8.x setup.
const float __Tdesign_degree_6_dirs_deg[24][2]
Directions [azimuth, Elevation] in degrees, for minimum Tdesign degree: 6.
const float __13pX_dirs_deg[13][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a 13.x setup.
const float __7pX_dirs_deg[7][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a 7.x setup.
const float __22pX_dirs_deg[22][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a 22.x setup.
const float __SphCovering_25_dirs_deg[25][2]
Directions [azimuth, Elevation] in degrees, for sphere covering: 25 dirs.
const float __Tdesign_degree_10_dirs_deg[60][2]
Directions [azimuth, Elevation] in degrees, for minimum Tdesign degree: 10.
const float __10pX_dirs_deg[10][2]
Loudspeaker directions [azimuth, Elevation] in degrees, for a 10.x setup.