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

A simple shoebox room Ambisonic encoder. More...

#include "_common.h"

Go to the source code of this file.

Macros

#define ROOM_SIM_MAX_NUM_RECEIVERS   ( 16 )
 Maximum supported number of receivers for the room sim example.
 
#define ROOM_SIM_MAX_NUM_SOURCES   ( 16 )
 Maximum supported number of sources for the room sim example.
 

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 *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 newValue)
 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_nReceievers)
 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)
 

Variables

const float ambi_roomsim_default_abs_wall [6]
 Default wall absorption coefficients.
 
const float ambi_roomsim_default_room_dims [3]
 Default room dimensions.
 
const int ambi_roomsim_defaultNumSources
 Default number of sources in the simulation.
 
const float ambi_roomsim_defaultSourcePositions [ROOM_SIM_MAX_NUM_SOURCES][3]
 Default source positions.
 
const int ambi_roomsim_defaultNumReceivers
 Default number of receivers in the simulation.
 
const float ambi_roomsim_defaultReceiverPositions [ROOM_SIM_MAX_NUM_RECEIVERS][3]
 Default receiver positions.
 

Detailed Description

A simple shoebox room Ambisonic encoder.

Author
Leo McCormack
Date
10.08.2020
License
ISC

Definition in file ambi_roomsim.h.

Macro Definition Documentation

◆ ROOM_SIM_MAX_NUM_RECEIVERS

#define ROOM_SIM_MAX_NUM_RECEIVERS   ( 16 )

Maximum supported number of receivers for the room sim example.

Definition at line 50 of file ambi_roomsim.h.

◆ ROOM_SIM_MAX_NUM_SOURCES

#define ROOM_SIM_MAX_NUM_SOURCES   ( 16 )

Maximum supported number of sources for the room sim example.

Definition at line 52 of file ambi_roomsim.h.

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
Examples
ambi_roomsim.h.

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
Examples
ambi_roomsim.h.

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)

Examples
ambi_roomsim.h.

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)

Examples
ambi_roomsim.h.

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 )

Examples
ambi_roomsim.h.

Definition at line 343 of file ambi_roomsim.c.

◆ ambi_roomsim_getMaxNumReceivers()

int ambi_roomsim_getMaxNumReceivers ( void )

Returns the maximum number of receivers.

Examples
ambi_roomsim.h.

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.

Examples
ambi_roomsim.h.

Definition at line 372 of file ambi_roomsim.c.

◆ ambi_roomsim_getMaxReflectionOrder()

int ambi_roomsim_getMaxReflectionOrder ( void *const hAmbi)

Returns the maximum reflection order.

Examples
ambi_roomsim.h.

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)

Examples
ambi_roomsim.h.

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.

Examples
ambi_roomsim.h.

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.

Examples
ambi_roomsim.h.

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.

Examples
ambi_roomsim.h.

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.

Examples
ambi_roomsim.h.

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)

Examples
ambi_roomsim.h.

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.

Examples
ambi_roomsim.h.

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.

Examples
ambi_roomsim.h.

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.

Examples
ambi_roomsim.h.

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.

Examples
ambi_roomsim.h.

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.

Examples
ambi_roomsim.h.

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.

Examples
ambi_roomsim.h.

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.

Examples
ambi_roomsim.h.

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.

Examples
ambi_roomsim.h.

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.

Examples
ambi_roomsim.h.

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.

Examples
ambi_roomsim.h.

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.
Examples
ambi_roomsim.h.

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
Examples
ambi_roomsim.h.

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.

Examples
ambi_roomsim.h.

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)

Examples
ambi_roomsim.h.

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)

Examples
ambi_roomsim.h.

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.

Examples
ambi_roomsim.h.

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)

Examples
ambi_roomsim.h.

Definition at line 333 of file ambi_roomsim.c.

◆ ambi_roomsim_setNumReceivers()

void ambi_roomsim_setNumReceivers ( void *const hAmbi,
int new_nReceievers )

Sets the number of input SH receivers.

Examples
ambi_roomsim.h.

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.

Examples
ambi_roomsim.h.

Definition at line 238 of file ambi_roomsim.c.

◆ ambi_roomsim_setOutputOrder()

void ambi_roomsim_setOutputOrder ( void *const hAmbi,
int newValue )

Sets the encoding order (see SH_ORDERS enum)

Examples
ambi_roomsim.h.

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
Examples
ambi_roomsim.h.

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
Examples
ambi_roomsim.h.

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
Examples
ambi_roomsim.h.

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.

Examples
ambi_roomsim.h.

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.

Examples
ambi_roomsim.h.

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.

Examples
ambi_roomsim.h.

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
Examples
ambi_roomsim.h.

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
Examples
ambi_roomsim.h.

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
Examples
ambi_roomsim.h.

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.

Examples
ambi_roomsim.h.

Definition at line 316 of file ambi_roomsim.c.

Variable Documentation

◆ ambi_roomsim_default_abs_wall

const float ambi_roomsim_default_abs_wall[6]
extern

Default wall absorption coefficients.

Definition at line 29 of file ambi_roomsim_internal.c.

◆ ambi_roomsim_default_room_dims

const float ambi_roomsim_default_room_dims[3]
extern

Default room dimensions.

Definition at line 31 of file ambi_roomsim_internal.c.

◆ ambi_roomsim_defaultNumReceivers

const int ambi_roomsim_defaultNumReceivers
extern

Default number of receivers in the simulation.

Definition at line 42 of file ambi_roomsim_internal.c.

◆ ambi_roomsim_defaultNumSources

const int ambi_roomsim_defaultNumSources
extern

Default number of sources in the simulation.

Definition at line 33 of file ambi_roomsim_internal.c.

◆ ambi_roomsim_defaultReceiverPositions

const float ambi_roomsim_defaultReceiverPositions[ROOM_SIM_MAX_NUM_RECEIVERS][3]
extern

Default receiver positions.

Definition at line 44 of file ambi_roomsim_internal.c.

◆ ambi_roomsim_defaultSourcePositions

const float ambi_roomsim_defaultSourcePositions[ROOM_SIM_MAX_NUM_SOURCES][3]
extern

Default source positions.

Definition at line 35 of file ambi_roomsim_internal.c.