30const float default_abs_wall[6] = { 0.341055000f, 0.431295000f, 0.351295000f, 0.344335000f, 0.401775000f, 0.482095000f};
40 *phAmbi = (
void*)pData;
58 float src_pos[3] = {5.2f, 1.5f, 1.4f};
59 memcpy(pData->
src_pos[0], src_pos, 3*
sizeof(
float));
60 float src2_pos[3] = {2.1f, 1.0f, 1.3f};
61 memcpy(pData->
src_pos[1], src2_pos, 3*
sizeof(
float));
62 float src3_pos[3] = {3.1f, 5.0f, 2.3f};
63 memcpy(pData->
src_pos[2], src3_pos, 3*
sizeof(
float));
64 float src4_pos[3] = {7.1f, 2.0f, 1.4f};
65 memcpy(pData->
src_pos[3], src4_pos, 3*
sizeof(
float));
66 float rec_pos[3] = {5.2f, 3.5f, 1.4f};
67 memcpy(pData->
rec_pos[0], rec_pos, 3*
sizeof(
float));
68 memcpy(pData->
rec_pos[1], rec_pos, 3*
sizeof(
float));
103 pData->
fs = (float)sampleRate;
109 const float *
const * inputs,
110 float*
const*
const outputs,
117 int i, j, rec, ch, nSources, nReceivers, nSH, order;
172 for(i=0; i <
SAF_MIN(nSources,nInputs); i++)
174 for(; i < nInputs; i++)
179 for(i=0; i<nSources; i++)
181 for(i=0; i<nReceivers; i++)
188 for(i=0; i<nReceivers; i++)
192 for(rec=0, i=0; rec<nReceivers; rec++){
210 for(; i < nOutputs; i++)
214 for (ch=0; ch < nOutputs; ch++)
215 memset(outputs[ch],0, nSamples*
sizeof(
float));
264 pData->
src_pos[index][0] = newValue;
271 pData->
src_pos[index][1] = newValue;
278 pData->
src_pos[index][2] = newValue;
291 pData->
rec_pos[index][0] = newValue;
298 pData->
rec_pos[index][1] = newValue;
305 pData->
rec_pos[index][2] = newValue;
335 saf_assert(xyz_idx<4,
"xyz_idx indicates each spatial axis, so cannot exceed 4");
336 saf_assert(posNeg_idx==0 || posNeg_idx==1,
"posNeg_idx is a bool");
337 if(new_value!=pData->
abs_wall[2*xyz_idx+posNeg_idx]){
338 pData->
abs_wall[2*xyz_idx+posNeg_idx] = new_value;
403 return pData->
src_pos[index][0];
410 return pData->
src_pos[index][1];
417 return pData->
src_pos[index][2];
435 return pData->
rec_pos[index][0];
442 return pData->
rec_pos[index][1];
449 return pData->
rec_pos[index][2];
473 return pData->
abs_wall[2*xyz_idx+posNeg_idx];
485 return (
int)pData->
norm;
#define MAX_SH_ORDER
Maximum supported Ambisonic order.
#define MAX_NUM_CHANNELS
Maximum number of input/output channels supported.
NORM_TYPES
Available Ambisonic normalisation conventions.
@ NORM_SN3D
Schmidt semi-normalisation (SN3D)
@ NORM_FUMA
(Legacy) Furse-Malham scaling
@ NORM_N3D
orthonormalised (N3D)
CH_ORDER
Available Ambisonic channel ordering conventions.
@ CH_ACN
Ambisonic Channel Numbering (ACN)
@ CH_FUMA
(Legacy) Furse-Malham/B-format (WXYZ)
#define MAX_NUM_SH_SIGNALS
Maximum number of spherical harmonic components/signals supported.
@ SH_ORDER_FIRST
First-order (4 channels)
void ambi_roomsim_setRoomDimY(void *const hAmbi, float newValue)
Sets the room length along the y dimension.
void ambi_roomsim_setOutputOrder(void *const hAmbi, int newOrder)
Sets the encoding order (see SH_ORDERS enum)
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_getNSHrequired(void *const hAmbi)
Returns the number of spherical harmonic signals required by the current decoding order: (current_ord...
void ambi_roomsim_process(void *const hAmbi, const float *const *inputs, float *const *const outputs, int nInputs, int nOutputs, int nSamples)
Processes audio.
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.
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.
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.
void ambi_roomsim_init(void *const hAmbi, int sampleRate)
Initialises an instance of ambi_roomsim with default settings.
float ambi_roomsim_getReceiverX(void *const hAmbi, int index)
Returns the 'x' coordinate for a specific receiver index.
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_setRoomDimX(void *const hAmbi, float newValue)
Sets the room length along the x dimension.
int ambi_roomsim_getMaxNumReceivers()
Returns the maximum number of receivers.
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.
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...
float ambi_roomsim_getRoomDimX(void *const hAmbi)
Returns the room length along the x dimension.
void ambi_roomsim_setNumReceivers(void *const hAmbi, int new_nReceivers)
Sets the number of input SH receivers.
void ambi_roomsim_setReceiverY(void *const hAmbi, int index, float newValue)
Sets the 'y' coordinate for a specific receiver index.
int ambi_roomsim_getMaxNumSources()
Returns the maximum number of input signals/sources that can be encoded.
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.
int ambi_roomsim_getProcessingDelay()
Returns the processing delay in samples (may be used for delay compensation features)
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.
int ambi_roomsim_getNormType(void *const hAmbi)
Returns the Ambisonic normalisation convention currently being used to encode with (see NORM_TYPES en...
const float default_abs_wall[6]
Default absorption coefficients per wall.
void ambi_roomsim_setMaxReflectionOrder(void *const hAmbi, int newValue)
Sets the maximum reflection order.
const float default_room_dims[3]
Default room dimensions.
float ambi_roomsim_getReceiverY(void *const hAmbi, int index)
Returns the 'y' coordinate for a specific receiver index.
A simple shoebox room Ambisonic encoder.
#define ROOM_SIM_MAX_NUM_RECEIVERS
Maximum supported number of receivers for the room sim example.
#define ROOM_SIM_MAX_NUM_SOURCES
Maximum supported number of sources for the room sim example.
A simple shoebox room Ambisonic encoder.
#define AMBI_ROOMSIM_FRAME_SIZE
Framesize, in time-domain samples.
void convertHOAChannelConvention(float *insig, int order, int signalLength, HOA_CH_ORDER inConvention, HOA_CH_ORDER outConvention)
Converts an Ambisonic signal from one channel ordering convention to another.
void convertHOANormConvention(float *insig, int order, int signalLength, HOA_NORM inConvention, HOA_NORM outConvention)
Converts an Ambisonic signal from one normalisation convention to another.
@ HOA_CH_ORDER_FUMA
Furse-Malham (FuMa) convention, often used by older recordings.
@ HOA_CH_ORDER_ACN
Ambisonic Channel numbering (ACN) convention, which is employed by all spherical harmonic related fun...
@ HOA_NORM_FUMA
Furse-Malham (FuMa) convention.
@ HOA_NORM_SN3D
Schmidt semi-normalisation (SN3D) convention, as used by the AmbiX standard.
@ HOA_NORM_N3D
Orthonormalised (N3D) convention, which is the default convention used by SAF.
void ims_shoebox_setRoomDimensions(void *hIms, float new_roomDimensions[3])
Sets new room dimensions.
void ims_shoebox_removeSource(void *hIms, int sourceID)
Removes a specific source from the simulation.
int ims_shoebox_addReceiverSH(void *hIms, int sh_order, float rec_xyz[3], float ***pSH_sigs)
Adds a spherical harmonic (SH) receiver object to the simulator of a given order, and returns a uniqu...
int ims_shoebox_addSource(void *hIms, float src_xyz[3], float **pSrc_sig)
Adds a source object to the simulator, and returns a unique ID corresponding to it.
void ims_shoebox_applyEchogramTD(void *hIms, long receiverID, int nSamples, int fractionalDelaysFLAG)
Applies the currently computed echograms in the time-domain, for all sources, for one specified recei...
void ims_shoebox_updateSource(void *hIms, int sourceID, float new_position_xyz[3])
Updates the position of a specific source in the simulation.
void ims_shoebox_computeEchograms(void *hIms, int maxN, float maxTime_ms)
Computes echograms for all active source/receiver combinations.
void ims_shoebox_updateReceiver(void *hIms, int receiverID, float new_position_xyz[3])
Updates the position of a specific receiver in the simulation.
void ims_shoebox_destroy(void **phIms)
Destroys an instance of ims_shoebox room simulator.
void ims_shoebox_removeReceiver(void *hIms, int receiverID)
Removes a specific receiver from the simulation.
void ims_shoebox_create(void **phIms, float roomDimensions[3], float *abs_wall, float lowestOctaveBand, int nOctBands, float c_ms, float fs)
Creates an instance of ims_shoebox room simulator.
#define IMS_MAX_NUM_RECEIVERS
Maximum number of receivers supported by an instance of the IMS simulator.
void ims_shoebox_setWallAbsCoeffs(void *hIms, float *abs_wall)
Sets new wall absorption coefficients per wall and per band.
#define ORDER2NSH(order)
Converts spherical harmonic order to number of spherical harmonic components i.e: (order+1)^2.
#define saf_assert(x, message)
Macro to make an assertion, along with a string explaining its purpose.
#define SAF_CLAMP(a, min, max)
Ensures value "a" is clamped between the "min" and "max" values.
#define SAF_MIN(a, b)
Returns the minimum of the two values.
void ** malloc2d(size_t dim1, size_t dim2, size_t data_size)
2-D malloc (contiguously allocated, so use free() as usual to deallocate)
void * malloc1d(size_t dim1_data_size)
1-D malloc (same as malloc, but with error checking)
void *** malloc3d(size_t dim1, size_t dim2, size_t dim3, size_t data_size)
3-D malloc (contiguously allocated, so use free() as usual to deallocate)
#define FLATTEN2D(A)
Use this macro when passing a 2-D dynamic multi-dimensional array to memset, memcpy or any other func...
Main structure for ambi_roomsim.
int enableReflections
0: disabled, 1: enabled
int new_nSources
New number of sources (current value will be replaced by this after next re-init)
int new_sh_order
New receiver SH order (current value will be replaced by this after next re-init)
CH_ORDER chOrdering
Ambisonic channel order convention (see CH_ORDER)
void * hIms
Image source implementation handle.
int nSources
Current number of sources.
float rec_pos[ROOM_SIM_MAX_NUM_RECEIVERS][3]
Current receiver Cartesian coordinates, meters.
float abs_wall[6]
Absorption coefficients per wall, in the order in which the axis intersect walls: +x -x +y -y +z -z.
int receiverIDs[ROOM_SIM_MAX_NUM_RECEIVERS]
Unique IDs per receiver in the simulation.
float fs
Host sampling rate, in Hz.
int nReceivers
Current number of receivers.
int sourceIDs[ROOM_SIM_MAX_NUM_SOURCES]
Unique IDs per source in the simulation.
int sh_order
Current SH order of receivers.
int reinit_room
Flag, 1: re-init required, 0: not required.
float src_pos[ROOM_SIM_MAX_NUM_SOURCES][3]
Current source Cartesian coordinates, meters.
float room_dims[3]
Room dimensions along the x,y,z axes in meters.
int new_nReceivers
New number of receivers (current value will be replaced by this after next re-init)
float ** src_sigs
Source signal buffers; ROOM_SIM_MAX_NUM_SOURCES x AMBI_ROOMSIM_FRAME_SIZE.
NORM_TYPES norm
Ambisonic normalisation convention (see NORM_TYPES)
float *** rec_sh_outsigs
Receiver signal buffers; ROOM_SIM_MAX_NUM_RECEIVERS x MAX_NUM_SH_SIGNALS x AMBI_ROOMSIM_FRAME_SIZE.
int refl_order
Current maximum image source reflection order.