-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathambi_roomsim.h
297 lines (239 loc) · 10.1 KB
/
ambi_roomsim.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
/*
* Copyright 2020 Leo McCormack
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/**
* @example ambi_roomsim.h
* @brief A simple shoebox room Ambisonic encoder.
*
* ### Files
* ambi_roomsim.h (include), ambi_roomsim_internal.h, ambi_roomsim.c,
* ambi_roomsim_internal.c
* ### Include Header
*/
/**
* @file ambi_roomsim.h
* @brief A simple shoebox room Ambisonic encoder.
*
* @author Leo McCormack
* @date 10.08.2020
* @license ISC
*/
#ifndef __AMBI_ROOMSIM_H_INCLUDED__
#define __AMBI_ROOMSIM_H_INCLUDED__
#include "_common.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** Maximum supported number of receivers for the room sim example */
#define ROOM_SIM_MAX_NUM_RECEIVERS ( 16 )
/** Maximum supported number of sources for the room sim example */
#define ROOM_SIM_MAX_NUM_SOURCES ( 16 )
/* ========================================================================== */
/* Main Functions */
/* ========================================================================== */
/**
* Creates an instance of ambi_roomsim
*
* @param[in] phAmbi (&) address of ambi_roomsim handle
*/
void ambi_roomsim_create(void** const phAmbi);
/**
* Destroys an instance of ambi_roomsim
*
* @param[in] phAmbi (&) address of ambi_roomsim handle
*/
void ambi_roomsim_destroy(void** const phAmbi);
/**
* Initialises an instance of ambi_roomsim with default settings
*
* @param[in] hAmbi ambi_roomsim handle
* @param[in] samplerate Host samplerate.
*/
void ambi_roomsim_init(void* const hAmbi,
int samplerate);
/**
* Processes audio
*
* @param[in] hAmbi ambi_roomsim handle
* @param[in] inputs Input channel buffers; 2-D array: nInputs x nSamples
* @param[in] outputs Output channel buffers; 2-D array: nOutputs x nSamples
* @param[in] nInputs Number of input channels
* @param[in] nOutputs Number of output channels
* @param[in] nSamples Number of samples in 'inputs'/'output' matrices
*/
void ambi_roomsim_process(void* const hAmbi,
const float *const * inputs,
float* const* outputs,
int nInputs,
int nOutputs,
int nSamples);
/* ========================================================================== */
/* Set Functions */
/* ========================================================================== */
/**
* Sets all intialisation flags to 1; re-initialising all settings/variables
* as ambi_roomsim is currently configured, at next available opportunity.
*/
void ambi_roomsim_refreshParams(void* const hAmbi);
/** Sets whether to include image sources (1) or not (0) */
void ambi_roomsim_setEnableIMSflag(void* const hAmbi, int newValue);
/** Sets the maximum reflection order */
void ambi_roomsim_setMaxReflectionOrder(void* const hAmbi, int newValue);
/** Sets the encoding order (see #SH_ORDERS enum) */
void ambi_roomsim_setOutputOrder(void* const hAmbi, int newValue);
/** Sets the number of input signals/sources to encode */
void ambi_roomsim_setNumSources(void* const hAmbi, int new_nSources);
/**
* Sets the 'x' coordinate for a specific source index
*
* @param[in] hAmbi ambi_roomsim handle
* @param[in] index Source index
* @param[in] newValue New 'x' coordinate, in metres
*/
void ambi_roomsim_setSourceX(void* const hAmbi, int index, float newValue);
/**
* Sets the 'y' coordinate for a specific source index
*
* @param[in] hAmbi ambi_roomsim handle
* @param[in] index Source index
* @param[in] newValue New 'y' coordinate, in metres
*/
void ambi_roomsim_setSourceY(void* const hAmbi, int index, float newValue);
/**
* Sets the 'z' coordinate for a specific source index
*
* @param[in] hAmbi ambi_roomsim handle
* @param[in] index Source index
* @param[in] newValue New 'z' coordinate, in metres
*/
void ambi_roomsim_setSourceZ(void* const hAmbi, int index, float newValue);
/** Sets the number of input SH receivers */
void ambi_roomsim_setNumReceivers(void* const hAmbi, int new_nReceievers);
/**
* Sets the 'x' coordinate for a specific receiver index
*
* @param[in] hAmbi ambi_roomsim handle
* @param[in] index Receiver index
* @param[in] newValue New 'x' coordinate, in metres
*/
void ambi_roomsim_setReceiverX(void* const hAmbi, int index, float newValue);
/**
* Sets the 'y' coordinate for a specific receiver index
*
* @param[in] hAmbi ambi_roomsim handle
* @param[in] index Receiver index
* @param[in] newValue New 'y' coordinate, in metres
*/
void ambi_roomsim_setReceiverY(void* const hAmbi, int index, float newValue);
/**
* Sets the 'z' coordinate for a specific receiver index
*
* @param[in] hAmbi ambi_roomsim handle
* @param[in] index Receiver index
* @param[in] newValue New 'z' coordinate, in metres
*/
void ambi_roomsim_setReceiverZ(void* const hAmbi, int index, float newValue);
/** Sets the room length along the x dimension */
void ambi_roomsim_setRoomDimX(void* const hAmbi, float newValue);
/** Sets the room length along the y dimension */
void ambi_roomsim_setRoomDimY(void* const hAmbi, float newValue);
/** Sets the room length along the z dimension */
void ambi_roomsim_setRoomDimZ(void* const hAmbi, float newValue);
/** Sets wall absorption coefficients */
void ambi_roomsim_setWallAbsCoeff(void* const hAmbi, int xyz_idx, int posNeg_idx, float new_value);
/**
* Sets the Ambisonic channel ordering convention to encode with (see #CH_ORDER
* enum)
*/
void ambi_roomsim_setChOrder(void* const hAmbi, int newOrder);
/**
* Sets the Ambisonic normalisation convention to encode with (see #NORM_TYPES
* enum)
*/
void ambi_roomsim_setNormType(void* const hAmbi, int newType);
/* ========================================================================== */
/* Get Functions */
/* ========================================================================== */
/**
* Returns the processing framesize (i.e., number of samples processed with
* every _process() call )
*/
int ambi_roomsim_getFrameSize(void);
/** Returns whether to include image sources (1) or not (0) */
int ambi_roomsim_getEnableIMSflag(void* const hAmbi);
/** Returns the maximum reflection order */
int ambi_roomsim_getMaxReflectionOrder(void* const hAmbi);
/**
* Returns the decoding order (see #SH_ORDERS enum)
*
* If decoding order is higher than the input signal order, the extra required
* channels are filled with zeros. If the decoding order is lower than the input
* signal order, the number input signals is truncated accordingly.
*/
int ambi_roomsim_getOutputOrder(void* const hAmbi);
/** Returns the number of input signals/sources to encode. */
int ambi_roomsim_getNumSources(void* const hAmbi);
/** Returns the maximum number of input signals/sources that can be encoded. */
int ambi_roomsim_getMaxNumSources(void);
/**
* Returns the number of spherical harmonic signals required by the current
* decoding order: (current_order+1)^2
*/
int ambi_roomsim_getNSHrequired(void* const hAmbi);
/** Returns the 'x' coordinate for a specific source index */
float ambi_roomsim_getSourceX(void* const hAmbi, int index);
/** Returns the 'y' coordinate for a specific source index */
float ambi_roomsim_getSourceY(void* const hAmbi, int index);
/** Returns the 'z' coordinate for a specific source index */
float ambi_roomsim_getSourceZ(void* const hAmbi, int index);
/** Returns the number of SH receivers */
int ambi_roomsim_getNumReceivers(void* const hAmbi);
/** Returns the maximum number of receivers */
int ambi_roomsim_getMaxNumReceivers(void);
/** Returns the 'x' coordinate for a specific receiver index */
float ambi_roomsim_getReceiverX(void* const hAmbi, int index);
/** Returns the 'y' coordinate for a specific receiver index */
float ambi_roomsim_getReceiverY(void* const hAmbi, int index);
/** Returns the 'z' coordinate for a specific receiver index */
float ambi_roomsim_getReceiverZ(void* const hAmbi, int index);
/** Returns the room length along the x dimension */
float ambi_roomsim_getRoomDimX(void* const hAmbi);
/** Returns the room length along the y dimension */
float ambi_roomsim_getRoomDimY(void* const hAmbi);
/** Returns the room length along the z dimension */
float ambi_roomsim_getRoomDimZ(void* const hAmbi);
/** Returns wall absorption coefficients */
float ambi_roomsim_getWallAbsCoeff(void* const hAmbi,
int xyz_idx,
int posNeg_idx);
/**
* Returns the Ambisonic channel ordering convention currently being used to
* encode with (see #CH_ORDER enum)
*/
int ambi_roomsim_getChOrder(void* const hAmbi);
/**
* Returns the Ambisonic normalisation convention currently being used to encode
* with (see #NORM_TYPES enum)
*/
int ambi_roomsim_getNormType(void* const hAmbi);
/**
* Returns the processing delay in samples (may be used for delay compensation
* features)
*/
int ambi_roomsim_getProcessingDelay(void);
#ifdef __cplusplus
} /* extern "C" { */
#endif /* __cplusplus */
#endif /* __AMBI_ROOMSIM_H_INCLUDED__ */