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 (void)
 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 (void)
 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 (void)
 Returns the processing delay in samples (may be used for delay compensation features)
 

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 29 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 63 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 460 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 348 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 343 of file ambi_roomsim.c.

◆ ambi_roomsim_getMaxNumReceivers()

int ambi_roomsim_getMaxNumReceivers ( void )

Returns the maximum number of receivers.

Definition at line 410 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 372 of file ambi_roomsim.c.

◆ ambi_roomsim_getMaxReflectionOrder()

int ambi_roomsim_getMaxReflectionOrder ( void *const hAmbi)

Returns the maximum reflection order.

Definition at line 354 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 466 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 377 of file ambi_roomsim.c.

◆ ambi_roomsim_getNumReceivers()

int ambi_roomsim_getNumReceivers ( void *const hAmbi)

Returns the number of SH receivers.

Definition at line 404 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 366 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 360 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 472 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 415 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 422 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 429 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 436 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 442 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 448 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 383 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 390 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 397 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 454 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 80 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 90 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 205 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 326 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 211 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 217 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 333 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 265 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 238 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 223 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 271 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 278 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 285 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 292 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 300 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 308 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 244 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 251 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 258 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 316 of file ambi_roomsim.c.