SAF
Loading...
Searching...
No Matches
ambi_roomsim.c File Reference

A simple shoebox room Ambisonic encoder. More...

Go to the source code of this file.

Functions

void ambi_roomsim_create (void **const phAmbi)
 Creates an instance of ambi_roomsim.
 
void ambi_roomsim_destroy (void **const phAmbi)
 Destroys an instance of ambi_roomsim.
 
void ambi_roomsim_init (void *const hAmbi, int sampleRate)
 Initialises an instance of ambi_roomsim with default settings.
 
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_refreshParams (void *const hAmbi)
 Sets all intialisation flags to 1; re-initialising all settings/variables as ambi_roomsim is currently configured, at next available opportunity.
 
void ambi_roomsim_setEnableIMSflag (void *const hAmbi, int newValue)
 Sets whether to include image sources (1) or not (0)
 
void ambi_roomsim_setMaxReflectionOrder (void *const hAmbi, int newValue)
 Sets the maximum reflection order.
 
void ambi_roomsim_setOutputOrder (void *const hAmbi, int newOrder)
 Sets the encoding order (see SH_ORDERS enum)
 
void ambi_roomsim_setNumSources (void *const hAmbi, int new_nSources)
 Sets the number of input signals/sources to encode.
 
void ambi_roomsim_setSourceX (void *const hAmbi, int index, float newValue)
 Sets the 'x' coordinate for a specific source index.
 
void ambi_roomsim_setSourceY (void *const hAmbi, int index, float newValue)
 Sets the 'y' coordinate for a specific source index.
 
void ambi_roomsim_setSourceZ (void *const hAmbi, int index, float newValue)
 Sets the 'z' coordinate for a specific source index.
 
void ambi_roomsim_setNumReceivers (void *const hAmbi, int new_nReceivers)
 Sets the number of input SH receivers.
 
void ambi_roomsim_setReceiverX (void *const hAmbi, int index, float newValue)
 Sets the 'x' coordinate for a specific receiver index.
 
void ambi_roomsim_setReceiverY (void *const hAmbi, int index, float newValue)
 Sets the 'y' coordinate for a specific receiver index.
 
void ambi_roomsim_setReceiverZ (void *const hAmbi, int index, float newValue)
 Sets the 'z' coordinate for a specific receiver index.
 
void ambi_roomsim_setRoomDimX (void *const hAmbi, float newValue)
 Sets the room length along the x dimension.
 
void ambi_roomsim_setRoomDimY (void *const hAmbi, float newValue)
 Sets 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_setWallAbsCoeff (void *const hAmbi, int xyz_idx, int posNeg_idx, float new_value)
 Sets wall absorption coefficients.
 
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_setNormType (void *const hAmbi, int newType)
 Sets the Ambisonic normalisation convention to encode with (see NORM_TYPES enum)
 
int ambi_roomsim_getFrameSize (void)
 Returns the processing framesize (i.e., number of samples processed with every _process() call )
 
int ambi_roomsim_getEnableIMSflag (void *const hAmbi)
 Returns whether to include image sources (1) or not (0)
 
int ambi_roomsim_getMaxReflectionOrder (void *const hAmbi)
 Returns the maximum reflection order.
 
int ambi_roomsim_getOutputOrder (void *const hAmbi)
 Returns the decoding order (see SH_ORDERS enum)
 
int ambi_roomsim_getNumSources (void *const hAmbi)
 Returns the number of input signals/sources to encode.
 
int ambi_roomsim_getMaxNumSources ()
 Returns the maximum number of input signals/sources that can be encoded.
 
int ambi_roomsim_getNSHrequired (void *const hAmbi)
 Returns the number of spherical harmonic signals required by the current decoding order: (current_order+1)^2.
 
float ambi_roomsim_getSourceX (void *const hAmbi, int index)
 Returns the 'x' coordinate for a specific source index.
 
float ambi_roomsim_getSourceY (void *const hAmbi, int index)
 Returns the 'y' coordinate for a specific source index.
 
float ambi_roomsim_getSourceZ (void *const hAmbi, int index)
 Returns the 'z' coordinate for a specific source index.
 
int ambi_roomsim_getNumReceivers (void *const hAmbi)
 Returns the number of SH receivers.
 
int ambi_roomsim_getMaxNumReceivers ()
 Returns the maximum number of receivers.
 
float ambi_roomsim_getReceiverX (void *const hAmbi, int index)
 Returns the 'x' coordinate for a specific receiver index.
 
float ambi_roomsim_getReceiverY (void *const hAmbi, int index)
 Returns the 'y' coordinate for a specific receiver index.
 
float ambi_roomsim_getReceiverZ (void *const hAmbi, int index)
 Returns the 'z' coordinate for a specific receiver index.
 
