SAF
Loading...
Searching...
No Matches
ambi_roomsim.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 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
35
36#ifndef __AMBI_ROOMSIM_H_INCLUDED__
37#define __AMBI_ROOMSIM_H_INCLUDED__
38
39#include "_common.h"
40
41#ifdef __cplusplus
42extern "C" {
43#endif /* __cplusplus */
44
45/* ========================================================================== */
46/* Presets + Constants */
47/* ========================================================================== */
48
50#define ROOM_SIM_MAX_NUM_RECEIVERS ( 16 )
52#define ROOM_SIM_MAX_NUM_SOURCES ( 16 )
53
55extern const float ambi_roomsim_default_abs_wall[6];
56
58extern const float ambi_roomsim_default_room_dims[3];
59
61extern const int ambi_roomsim_defaultNumSources;
62
65
68
71
72
73/* ========================================================================== */
74/* Main Functions */
75/* ========================================================================== */
76
82void ambi_roomsim_create(void** const phAmbi);
83
89void ambi_roomsim_destroy(void** const phAmbi);
90
97void ambi_roomsim_init(void* const hAmbi,
98 int samplerate);
99
110void ambi_roomsim_process(void* const hAmbi,
111 const float *const * inputs,
112 float* const* outputs,
113 int nInputs,
114 int nOutputs,
115 int nSamples);
116
117
118/* ========================================================================== */
119/* Set Functions */
120/* ========================================================================== */
121
126void ambi_roomsim_refreshParams(void* const hAmbi);
127
129void ambi_roomsim_setEnableIMSflag(void* const hAmbi, int newValue);
130
132void ambi_roomsim_setMaxReflectionOrder(void* const hAmbi, int newValue);
133
135void ambi_roomsim_setOutputOrder(void* const hAmbi, int newValue);
136
138void ambi_roomsim_setNumSources(void* const hAmbi, int new_nSources);
139
147void ambi_roomsim_setSourceX(void* const hAmbi, int index, float newValue);
148
156void ambi_roomsim_setSourceY(void* const hAmbi, int index, float newValue);
157
165void ambi_roomsim_setSourceZ(void* const hAmbi, int index, float newValue);
166
168void ambi_roomsim_setNumReceivers(void* const hAmbi, int new_nReceievers);
169
177void ambi_roomsim_setReceiverX(void* const hAmbi, int index, float newValue);
178
186void ambi_roomsim_setReceiverY(void* const hAmbi, int index, float newValue);
187
195void ambi_roomsim_setReceiverZ(void* const hAmbi, int index, float newValue);
196
198void ambi_roomsim_setRoomDimX(void* const hAmbi, float newValue);
199
201void ambi_roomsim_setRoomDimY(void* const hAmbi, float newValue);
202
204void ambi_roomsim_setRoomDimZ(void* const hAmbi, float newValue);
205
207void ambi_roomsim_setWallAbsCoeff(void* const hAmbi, int xyz_idx, int posNeg_idx, float new_value);
208
213void ambi_roomsim_setChOrder(void* const hAmbi, int newOrder);
214
219void ambi_roomsim_setNormType(void* const hAmbi, int newType);
220
221
222/* ========================================================================== */
223/* Get Functions */
224/* ========================================================================== */
225
231
233int ambi_roomsim_getEnableIMSflag(void* const hAmbi);
234
236int ambi_roomsim_getMaxReflectionOrder(void* const hAmbi);
237
245int ambi_roomsim_getOutputOrder(void* const hAmbi);
246
248int ambi_roomsim_getNumSources(void* const hAmbi);
249
252
257int ambi_roomsim_getNSHrequired(void* const hAmbi);
258
260float ambi_roomsim_getSourceX(void* const hAmbi, int index);
261
263float ambi_roomsim_getSourceY(void* const hAmbi, int index);
264
266float ambi_roomsim_getSourceZ(void* const hAmbi, int index);
267
269int ambi_roomsim_getNumReceivers(void* const hAmbi);
270
273
275float ambi_roomsim_getReceiverX(void* const hAmbi, int index);
276
278float ambi_roomsim_getReceiverY(void* const hAmbi, int index);
279
281float ambi_roomsim_getReceiverZ(void* const hAmbi, int index);
282
284float ambi_roomsim_getRoomDimX(void* const hAmbi);
285
287float ambi_roomsim_getRoomDimY(void* const hAmbi);
288
290float ambi_roomsim_getRoomDimZ(void* const hAmbi);
291
293float ambi_roomsim_getWallAbsCoeff(void* const hAmbi,
294 int xyz_idx,
295 int posNeg_idx);
296
301int ambi_roomsim_getChOrder(void* const hAmbi);
302
307int ambi_roomsim_getNormType(void* const hAmbi);
308
314
315
316#ifdef __cplusplus
317} /* extern "C" { */
318#endif /* __cplusplus */
319
320#endif /* __AMBI_ROOMSIM_H_INCLUDED__ */
A bunch of things that are common to many of the saf examples.
void ambi_roomsim_setRoomDimY(void *const hAmbi, float newValue)
Sets the room length along the y dimension.
float ambi_roomsim_getSourceZ(void *const hAmbi, int index)
Returns the 'z' coordinate for a specific source index.
void ambi_roomsim_setReceiverZ(void *const hAmbi, int index, float newValue)
Sets the 'z' coordinate for a specific receiver index.
int ambi_roomsim_getEnableIMSflag(void *const hAmbi)
Returns whether to include image sources (1) or not (0)
int ambi_roomsim_getMaxNumReceivers(void)
Returns the maximum number of receivers.
int ambi_roomsim_getNSHrequired(void *const hAmbi)
Returns the number of spherical harmonic signals required by the current decoding order: (current_ord...
void ambi_roomsim_setNumSources(void *const hAmbi, int new_nSources)
Sets the number of input signals/sources to encode.
float ambi_roomsim_getWallAbsCoeff(void *const hAmbi, int xyz_idx, int posNeg_idx)
Returns wall absorption coefficients.
float ambi_roomsim_getReceiverZ(void *const hAmbi, int index)
Returns the 'z' coordinate for a specific receiver index.
void ambi_roomsim_setOutputOrder(void *const hAmbi, int newValue)
Sets the encoding order (see SH_ORDERS enum)
float ambi_roomsim_getRoomDimZ(void *const hAmbi)
Returns the room length along the z dimension.
void ambi_roomsim_setReceiverX(void *const hAmbi, int index, float newValue)
Sets the 'x' coordinate for a specific receiver index.
float ambi_roomsim_getRoomDimY(void *const hAmbi)
Returns the room length along the y dimension.
void ambi_roomsim_setRoomDimZ(void *const hAmbi, float newValue)
Sets the room length along the z dimension.
const float ambi_roomsim_default_room_dims[3]
Default room dimensions.
void ambi_roomsim_create(void **const phAmbi)
Creates an instance of ambi_roomsim.
int ambi_roomsim_getNumReceivers(void *const hAmbi)
Returns the number of SH receivers.
float ambi_roomsim_getSourceY(void *const hAmbi, int index)
Returns the 'y' coordinate for a specific source index.
void ambi_roomsim_setNormType(void *const hAmbi, int newType)
Sets the Ambisonic normalisation convention to encode with (see NORM_TYPES enum)
void ambi_roomsim_destroy(void **const phAmbi)
Destroys an instance of ambi_roomsim.
void ambi_roomsim_setSourceX(void *const hAmbi, int index, float newValue)
Sets the 'x' coordinate for a specific source index.
float ambi_roomsim_getReceiverX(void *const hAmbi, int index)
Returns the 'x' coordinate for a specific receiver index.
const float ambi_roomsim_defaultReceiverPositions[ROOM_SIM_MAX_NUM_RECEIVERS][3]
Default receiver positions.
int ambi_roomsim_getNumSources(void *const hAmbi)
Returns the number of input signals/sources to encode.
void ambi_roomsim_setEnableIMSflag(void *const hAmbi, int newValue)
Sets whether to include image sources (1) or not (0)
void ambi_roomsim_setChOrder(void *const hAmbi, int newOrder)
Sets the Ambisonic channel ordering convention to encode with (see CH_ORDER enum)
void ambi_roomsim_process(void *const hAmbi, const float *const *inputs, float *const *outputs, int nInputs, int nOutputs, int nSamples)
Processes audio.
void ambi_roomsim_setRoomDimX(void *const hAmbi, float newValue)
Sets the room length along the x dimension.
void ambi_roomsim_setNumReceivers(void *const hAmbi, int new_nReceievers)
Sets the number of input SH receivers.
#define ROOM_SIM_MAX_NUM_RECEIVERS
Maximum supported number of receivers for the room sim example.
void ambi_roomsim_refreshParams(void *const hAmbi)
Sets all intialisation flags to 1; re-initialising all settings/variables as ambi_roomsim is currentl...
void ambi_roomsim_setSourceZ(void *const hAmbi, int index, float newValue)
Sets the 'z' coordinate for a specific source index.
const int ambi_roomsim_defaultNumReceivers
Default number of receivers in the simulation.
const int ambi_roomsim_defaultNumSources
Default number of sources in the simulation.
int ambi_roomsim_getProcessingDelay(void)
Returns the processing delay in samples (may be used for delay compensation features)
int ambi_roomsim_getOutputOrder(void *const hAmbi)
Returns the decoding order (see SH_ORDERS enum)
float ambi_roomsim_getSourceX(void *const hAmbi, int index)
Returns the 'x' coordinate for a specific source index.
int ambi_roomsim_getChOrder(void *const hAmbi)
Returns the Ambisonic channel ordering convention currently being used to encode with (see CH_ORDER e...
const float ambi_roomsim_defaultSourcePositions[ROOM_SIM_MAX_NUM_SOURCES][3]
Default source positions.
float ambi_roomsim_getRoomDimX(void *const hAmbi)
Returns the room length along the x dimension.
void ambi_roomsim_init(void *const hAmbi, int samplerate)
Initialises an instance of ambi_roomsim with default settings.
void ambi_roomsim_setReceiverY(void *const hAmbi, int index, float newValue)
Sets the 'y' coordinate for a specific receiver index.
int ambi_roomsim_getMaxReflectionOrder(void *const hAmbi)
Returns the maximum reflection order.
void ambi_roomsim_setWallAbsCoeff(void *const hAmbi, int xyz_idx, int posNeg_idx, float new_value)
Sets wall absorption coefficients.
const float ambi_roomsim_default_abs_wall[6]
Default wall absorption coefficients.
int ambi_roomsim_getFrameSize(void)
Returns the processing framesize (i.e., number of samples processed with every _process() call )
void ambi_roomsim_setSourceY(void *const hAmbi, int index, float newValue)
Sets the 'y' coordinate for a specific source index.
#define ROOM_SIM_MAX_NUM_SOURCES
Maximum supported number of sources for the room sim example.
int ambi_roomsim_getMaxNumSources(void)
Returns the maximum number of input signals/sources that can be encoded.
int ambi_roomsim_getNormType(void *const hAmbi)
Returns the Ambisonic normalisation convention currently being used to encode with (see NORM_TYPES en...
void ambi_roomsim_setMaxReflectionOrder(void *const hAmbi, int newValue)
Sets the maximum reflection order.
float ambi_roomsim_getReceiverY(void *const hAmbi, int index)
Returns the 'y' coordinate for a specific receiver index.