float ambi_roomsim_getRoomDimX (void *const hAmbi)
 Returns the room length along the x dimension.
 
float ambi_roomsim_getRoomDimY (void *const hAmbi)
 Returns the room length along the y dimension.
 
float ambi_roomsim_getRoomDimZ (void *const hAmbi)
 Returns the room length along the z dimension.
 
float ambi_roomsim_getWallAbsCoeff (void *const hAmbi, int xyz_idx, int posNeg_idx)
 Returns wall absorption coefficients.
 
int ambi_roomsim_getChOrder (void *const hAmbi)
 Returns the Ambisonic channel ordering convention currently being used to encode with (see CH_ORDER enum)
 
int ambi_roomsim_getNormType (void *const hAmbi)
 Returns the Ambisonic normalisation convention currently being used to encode with (see NORM_TYPES enum)
 
int ambi_roomsim_getProcessingDelay ()
 Returns the processing delay in samples (may be used for delay compensation features)
 

Variables

const float default_abs_wall [6] = { 0.341055000f, 0.431295000f, 0.351295000f, 0.344335000f, 0.401775000f, 0.482095000f}
 Default absorption coefficients per wall.
 
const float default_room_dims [3] = { 9.1f, 8.0f, 3.0f }
 Default room dimensions.
 

Detailed Description

A simple shoebox room Ambisonic encoder.

Author
Leo McCormack
Date
10.08.2020
License
ISC

Definition in file ambi_roomsim.c.

Function Documentation

◆ ambi_roomsim_create()

void ambi_roomsim_create ( void **const phAmbi)

Creates an instance of ambi_roomsim.

Parameters
[in]phAmbi(&) address of ambi_roomsim handle

Definition at line 34 of file ambi_roomsim.c.

◆ ambi_roomsim_destroy()

void ambi_roomsim_destroy ( void **const phAmbi)

Destroys an instance of ambi_roomsim.

Parameters
[in]phAmbi(&) address of ambi_roomsim handle

Definition at line 79 of file ambi_roomsim.c.

◆ ambi_roomsim_getChOrder()

int ambi_roomsim_getChOrder ( void *const hAmbi)

Returns the Ambisonic channel ordering convention currently being used to encode with (see CH_ORDER enum)

Definition at line 476 of file ambi_roomsim.c.

◆ ambi_roomsim_getEnableIMSflag()

int ambi_roomsim_getEnableIMSflag ( void *const hAmbi)

Returns whether to include image sources (1) or not (0)

Definition at line 364 of file ambi_roomsim.c.

◆ ambi_roomsim_getFrameSize()

int ambi_roomsim_getFrameSize ( void )

Returns the processing framesize (i.e., number of samples processed with every _process() call )

Definition at line 359 of file ambi_roomsim.c.

◆ ambi_roomsim_getMaxNumReceivers()

int ambi_roomsim_getMaxNumReceivers ( void )

Returns the maximum number of receivers.

Definition at line 426 of file ambi_roomsim.c.

◆ ambi_roomsim_getMaxNumSources()

int ambi_roomsim_getMaxNumSources ( void )

Returns the maximum number of input signals/sources that can be encoded.

Definition at line 388 of file ambi_roomsim.c.

◆ ambi_roomsim_getMaxReflectionOrder()

int ambi_roomsim_getMaxReflectionOrder ( void *const hAmbi)

Returns the maximum reflection order.

Definition at line 370 of file ambi_roomsim.c.

◆ ambi_roomsim_getNormType()

int ambi_roomsim_getNormType ( void *const hAmbi)

Returns the Ambisonic normalisation convention currently being used to encode with (see NORM_TYPES enum)

Definition at line 482 of file ambi_roomsim.c.

◆ ambi_roomsim_getNSHrequired()

int ambi_roomsim_getNSHrequired ( void *const hAmbi)

Returns the number of spherical harmonic signals required by the current decoding order: (current_order+1)^2.

Definition at line 393 of file ambi_roomsim.c.

◆ ambi_roomsim_getNumReceivers()

int ambi_roomsim_getNumReceivers ( void *const hAmbi)

Returns the number of SH receivers.

Definition at line 420 of file ambi_roomsim.c.

◆ ambi_roomsim_getNumSources()

int ambi_roomsim_getNumSources ( void *const hAmbi)

Returns the number of input signals/sources to encode.

Definition at line 382 of file ambi_roomsim.c.

◆ ambi_roomsim_getOutputOrder()

int ambi_roomsim_getOutputOrder ( 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.

Definition at line 376 of file ambi_roomsim.c.

◆ ambi_roomsim_getProcessingDelay()

int ambi_roomsim_getProcessingDelay ( void )

Returns the processing delay in samples (may be used for delay compensation features)

Definition at line 488 of file ambi_roomsim.c.

◆ ambi_roomsim_getReceiverX()

float ambi_roomsim_getReceiverX ( void *const hAmbi,
int index )

Returns the 'x' coordinate for a specific receiver index.

Definition at line 431 of file ambi_roomsim.c.

◆ ambi_roomsim_getReceiverY()

float ambi_roomsim_getReceiverY ( void *const hAmbi,
int index )

Returns the 'y' coordinate for a specific receiver index.

Definition at line 438 of file ambi_roomsim.c.

◆ ambi_roomsim_getReceiverZ()

float ambi_roomsim_getReceiverZ ( void *const hAmbi,
int index )

Returns the 'z' coordinate for a specific receiver index.

Definition at line 445 of file ambi_roomsim.c.

◆ ambi_roomsim_getRoomDimX()

float ambi_roomsim_getRoomDimX ( void *const hAmbi)

Returns the room length along the x dimension.

Definition at line 452 of file ambi_roomsim.c.

◆ ambi_roomsim_getRoomDimY()

float ambi_roomsim_getRoomDimY ( void *const hAmbi)

Returns the room length along the y dimension.

Definition at line 458 of file ambi_roomsim.c.

◆ ambi_roomsim_getRoomDimZ()

float ambi_roomsim_getRoomDimZ ( void *const hAmbi)

Returns the room length along the z dimension.

Definition at line 464 of file ambi_roomsim.c.

◆ ambi_roomsim_getSourceX()

float ambi_roomsim_getSourceX ( void *const hAmbi,
int index )

Returns the 'x' coordinate for a specific source index.

Definition at line 399 of file ambi_roomsim.c.

◆ ambi_roomsim_getSourceY()

float ambi_roomsim_getSourceY ( void *const hAmbi,
int index )

Returns the 'y' coordinate for a specific source index.

Definition at line 406 of file ambi_roomsim.c.

◆ ambi_roomsim_getSourceZ()

float ambi_roomsim_getSourceZ ( void *const hAmbi,
int index )

Returns the 'z' coordinate for a specific source index.

Definition at line 413 of file ambi_roomsim.c.

◆ ambi_roomsim_getWallAbsCoeff()

float ambi_roomsim_getWallAbsCoeff ( void *const hAmbi,
int xyz_idx,
int posNeg_idx )

Returns wall absorption coefficients.

Definition at line 470 of file ambi_roomsim.c.

◆ ambi_roomsim_init()

void ambi_roomsim_init ( void *const hAmbi,
int samplerate )

Initialises an instance of ambi_roomsim with default settings.

Parameters
[in]hAmbiambi_roomsim handle
[in]samplerateHost samplerate.

Definition at line 96 of file ambi_roomsim.c.

◆ ambi_roomsim_process()

void ambi_roomsim_process ( void *const hAmbi,
const float *const * inputs,
float *const * outputs,
int nInputs,
int nOutputs,
int nSamples )

Processes audio.

Parameters
[in]hAmbiambi_roomsim handle
[in]inputsInput channel buffers; 2-D array: nInputs x nSamples
[in]outputsOutput channel buffers; 2-D array: nOutputs x nSamples
[in]nInputsNumber of input channels
[in]nOutputsNumber of output channels
[in]nSamplesNumber of samples in 'inputs'/'output' matrices

Definition at line 106 of file ambi_roomsim.c.

◆ ambi_roomsim_refreshParams()

void ambi_roomsim_refreshParams ( void *const hAmbi)

Sets all intialisation flags to 1; re-initialising all settings/variables as ambi_roomsim is currently configured, at next available opportunity.

Definition at line 221 of file ambi_roomsim.c.

◆ ambi_roomsim_setChOrder()

void ambi_roomsim_setChOrder ( void *const hAmbi,
int newOrder )

Sets the Ambisonic channel ordering convention to encode with (see CH_ORDER enum)

Definition at line 342 of file ambi_roomsim.c.

◆ ambi_roomsim_setEnableIMSflag()

void ambi_roomsim_setEnableIMSflag ( void *const hAmbi,
int newValue )

Sets whether to include image sources (1) or not (0)

Definition at line 227 of file ambi_roomsim.c.

◆ ambi_roomsim_setMaxReflectionOrder()

void ambi_roomsim_setMaxReflectionOrder ( void *const hAmbi,
int newValue )

Sets the maximum reflection order.

Definition at line 233 of file ambi_roomsim.c.

◆ ambi_roomsim_setNormType()

void ambi_roomsim_setNormType ( void *const hAmbi,
int newType )

Sets the Ambisonic normalisation convention to encode with (see NORM_TYPES enum)

Definition at line 349 of file ambi_roomsim.c.

◆ ambi_roomsim_setNumReceivers()

void ambi_roomsim_setNumReceivers ( void *const hAmbi,
int new_nReceivers )

Sets the number of input SH receivers.

Definition at line 281 of file ambi_roomsim.c.

◆ ambi_roomsim_setNumSources()

void ambi_roomsim_setNumSources ( void *const hAmbi,
int new_nSources )

Sets the number of input signals/sources to encode.

Definition at line 254 of file ambi_roomsim.c.

◆ ambi_roomsim_setOutputOrder()

void ambi_roomsim_setOutputOrder ( void *const hAmbi,
int newOrder )

Sets the encoding order (see SH_ORDERS enum)

Definition at line 239 of file ambi_roomsim.c.

◆ ambi_roomsim_setReceiverX()

void ambi_roomsim_setReceiverX ( void *const hAmbi,
int index,
float newValue )

Sets the 'x' coordinate for a specific receiver index.

Parameters
[in]hAmbiambi_roomsim handle
[in]indexReceiver index
[in]newValueNew 'x' coordinate, in metres

Definition at line 287 of file ambi_roomsim.c.

◆ ambi_roomsim_setReceiverY()

void ambi_roomsim_setReceiverY ( void *const hAmbi,
int index,
float newValue )

Sets the 'y' coordinate for a specific receiver index.

Parameters
[in]hAmbiambi_roomsim handle
[in]indexReceiver index
[in]newValueNew 'y' coordinate, in metres

Definition at line 294 of file ambi_roomsim.c.

◆ ambi_roomsim_setReceiverZ()

void ambi_roomsim_setReceiverZ ( void *const hAmbi,
int index,
float newValue )

Sets the 'z' coordinate for a specific receiver index.

Parameters
[in]hAmbiambi_roomsim handle
[in]indexReceiver index
[in]newValueNew 'z' coordinate, in metres

Definition at line 301 of file ambi_roomsim.c.

◆ ambi_roomsim_setRoomDimX()

void ambi_roomsim_setRoomDimX ( void *const hAmbi,
float newValue )

Sets the room length along the x dimension.

Definition at line 308 of file ambi_roomsim.c.

◆ ambi_roomsim_setRoomDimY()

void ambi_roomsim_setRoomDimY ( void *const hAmbi,
float newValue )

Sets the room length along the y dimension.

Definition at line 316 of file ambi_roomsim.c.

◆ ambi_roomsim_setRoomDimZ()

void ambi_roomsim_setRoomDimZ ( void *const hAmbi,
float newValue )

Sets the room length along the z dimension.

Definition at line 324 of file ambi_roomsim.c.

◆ ambi_roomsim_setSourceX()

void ambi_roomsim_setSourceX ( void *const hAmbi,
int index,
float newValue )

Sets the 'x' coordinate for a specific source index.

Parameters
[in]hAmbiambi_roomsim handle
[in]indexSource index
[in]newValueNew 'x' coordinate, in metres

Definition at line 260 of file ambi_roomsim.c.

◆ ambi_roomsim_setSourceY()

void ambi_roomsim_setSourceY ( void *const hAmbi,
int index,
float newValue )

Sets the 'y' coordinate for a specific source index.

Parameters
[in]hAmbiambi_roomsim handle
[in]indexSource index
[in]newValueNew 'y' coordinate, in metres

Definition at line 267 of file ambi_roomsim.c.

◆ ambi_roomsim_setSourceZ()

void ambi_roomsim_setSourceZ ( void *const hAmbi,
int index,
float newValue )

Sets the 'z' coordinate for a specific source index.

Parameters
[in]hAmbiambi_roomsim handle
[in]indexSource index
[in]newValueNew 'z' coordinate, in metres

Definition at line 274 of file ambi_roomsim.c.

◆ ambi_roomsim_setWallAbsCoeff()

void ambi_roomsim_setWallAbsCoeff ( void *const hAmbi,
int xyz_idx,
int posNeg_idx,
float new_value )

Sets wall absorption coefficients.

Definition at line 332 of file ambi_roomsim.c.

Variable Documentation

◆ default_abs_wall

const float default_abs_wall[6] = { 0.341055000f, 0.431295000f, 0.351295000f, 0.344335000f, 0.401775000f, 0.482095000f}

Default absorption coefficients per wall.

Definition at line 30 of file ambi_roomsim.c.

◆ default_room_dims

const float default_room_dims[3] = { 9.1f, 8.0f, 3.0f }

Default room dimensions.

Definition at line 32 of file ambi_roomsim.c.